Fossil SCM

Make it impossible to remove the "branch" and the "sym-<branchname>" tag from a check-in through the ci_edit page. Any check-in must have those two tags, the "Branching" section already contains a check-button suitable to change the branch.

jan.nijtmans 2013-12-04 08:39 UTC trunk
Commit 64c21ef6860d49c91fbfeeb72ffe1cbc4e54f799
1 file changed +21 -10
+21 -10
--- src/info.c
+++ src/info.c
@@ -2053,13 +2053,15 @@
20532053
const char *zNewBrFlag;
20542054
const char *zNewBranch;
20552055
const char *zCloseFlag;
20562056
int fPropagateColor; /* True if color propagates before edit */
20572057
int fNewPropagateColor; /* True if color propagates after edit */
2058
+ int fHasClosed = 0; /* True if closed tag already set */
20582059
const char *zChngTime = 0; /* Value of chngtime= query param, if any */
20592060
char *zUuid;
20602061
Blob comment;
2062
+ char *zBranchName = 0;
20612063
Stmt q;
20622064
20632065
login_check_credentials();
20642066
if( !g.perm.Write ){ login_needed(); return; }
20652067
rid = name_to_typed_rid(P("r"), "ci");
@@ -2275,32 +2277,44 @@
22752277
@ <label><input type="checkbox" id="newtag" name="newtag"%s(zNewTagFlag) />
22762278
@ Add the following new tag name to this check-in:</label>
22772279
@ <input type="text" style="width:15;" name="tagname" value="%h(zNewTag)"
22782280
@ onkeyup="gebi('newtag').checked=!!this.value" />
22792281
db_prepare(&q,
2280
- "SELECT tag.tagid, tagname FROM tagxref, tag"
2282
+ "SELECT tag.tagid, tagname, tagxref.value FROM tagxref, tag"
22812283
" WHERE tagxref.rid=%d AND tagtype>0 AND tagxref.tagid=tag.tagid"
22822284
" ORDER BY CASE WHEN tagname GLOB 'sym-*' THEN substr(tagname,5)"
22832285
" ELSE tagname END /*sort*/",
22842286
rid
22852287
);
22862288
while( db_step(&q)==SQLITE_ROW ){
22872289
int tagid = db_column_int(&q, 0);
22882290
const char *zTagName = db_column_text(&q, 1);
2291
+ int isSpecialTag = strncmp(zTagName, "sym-", 4)!=0;
22892292
char zLabel[30];
2290
- if (tagid == TAG_COMMENT) continue;
2293
+
2294
+ if (tagid == TAG_CLOSED){
2295
+ fHasClosed = 1;
2296
+ }else if (tagid == TAG_COMMENT){
2297
+ continue;
2298
+ }else if (tagid == TAG_BRANCH){
2299
+ zBranchName = mprintf("%s", db_column_text(&q, 2));
2300
+ continue;
2301
+ }else if( !isSpecialTag && zBranchName &&
2302
+ strcmp(&zTagName[4], zBranchName)==0){
2303
+ continue;
2304
+ }
22912305
sqlite3_snprintf(sizeof(zLabel), zLabel, "c%d", tagid);
22922306
@ <br /><label>
22932307
if( P(zLabel) ){
22942308
@ <input type="checkbox" name="c%d(tagid)" checked="checked" />
22952309
}else{
22962310
@ <input type="checkbox" name="c%d(tagid)" />
22972311
}
2298
- if( strncmp(zTagName, "sym-", 4)==0 ){
2299
- @ Cancel tag <b>%h(&zTagName[4])</b></label>
2312
+ if( isSpecialTag ){
2313
+ @ Cancel special tag <b>%h(zTagName)</b></label>
23002314
}else{
2301
- @ Cancel special tag <b>%h(zTagName)</b></label>
2315
+ @ Cancel tag <b>%h(&zTagName[4])</b></label>
23022316
}
23032317
}
23042318
db_finalize(&q);
23052319
@ </td></tr>
23062320
@@ -2310,22 +2324,19 @@
23102324
@ Make this check-in the start of a new branch named:</label>
23112325
@ <input type="text" style="width:15;" name="brname" value="%h(zNewBranch)"
23122326
@ onkeyup="gebi('newbr').checked=!!this.value" />
23132327
@ </td></tr>
23142328
2315
- if( is_a_leaf(rid)
2316
- && !db_exists("SELECT 1 FROM tagxref "
2317
- " WHERE tagid=%d AND rid=%d AND tagtype>0",
2318
- TAG_CLOSED, rid)
2319
- ){
2329
+ if( !fHasClosed && is_a_leaf(rid) ){
23202330
@ <tr><th align="right" valign="top">Leaf Closure:</th>
23212331
@ <td valign="top">
23222332
@ <label><input type="checkbox" name="close"%s(zCloseFlag) />
23232333
@ Mark this leaf as "closed" so that it no longer appears on the
23242334
@ "leaves" page and is no longer labeled as a "<b>Leaf</b>"</label>
23252335
@ </td></tr>
23262336
}
2337
+ if(zBranchName) fossil_free(zBranchName);
23272338
23282339
23292340
@ <tr><td colspan="2">
23302341
@ <input type="submit" name="preview" value="Preview" />
23312342
@ <input type="submit" name="apply" value="Apply Changes" />
23322343
--- src/info.c
+++ src/info.c
@@ -2053,13 +2053,15 @@
2053 const char *zNewBrFlag;
2054 const char *zNewBranch;
2055 const char *zCloseFlag;
2056 int fPropagateColor; /* True if color propagates before edit */
2057 int fNewPropagateColor; /* True if color propagates after edit */
 
2058 const char *zChngTime = 0; /* Value of chngtime= query param, if any */
2059 char *zUuid;
2060 Blob comment;
 
2061 Stmt q;
2062
2063 login_check_credentials();
2064 if( !g.perm.Write ){ login_needed(); return; }
2065 rid = name_to_typed_rid(P("r"), "ci");
@@ -2275,32 +2277,44 @@
2275 @ <label><input type="checkbox" id="newtag" name="newtag"%s(zNewTagFlag) />
2276 @ Add the following new tag name to this check-in:</label>
2277 @ <input type="text" style="width:15;" name="tagname" value="%h(zNewTag)"
2278 @ onkeyup="gebi('newtag').checked=!!this.value" />
2279 db_prepare(&q,
2280 "SELECT tag.tagid, tagname FROM tagxref, tag"
2281 " WHERE tagxref.rid=%d AND tagtype>0 AND tagxref.tagid=tag.tagid"
2282 " ORDER BY CASE WHEN tagname GLOB 'sym-*' THEN substr(tagname,5)"
2283 " ELSE tagname END /*sort*/",
2284 rid
2285 );
2286 while( db_step(&q)==SQLITE_ROW ){
2287 int tagid = db_column_int(&q, 0);
2288 const char *zTagName = db_column_text(&q, 1);
 
2289 char zLabel[30];
2290 if (tagid == TAG_COMMENT) continue;
 
 
 
 
 
 
 
 
 
 
 
2291 sqlite3_snprintf(sizeof(zLabel), zLabel, "c%d", tagid);
2292 @ <br /><label>
2293 if( P(zLabel) ){
2294 @ <input type="checkbox" name="c%d(tagid)" checked="checked" />
2295 }else{
2296 @ <input type="checkbox" name="c%d(tagid)" />
2297 }
2298 if( strncmp(zTagName, "sym-", 4)==0 ){
2299 @ Cancel tag <b>%h(&zTagName[4])</b></label>
2300 }else{
2301 @ Cancel special tag <b>%h(zTagName)</b></label>
2302 }
2303 }
2304 db_finalize(&q);
2305 @ </td></tr>
2306
@@ -2310,22 +2324,19 @@
2310 @ Make this check-in the start of a new branch named:</label>
2311 @ <input type="text" style="width:15;" name="brname" value="%h(zNewBranch)"
2312 @ onkeyup="gebi('newbr').checked=!!this.value" />
2313 @ </td></tr>
2314
2315 if( is_a_leaf(rid)
2316 && !db_exists("SELECT 1 FROM tagxref "
2317 " WHERE tagid=%d AND rid=%d AND tagtype>0",
2318 TAG_CLOSED, rid)
2319 ){
2320 @ <tr><th align="right" valign="top">Leaf Closure:</th>
2321 @ <td valign="top">
2322 @ <label><input type="checkbox" name="close"%s(zCloseFlag) />
2323 @ Mark this leaf as "closed" so that it no longer appears on the
2324 @ "leaves" page and is no longer labeled as a "<b>Leaf</b>"</label>
2325 @ </td></tr>
2326 }
 
2327
2328
2329 @ <tr><td colspan="2">
2330 @ <input type="submit" name="preview" value="Preview" />
2331 @ <input type="submit" name="apply" value="Apply Changes" />
2332
--- src/info.c
+++ src/info.c
@@ -2053,13 +2053,15 @@
2053 const char *zNewBrFlag;
2054 const char *zNewBranch;
2055 const char *zCloseFlag;
2056 int fPropagateColor; /* True if color propagates before edit */
2057 int fNewPropagateColor; /* True if color propagates after edit */
2058 int fHasClosed = 0; /* True if closed tag already set */
2059 const char *zChngTime = 0; /* Value of chngtime= query param, if any */
2060 char *zUuid;
2061 Blob comment;
2062 char *zBranchName = 0;
2063 Stmt q;
2064
2065 login_check_credentials();
2066 if( !g.perm.Write ){ login_needed(); return; }
2067 rid = name_to_typed_rid(P("r"), "ci");
@@ -2275,32 +2277,44 @@
2277 @ <label><input type="checkbox" id="newtag" name="newtag"%s(zNewTagFlag) />
2278 @ Add the following new tag name to this check-in:</label>
2279 @ <input type="text" style="width:15;" name="tagname" value="%h(zNewTag)"
2280 @ onkeyup="gebi('newtag').checked=!!this.value" />
2281 db_prepare(&q,
2282 "SELECT tag.tagid, tagname, tagxref.value FROM tagxref, tag"
2283 " WHERE tagxref.rid=%d AND tagtype>0 AND tagxref.tagid=tag.tagid"
2284 " ORDER BY CASE WHEN tagname GLOB 'sym-*' THEN substr(tagname,5)"
2285 " ELSE tagname END /*sort*/",
2286 rid
2287 );
2288 while( db_step(&q)==SQLITE_ROW ){
2289 int tagid = db_column_int(&q, 0);
2290 const char *zTagName = db_column_text(&q, 1);
2291 int isSpecialTag = strncmp(zTagName, "sym-", 4)!=0;
2292 char zLabel[30];
2293
2294 if (tagid == TAG_CLOSED){
2295 fHasClosed = 1;
2296 }else if (tagid == TAG_COMMENT){
2297 continue;
2298 }else if (tagid == TAG_BRANCH){
2299 zBranchName = mprintf("%s", db_column_text(&q, 2));
2300 continue;
2301 }else if( !isSpecialTag && zBranchName &&
2302 strcmp(&zTagName[4], zBranchName)==0){
2303 continue;
2304 }
2305 sqlite3_snprintf(sizeof(zLabel), zLabel, "c%d", tagid);
2306 @ <br /><label>
2307 if( P(zLabel) ){
2308 @ <input type="checkbox" name="c%d(tagid)" checked="checked" />
2309 }else{
2310 @ <input type="checkbox" name="c%d(tagid)" />
2311 }
2312 if( isSpecialTag ){
2313 @ Cancel special tag <b>%h(zTagName)</b></label>
2314 }else{
2315 @ Cancel tag <b>%h(&zTagName[4])</b></label>
2316 }
2317 }
2318 db_finalize(&q);
2319 @ </td></tr>
2320
@@ -2310,22 +2324,19 @@
2324 @ Make this check-in the start of a new branch named:</label>
2325 @ <input type="text" style="width:15;" name="brname" value="%h(zNewBranch)"
2326 @ onkeyup="gebi('newbr').checked=!!this.value" />
2327 @ </td></tr>
2328
2329 if( !fHasClosed && is_a_leaf(rid) ){
 
 
 
 
2330 @ <tr><th align="right" valign="top">Leaf Closure:</th>
2331 @ <td valign="top">
2332 @ <label><input type="checkbox" name="close"%s(zCloseFlag) />
2333 @ Mark this leaf as "closed" so that it no longer appears on the
2334 @ "leaves" page and is no longer labeled as a "<b>Leaf</b>"</label>
2335 @ </td></tr>
2336 }
2337 if(zBranchName) fossil_free(zBranchName);
2338
2339
2340 @ <tr><td colspan="2">
2341 @ <input type="submit" name="preview" value="Preview" />
2342 @ <input type="submit" name="apply" value="Apply Changes" />
2343

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button