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.

drh 2009-12-09 23:35 trunk
Commit 68bfc1d5ccf953b9772ea171aa4e4ef05b18513f
1 file changed +12 -4
+12 -4
--- src/checkin.c
+++ src/checkin.c
@@ -257,22 +257,23 @@
257257
** the VISUAL or EDITOR environment variable.
258258
**
259259
** Store the final commit comment in pComment. pComment is assumed
260260
** to be uninitialized - any prior content is overwritten.
261261
*/
262
-static void prepare_commit_comment(Blob *pComment){
262
+static void prepare_commit_comment(Blob *pComment, char *zInit){
263263
const char *zEditor;
264264
char *zCmd;
265265
char *zFile;
266266
Blob text, line;
267267
char *zComment;
268268
int i;
269
- blob_set(&text,
269
+ blob_init(&text, zInit, -1);
270
+ blob_append(&text,
270271
"\n"
271272
"# Enter comments on this check-in. Lines beginning with # are ignored.\n"
272273
"# The check-in comment follows wiki formatting rules.\n"
273
- "#\n"
274
+ "#\n", -1
274275
);
275276
if( g.markPrivate ){
276277
blob_append(&text,
277278
"# PRIVATE BRANCH: This check-in will be private and will not sync to\n"
278279
"# repositories.\n"
@@ -538,19 +539,25 @@
538539
vfile_aggregate_checksum_disk(vid, &cksum1);
539540
if( zComment ){
540541
blob_zero(&comment);
541542
blob_append(&comment, zComment, -1);
542543
}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);
544547
if( blob_size(&comment)==0 ){
545548
Blob ans;
546549
blob_zero(&ans);
547550
prompt_user("empty check-in comment. continue [y/N]? ", &ans);
548551
if( blob_str(&ans)[0]!='y' ){
549552
db_end_transaction(1);
550553
exit(1);
551554
}
555
+ }else{
556
+ db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment);
557
+ db_end_transaction(0);
558
+ db_begin_transaction();
552559
}
553560
}
554561
555562
/* Step 1: Insert records for all modified files into the blob
556563
** table. If there were arguments passed to this command, only
@@ -735,10 +742,11 @@
735742
736743
/* Clear the undo/redo stack */
737744
undo_reset();
738745
739746
/* Commit */
747
+ db_multi_exec("DELETE FROM vvar WHERE name='ci-comment'");
740748
db_end_transaction(0);
741749
742750
if( !g.markPrivate ){
743751
autosync(AUTOSYNC_PUSH);
744752
}
745753
--- 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

Keyboard Shortcuts

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