Fossil SCM
Update the "checkin" command so that the template check-in message contains a comment that shows the branch tags that will be associated with the new check-in.
Commit
6df39e37f2094628ecdda8f3575deabfa63c5fa9
Parent
9c06ea312083459…
2 files changed
+22
-2
+19
-6
+22
-2
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -261,12 +261,26 @@ | ||
| 261 | 261 | ** editor specified in the global_config table or either |
| 262 | 262 | ** the VISUAL or EDITOR environment variable. |
| 263 | 263 | ** |
| 264 | 264 | ** Store the final commit comment in pComment. pComment is assumed |
| 265 | 265 | ** to be uninitialized - any prior content is overwritten. |
| 266 | +** | |
| 267 | +** zInit is the text of the most recent failed attempt to check in | |
| 268 | +** this same change. Use zInit to reinitialize the check-in comment | |
| 269 | +** so that the user does not have to retype. | |
| 270 | +** | |
| 271 | +** zBranch is the name of a new branch that this check-in is forced into. | |
| 272 | +** zBranch might be NULL or an empty string if no forcing occurs. | |
| 273 | +** | |
| 274 | +** parent_rid is the recordid of the parent check-in. | |
| 266 | 275 | */ |
| 267 | -static void prepare_commit_comment(Blob *pComment, char *zInit){ | |
| 276 | +static void prepare_commit_comment( | |
| 277 | + Blob *pComment, | |
| 278 | + char *zInit, | |
| 279 | + const char *zBranch, | |
| 280 | + int parent_rid | |
| 281 | +){ | |
| 268 | 282 | const char *zEditor; |
| 269 | 283 | char *zCmd; |
| 270 | 284 | char *zFile; |
| 271 | 285 | Blob text, line; |
| 272 | 286 | char *zComment; |
| @@ -276,10 +290,16 @@ | ||
| 276 | 290 | "\n" |
| 277 | 291 | "# Enter comments on this check-in. Lines beginning with # are ignored.\n" |
| 278 | 292 | "# The check-in comment follows wiki formatting rules.\n" |
| 279 | 293 | "#\n", -1 |
| 280 | 294 | ); |
| 295 | + if( zBranch && zBranch[0] ){ | |
| 296 | + blob_appendf(&text, "# tags: %s\n#\n", zBranch); | |
| 297 | + }else{ | |
| 298 | + char *zTags = info_tags_of_checkin(parent_rid); | |
| 299 | + if( zTags ) blob_appendf(&text, "# tags: %z\n#\n", zTags); | |
| 300 | + } | |
| 281 | 301 | if( g.markPrivate ){ |
| 282 | 302 | blob_append(&text, |
| 283 | 303 | "# PRIVATE BRANCH: This check-in will be private and will not sync to\n" |
| 284 | 304 | "# repositories.\n" |
| 285 | 305 | "#\n", -1 |
| @@ -558,11 +578,11 @@ | ||
| 558 | 578 | }else if( zCommentFile ){ |
| 559 | 579 | blob_zero(&comment); |
| 560 | 580 | blob_read_from_file(&comment, zCommentFile); |
| 561 | 581 | }else{ |
| 562 | 582 | char *zInit = db_text(0, "SELECT value FROM vvar WHERE name='ci-comment'"); |
| 563 | - prepare_commit_comment(&comment, zInit); | |
| 583 | + prepare_commit_comment(&comment, zInit, zBranch, vid); | |
| 564 | 584 | free(zInit); |
| 565 | 585 | } |
| 566 | 586 | if( blob_size(&comment)==0 ){ |
| 567 | 587 | Blob ans; |
| 568 | 588 | blob_zero(&ans); |
| 569 | 589 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -261,12 +261,26 @@ | |
| 261 | ** editor specified in the global_config table or either |
| 262 | ** the VISUAL or EDITOR environment variable. |
| 263 | ** |
| 264 | ** Store the final commit comment in pComment. pComment is assumed |
| 265 | ** to be uninitialized - any prior content is overwritten. |
| 266 | */ |
| 267 | static void prepare_commit_comment(Blob *pComment, char *zInit){ |
| 268 | const char *zEditor; |
| 269 | char *zCmd; |
| 270 | char *zFile; |
| 271 | Blob text, line; |
| 272 | char *zComment; |
| @@ -276,10 +290,16 @@ | |
| 276 | "\n" |
| 277 | "# Enter comments on this check-in. Lines beginning with # are ignored.\n" |
| 278 | "# The check-in comment follows wiki formatting rules.\n" |
| 279 | "#\n", -1 |
| 280 | ); |
| 281 | if( g.markPrivate ){ |
| 282 | blob_append(&text, |
| 283 | "# PRIVATE BRANCH: This check-in will be private and will not sync to\n" |
| 284 | "# repositories.\n" |
| 285 | "#\n", -1 |
| @@ -558,11 +578,11 @@ | |
| 558 | }else if( zCommentFile ){ |
| 559 | blob_zero(&comment); |
| 560 | blob_read_from_file(&comment, zCommentFile); |
| 561 | }else{ |
| 562 | char *zInit = db_text(0, "SELECT value FROM vvar WHERE name='ci-comment'"); |
| 563 | prepare_commit_comment(&comment, zInit); |
| 564 | free(zInit); |
| 565 | } |
| 566 | if( blob_size(&comment)==0 ){ |
| 567 | Blob ans; |
| 568 | blob_zero(&ans); |
| 569 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -261,12 +261,26 @@ | |
| 261 | ** editor specified in the global_config table or either |
| 262 | ** the VISUAL or EDITOR environment variable. |
| 263 | ** |
| 264 | ** Store the final commit comment in pComment. pComment is assumed |
| 265 | ** to be uninitialized - any prior content is overwritten. |
| 266 | ** |
| 267 | ** zInit is the text of the most recent failed attempt to check in |
| 268 | ** this same change. Use zInit to reinitialize the check-in comment |
| 269 | ** so that the user does not have to retype. |
| 270 | ** |
| 271 | ** zBranch is the name of a new branch that this check-in is forced into. |
| 272 | ** zBranch might be NULL or an empty string if no forcing occurs. |
| 273 | ** |
| 274 | ** parent_rid is the recordid of the parent check-in. |
| 275 | */ |
| 276 | static void prepare_commit_comment( |
| 277 | Blob *pComment, |
| 278 | char *zInit, |
| 279 | const char *zBranch, |
| 280 | int parent_rid |
| 281 | ){ |
| 282 | const char *zEditor; |
| 283 | char *zCmd; |
| 284 | char *zFile; |
| 285 | Blob text, line; |
| 286 | char *zComment; |
| @@ -276,10 +290,16 @@ | |
| 290 | "\n" |
| 291 | "# Enter comments on this check-in. Lines beginning with # are ignored.\n" |
| 292 | "# The check-in comment follows wiki formatting rules.\n" |
| 293 | "#\n", -1 |
| 294 | ); |
| 295 | if( zBranch && zBranch[0] ){ |
| 296 | blob_appendf(&text, "# tags: %s\n#\n", zBranch); |
| 297 | }else{ |
| 298 | char *zTags = info_tags_of_checkin(parent_rid); |
| 299 | if( zTags ) blob_appendf(&text, "# tags: %z\n#\n", zTags); |
| 300 | } |
| 301 | if( g.markPrivate ){ |
| 302 | blob_append(&text, |
| 303 | "# PRIVATE BRANCH: This check-in will be private and will not sync to\n" |
| 304 | "# repositories.\n" |
| 305 | "#\n", -1 |
| @@ -558,11 +578,11 @@ | |
| 578 | }else if( zCommentFile ){ |
| 579 | blob_zero(&comment); |
| 580 | blob_read_from_file(&comment, zCommentFile); |
| 581 | }else{ |
| 582 | char *zInit = db_text(0, "SELECT value FROM vvar WHERE name='ci-comment'"); |
| 583 | prepare_commit_comment(&comment, zInit, zBranch, vid); |
| 584 | free(zInit); |
| 585 | } |
| 586 | if( blob_size(&comment)==0 ){ |
| 587 | Blob ans; |
| 588 | blob_zero(&ans); |
| 589 |
+19
-6
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -27,10 +27,28 @@ | ||
| 27 | 27 | */ |
| 28 | 28 | #include "config.h" |
| 29 | 29 | #include "info.h" |
| 30 | 30 | #include <assert.h> |
| 31 | 31 | |
| 32 | +/* | |
| 33 | +** Return a string (in memory obtained from malloc) holding a | |
| 34 | +** comma-separated list of tags that apply to check-in with | |
| 35 | +** record-id rid. | |
| 36 | +** | |
| 37 | +** Return NULL if there are no such tags. | |
| 38 | +*/ | |
| 39 | +char *info_tags_of_checkin(int rid){ | |
| 40 | + char *zTags; | |
| 41 | + zTags = db_text(0, "SELECT group_concat(substr(tagname, 5), ', ')" | |
| 42 | + " FROM tagxref, tag" | |
| 43 | + " WHERE tagxref.rid=%d AND tagxref.tagtype>0" | |
| 44 | + " AND tag.tagid=tagxref.tagid" | |
| 45 | + " AND tag.tagname GLOB 'sym-*'", | |
| 46 | + rid); | |
| 47 | + return zTags; | |
| 48 | +} | |
| 49 | + | |
| 32 | 50 | |
| 33 | 51 | /* |
| 34 | 52 | ** Print common information about a particular record. |
| 35 | 53 | ** |
| 36 | 54 | ** * The UUID |
| @@ -77,16 +95,11 @@ | ||
| 77 | 95 | ); |
| 78 | 96 | printf("child: %s %s\n", zUuid, zDate); |
| 79 | 97 | free(zDate); |
| 80 | 98 | } |
| 81 | 99 | db_finalize(&q); |
| 82 | - zTags = db_text(0, "SELECT group_concat(substr(tagname, 5), ', ')" | |
| 83 | - " FROM tagxref, tag" | |
| 84 | - " WHERE tagxref.rid=%d AND tagxref.tagtype>0" | |
| 85 | - " AND tag.tagid=tagxref.tagid" | |
| 86 | - " AND tag.tagname GLOB 'sym-*'", | |
| 87 | - rid); | |
| 100 | + zTags = info_tags_of_checkin(rid); | |
| 88 | 101 | if( zTags && zTags[0] ){ |
| 89 | 102 | printf("tags: %s\n", zTags); |
| 90 | 103 | } |
| 91 | 104 | free(zTags); |
| 92 | 105 | if( zComment ){ |
| 93 | 106 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -27,10 +27,28 @@ | |
| 27 | */ |
| 28 | #include "config.h" |
| 29 | #include "info.h" |
| 30 | #include <assert.h> |
| 31 | |
| 32 | |
| 33 | /* |
| 34 | ** Print common information about a particular record. |
| 35 | ** |
| 36 | ** * The UUID |
| @@ -77,16 +95,11 @@ | |
| 77 | ); |
| 78 | printf("child: %s %s\n", zUuid, zDate); |
| 79 | free(zDate); |
| 80 | } |
| 81 | db_finalize(&q); |
| 82 | zTags = db_text(0, "SELECT group_concat(substr(tagname, 5), ', ')" |
| 83 | " FROM tagxref, tag" |
| 84 | " WHERE tagxref.rid=%d AND tagxref.tagtype>0" |
| 85 | " AND tag.tagid=tagxref.tagid" |
| 86 | " AND tag.tagname GLOB 'sym-*'", |
| 87 | rid); |
| 88 | if( zTags && zTags[0] ){ |
| 89 | printf("tags: %s\n", zTags); |
| 90 | } |
| 91 | free(zTags); |
| 92 | if( zComment ){ |
| 93 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -27,10 +27,28 @@ | |
| 27 | */ |
| 28 | #include "config.h" |
| 29 | #include "info.h" |
| 30 | #include <assert.h> |
| 31 | |
| 32 | /* |
| 33 | ** Return a string (in memory obtained from malloc) holding a |
| 34 | ** comma-separated list of tags that apply to check-in with |
| 35 | ** record-id rid. |
| 36 | ** |
| 37 | ** Return NULL if there are no such tags. |
| 38 | */ |
| 39 | char *info_tags_of_checkin(int rid){ |
| 40 | char *zTags; |
| 41 | zTags = db_text(0, "SELECT group_concat(substr(tagname, 5), ', ')" |
| 42 | " FROM tagxref, tag" |
| 43 | " WHERE tagxref.rid=%d AND tagxref.tagtype>0" |
| 44 | " AND tag.tagid=tagxref.tagid" |
| 45 | " AND tag.tagname GLOB 'sym-*'", |
| 46 | rid); |
| 47 | return zTags; |
| 48 | } |
| 49 | |
| 50 | |
| 51 | /* |
| 52 | ** Print common information about a particular record. |
| 53 | ** |
| 54 | ** * The UUID |
| @@ -77,16 +95,11 @@ | |
| 95 | ); |
| 96 | printf("child: %s %s\n", zUuid, zDate); |
| 97 | free(zDate); |
| 98 | } |
| 99 | db_finalize(&q); |
| 100 | zTags = info_tags_of_checkin(rid); |
| 101 | if( zTags && zTags[0] ){ |
| 102 | printf("tags: %s\n", zTags); |
| 103 | } |
| 104 | free(zTags); |
| 105 | if( zComment ){ |
| 106 |