Fossil SCM
When a commit aborts, the check-in comment is saved and used to reinitialize the check-in comment template on the next commit attempt.
Commit
68bfc1d5ccf953b9772ea171aa4e4ef05b18513f
Parent
fb1fa7f1a6af4a4…
1 file changed
+12
-4
+12
-4
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -257,22 +257,23 @@ | ||
| 257 | 257 | ** the VISUAL or EDITOR environment variable. |
| 258 | 258 | ** |
| 259 | 259 | ** Store the final commit comment in pComment. pComment is assumed |
| 260 | 260 | ** to be uninitialized - any prior content is overwritten. |
| 261 | 261 | */ |
| 262 | -static void prepare_commit_comment(Blob *pComment){ | |
| 262 | +static void prepare_commit_comment(Blob *pComment, char *zInit){ | |
| 263 | 263 | const char *zEditor; |
| 264 | 264 | char *zCmd; |
| 265 | 265 | char *zFile; |
| 266 | 266 | Blob text, line; |
| 267 | 267 | char *zComment; |
| 268 | 268 | int i; |
| 269 | - blob_set(&text, | |
| 269 | + blob_init(&text, zInit, -1); | |
| 270 | + blob_append(&text, | |
| 270 | 271 | "\n" |
| 271 | 272 | "# Enter comments on this check-in. Lines beginning with # are ignored.\n" |
| 272 | 273 | "# The check-in comment follows wiki formatting rules.\n" |
| 273 | - "#\n" | |
| 274 | + "#\n", -1 | |
| 274 | 275 | ); |
| 275 | 276 | if( g.markPrivate ){ |
| 276 | 277 | blob_append(&text, |
| 277 | 278 | "# PRIVATE BRANCH: This check-in will be private and will not sync to\n" |
| 278 | 279 | "# repositories.\n" |
| @@ -538,19 +539,25 @@ | ||
| 538 | 539 | vfile_aggregate_checksum_disk(vid, &cksum1); |
| 539 | 540 | if( zComment ){ |
| 540 | 541 | blob_zero(&comment); |
| 541 | 542 | blob_append(&comment, zComment, -1); |
| 542 | 543 | }else{ |
| 543 | - prepare_commit_comment(&comment); | |
| 544 | + char *zInit = db_text(0, "SELECT value FROM vvar WHERE name='ci-comment'"); | |
| 545 | + prepare_commit_comment(&comment, zInit); | |
| 546 | + free(zInit); | |
| 544 | 547 | if( blob_size(&comment)==0 ){ |
| 545 | 548 | Blob ans; |
| 546 | 549 | blob_zero(&ans); |
| 547 | 550 | prompt_user("empty check-in comment. continue [y/N]? ", &ans); |
| 548 | 551 | if( blob_str(&ans)[0]!='y' ){ |
| 549 | 552 | db_end_transaction(1); |
| 550 | 553 | exit(1); |
| 551 | 554 | } |
| 555 | + }else{ | |
| 556 | + db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment); | |
| 557 | + db_end_transaction(0); | |
| 558 | + db_begin_transaction(); | |
| 552 | 559 | } |
| 553 | 560 | } |
| 554 | 561 | |
| 555 | 562 | /* Step 1: Insert records for all modified files into the blob |
| 556 | 563 | ** table. If there were arguments passed to this command, only |
| @@ -735,10 +742,11 @@ | ||
| 735 | 742 | |
| 736 | 743 | /* Clear the undo/redo stack */ |
| 737 | 744 | undo_reset(); |
| 738 | 745 | |
| 739 | 746 | /* Commit */ |
| 747 | + db_multi_exec("DELETE FROM vvar WHERE name='ci-comment'"); | |
| 740 | 748 | db_end_transaction(0); |
| 741 | 749 | |
| 742 | 750 | if( !g.markPrivate ){ |
| 743 | 751 | autosync(AUTOSYNC_PUSH); |
| 744 | 752 | } |
| 745 | 753 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -257,22 +257,23 @@ | |
| 257 | ** the VISUAL or EDITOR environment variable. |
| 258 | ** |
| 259 | ** Store the final commit comment in pComment. pComment is assumed |
| 260 | ** to be uninitialized - any prior content is overwritten. |
| 261 | */ |
| 262 | static void prepare_commit_comment(Blob *pComment){ |
| 263 | const char *zEditor; |
| 264 | char *zCmd; |
| 265 | char *zFile; |
| 266 | Blob text, line; |
| 267 | char *zComment; |
| 268 | int i; |
| 269 | blob_set(&text, |
| 270 | "\n" |
| 271 | "# Enter comments on this check-in. Lines beginning with # are ignored.\n" |
| 272 | "# The check-in comment follows wiki formatting rules.\n" |
| 273 | "#\n" |
| 274 | ); |
| 275 | if( g.markPrivate ){ |
| 276 | blob_append(&text, |
| 277 | "# PRIVATE BRANCH: This check-in will be private and will not sync to\n" |
| 278 | "# repositories.\n" |
| @@ -538,19 +539,25 @@ | |
| 538 | vfile_aggregate_checksum_disk(vid, &cksum1); |
| 539 | if( zComment ){ |
| 540 | blob_zero(&comment); |
| 541 | blob_append(&comment, zComment, -1); |
| 542 | }else{ |
| 543 | prepare_commit_comment(&comment); |
| 544 | if( blob_size(&comment)==0 ){ |
| 545 | Blob ans; |
| 546 | blob_zero(&ans); |
| 547 | prompt_user("empty check-in comment. continue [y/N]? ", &ans); |
| 548 | if( blob_str(&ans)[0]!='y' ){ |
| 549 | db_end_transaction(1); |
| 550 | exit(1); |
| 551 | } |
| 552 | } |
| 553 | } |
| 554 | |
| 555 | /* Step 1: Insert records for all modified files into the blob |
| 556 | ** table. If there were arguments passed to this command, only |
| @@ -735,10 +742,11 @@ | |
| 735 | |
| 736 | /* Clear the undo/redo stack */ |
| 737 | undo_reset(); |
| 738 | |
| 739 | /* Commit */ |
| 740 | db_end_transaction(0); |
| 741 | |
| 742 | if( !g.markPrivate ){ |
| 743 | autosync(AUTOSYNC_PUSH); |
| 744 | } |
| 745 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -257,22 +257,23 @@ | |
| 257 | ** the VISUAL or EDITOR environment variable. |
| 258 | ** |
| 259 | ** Store the final commit comment in pComment. pComment is assumed |
| 260 | ** to be uninitialized - any prior content is overwritten. |
| 261 | */ |
| 262 | static void prepare_commit_comment(Blob *pComment, char *zInit){ |
| 263 | const char *zEditor; |
| 264 | char *zCmd; |
| 265 | char *zFile; |
| 266 | Blob text, line; |
| 267 | char *zComment; |
| 268 | int i; |
| 269 | blob_init(&text, zInit, -1); |
| 270 | blob_append(&text, |
| 271 | "\n" |
| 272 | "# Enter comments on this check-in. Lines beginning with # are ignored.\n" |
| 273 | "# The check-in comment follows wiki formatting rules.\n" |
| 274 | "#\n", -1 |
| 275 | ); |
| 276 | if( g.markPrivate ){ |
| 277 | blob_append(&text, |
| 278 | "# PRIVATE BRANCH: This check-in will be private and will not sync to\n" |
| 279 | "# repositories.\n" |
| @@ -538,19 +539,25 @@ | |
| 539 | vfile_aggregate_checksum_disk(vid, &cksum1); |
| 540 | if( zComment ){ |
| 541 | blob_zero(&comment); |
| 542 | blob_append(&comment, zComment, -1); |
| 543 | }else{ |
| 544 | char *zInit = db_text(0, "SELECT value FROM vvar WHERE name='ci-comment'"); |
| 545 | prepare_commit_comment(&comment, zInit); |
| 546 | free(zInit); |
| 547 | if( blob_size(&comment)==0 ){ |
| 548 | Blob ans; |
| 549 | blob_zero(&ans); |
| 550 | prompt_user("empty check-in comment. continue [y/N]? ", &ans); |
| 551 | if( blob_str(&ans)[0]!='y' ){ |
| 552 | db_end_transaction(1); |
| 553 | exit(1); |
| 554 | } |
| 555 | }else{ |
| 556 | db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment); |
| 557 | db_end_transaction(0); |
| 558 | db_begin_transaction(); |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | /* Step 1: Insert records for all modified files into the blob |
| 563 | ** table. If there were arguments passed to this command, only |
| @@ -735,10 +742,11 @@ | |
| 742 | |
| 743 | /* Clear the undo/redo stack */ |
| 744 | undo_reset(); |
| 745 | |
| 746 | /* Commit */ |
| 747 | db_multi_exec("DELETE FROM vvar WHERE name='ci-comment'"); |
| 748 | db_end_transaction(0); |
| 749 | |
| 750 | if( !g.markPrivate ){ |
| 751 | autosync(AUTOSYNC_PUSH); |
| 752 | } |
| 753 |