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.
Commit
64c21ef6860d49c91fbfeeb72ffe1cbc4e54f799
Parent
d7543d8bbd92ab6…
1 file changed
+21
-10
+21
-10
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -2053,13 +2053,15 @@ | ||
| 2053 | 2053 | const char *zNewBrFlag; |
| 2054 | 2054 | const char *zNewBranch; |
| 2055 | 2055 | const char *zCloseFlag; |
| 2056 | 2056 | int fPropagateColor; /* True if color propagates before edit */ |
| 2057 | 2057 | int fNewPropagateColor; /* True if color propagates after edit */ |
| 2058 | + int fHasClosed = 0; /* True if closed tag already set */ | |
| 2058 | 2059 | const char *zChngTime = 0; /* Value of chngtime= query param, if any */ |
| 2059 | 2060 | char *zUuid; |
| 2060 | 2061 | Blob comment; |
| 2062 | + char *zBranchName = 0; | |
| 2061 | 2063 | Stmt q; |
| 2062 | 2064 | |
| 2063 | 2065 | login_check_credentials(); |
| 2064 | 2066 | if( !g.perm.Write ){ login_needed(); return; } |
| 2065 | 2067 | rid = name_to_typed_rid(P("r"), "ci"); |
| @@ -2275,32 +2277,44 @@ | ||
| 2275 | 2277 | @ <label><input type="checkbox" id="newtag" name="newtag"%s(zNewTagFlag) /> |
| 2276 | 2278 | @ Add the following new tag name to this check-in:</label> |
| 2277 | 2279 | @ <input type="text" style="width:15;" name="tagname" value="%h(zNewTag)" |
| 2278 | 2280 | @ onkeyup="gebi('newtag').checked=!!this.value" /> |
| 2279 | 2281 | db_prepare(&q, |
| 2280 | - "SELECT tag.tagid, tagname FROM tagxref, tag" | |
| 2282 | + "SELECT tag.tagid, tagname, tagxref.value FROM tagxref, tag" | |
| 2281 | 2283 | " WHERE tagxref.rid=%d AND tagtype>0 AND tagxref.tagid=tag.tagid" |
| 2282 | 2284 | " ORDER BY CASE WHEN tagname GLOB 'sym-*' THEN substr(tagname,5)" |
| 2283 | 2285 | " ELSE tagname END /*sort*/", |
| 2284 | 2286 | rid |
| 2285 | 2287 | ); |
| 2286 | 2288 | while( db_step(&q)==SQLITE_ROW ){ |
| 2287 | 2289 | int tagid = db_column_int(&q, 0); |
| 2288 | 2290 | const char *zTagName = db_column_text(&q, 1); |
| 2291 | + int isSpecialTag = strncmp(zTagName, "sym-", 4)!=0; | |
| 2289 | 2292 | 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 | + } | |
| 2291 | 2305 | sqlite3_snprintf(sizeof(zLabel), zLabel, "c%d", tagid); |
| 2292 | 2306 | @ <br /><label> |
| 2293 | 2307 | if( P(zLabel) ){ |
| 2294 | 2308 | @ <input type="checkbox" name="c%d(tagid)" checked="checked" /> |
| 2295 | 2309 | }else{ |
| 2296 | 2310 | @ <input type="checkbox" name="c%d(tagid)" /> |
| 2297 | 2311 | } |
| 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> | |
| 2300 | 2314 | }else{ |
| 2301 | - @ Cancel special tag <b>%h(zTagName)</b></label> | |
| 2315 | + @ Cancel tag <b>%h(&zTagName[4])</b></label> | |
| 2302 | 2316 | } |
| 2303 | 2317 | } |
| 2304 | 2318 | db_finalize(&q); |
| 2305 | 2319 | @ </td></tr> |
| 2306 | 2320 | |
| @@ -2310,22 +2324,19 @@ | ||
| 2310 | 2324 | @ Make this check-in the start of a new branch named:</label> |
| 2311 | 2325 | @ <input type="text" style="width:15;" name="brname" value="%h(zNewBranch)" |
| 2312 | 2326 | @ onkeyup="gebi('newbr').checked=!!this.value" /> |
| 2313 | 2327 | @ </td></tr> |
| 2314 | 2328 | |
| 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) ){ | |
| 2320 | 2330 | @ <tr><th align="right" valign="top">Leaf Closure:</th> |
| 2321 | 2331 | @ <td valign="top"> |
| 2322 | 2332 | @ <label><input type="checkbox" name="close"%s(zCloseFlag) /> |
| 2323 | 2333 | @ Mark this leaf as "closed" so that it no longer appears on the |
| 2324 | 2334 | @ "leaves" page and is no longer labeled as a "<b>Leaf</b>"</label> |
| 2325 | 2335 | @ </td></tr> |
| 2326 | 2336 | } |
| 2337 | + if(zBranchName) fossil_free(zBranchName); | |
| 2327 | 2338 | |
| 2328 | 2339 | |
| 2329 | 2340 | @ <tr><td colspan="2"> |
| 2330 | 2341 | @ <input type="submit" name="preview" value="Preview" /> |
| 2331 | 2342 | @ <input type="submit" name="apply" value="Apply Changes" /> |
| 2332 | 2343 |
| --- 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 |