Fossil SCM

Improve the "fossil undo" and "fossil commit" commands with a couple of bug fixes.

andybradford 2026-02-14 21:16 trunk merge
Commit f72ef850fce04521de4049fbfff5a092ba33f6983b31166712cc3b055928eacd
+1 -30
--- src/checkin.c
+++ src/checkin.c
@@ -2556,22 +2556,19 @@
25562556
int allowEmpty = 0; /* Allow a commit with no changes */
25572557
int onlyIfChanges = 0; /* No-op if there are no changes */
25582558
int allowFork = 0; /* Allow the commit to fork */
25592559
int allowOlder = 0; /* Allow a commit older than its ancestor */
25602560
int noVerifyCom = 0; /* Allow suspicious check-in comments */
2561
- char *zManifestFile; /* Name of the manifest file */
25622561
int useCksum; /* True if checksums should be computed and verified */
2563
- int outputManifest; /* True to output "manifest" and "manifest.uuid" */
25642562
int dryRunFlag; /* True for a test run. Debugging only */
25652563
CheckinInfo sCiInfo; /* Information about this check-in */
25662564
const char *zComFile; /* Read commit message from this file */
25672565
int nTag = 0; /* Number of --tag arguments */
25682566
const char *zTag; /* A single --tag argument */
25692567
ManifestFile *pFile; /* File structure in the manifest */
25702568
Manifest *pManifest; /* Manifest structure */
25712569
Blob manifest; /* Manifest in baseline form */
2572
- Blob muuid; /* Manifest uuid */
25732570
Blob cksum1, cksum2; /* Before and after commit checksums */
25742571
Blob cksum1b; /* Checksum recorded in the manifest */
25752572
int szD; /* Size of the delta manifest */
25762573
int szB; /* Size of the baseline manifest */
25772574
int nConflict = 0; /* Number of unresolved merge conflicts */
@@ -2647,11 +2644,10 @@
26472644
sCiInfo.zUserOvrd = find_option("user-override",0,1);
26482645
noSign = db_get_boolean("omitsign", 0)|noSign;
26492646
if( db_get_boolean("clearsign", 0)==0 ){ noSign = 1; }
26502647
useCksum = db_get_boolean("repo-cksum", 1);
26512648
bIgnoreSkew = find_option("ignore-clock-skew",0,0)!=0;
2652
- outputManifest = db_get_manifest_setting(0);
26532649
mxSize = db_large_file_size();
26542650
if( find_option("ignore-oversize",0,0)!=0 ) mxSize = 0;
26552651
(void)fossil_text_editor();
26562652
verify_all_options();
26572653
@@ -3209,17 +3205,10 @@
32093205
** and rollback the transaction.
32103206
*/
32113207
if( dryRunFlag ){
32123208
blob_write_to_file(&manifest, "");
32133209
}
3214
- if( outputManifest & MFESTFLG_RAW ){
3215
- zManifestFile = mprintf("%smanifest", g.zLocalRoot);
3216
- blob_write_to_file(&manifest, zManifestFile);
3217
- blob_reset(&manifest);
3218
- blob_read_from_file(&manifest, zManifestFile, ExtFILE);
3219
- free(zManifestFile);
3220
- }
32213210
32223211
nvid = content_put(&manifest);
32233212
if( nvid==0 ){
32243213
fossil_fatal("trouble committing manifest: %s", g.zErrMsg);
32253214
}
@@ -3242,18 +3231,10 @@
32423231
}
32433232
}
32443233
db_finalize(&q);
32453234
32463235
fossil_print("New_Version: %s\n", zUuid);
3247
- if( outputManifest & MFESTFLG_UUID ){
3248
- zManifestFile = mprintf("%smanifest.uuid", g.zLocalRoot);
3249
- blob_zero(&muuid);
3250
- blob_appendf(&muuid, "%s\n", zUuid);
3251
- blob_write_to_file(&muuid, zManifestFile);
3252
- free(zManifestFile);
3253
- blob_reset(&muuid);
3254
- }
32553236
32563237
/* Update the vfile and vmerge tables */
32573238
db_multi_exec(
32583239
"DELETE FROM vfile WHERE (vid!=%d OR deleted) AND is_selected(id);"
32593240
"DELETE FROM vmerge;"
@@ -3260,11 +3241,11 @@
32603241
"UPDATE vfile SET vid=%d;"
32613242
"UPDATE vfile SET rid=mrid, mhash=NULL, chnged=0, deleted=0, origname=NULL"
32623243
" WHERE is_selected(id);"
32633244
, vid, nvid
32643245
);
3265
- db_set_checkout(nvid);
3246
+ db_set_checkout(nvid, !dryRunFlag);
32663247
32673248
/* Update the isexe and islink columns of the vfile table */
32683249
db_prepare(&q,
32693250
"UPDATE vfile SET isexe=:exec, islink=:link"
32703251
" WHERE vid=:vid AND pathname=:path AND (isexe!=:exec OR islink!=:link)"
@@ -3325,20 +3306,10 @@
33253306
db_end_transaction(1);
33263307
return;
33273308
}
33283309
db_end_transaction(0);
33293310
3330
- if( outputManifest & MFESTFLG_TAGS ){
3331
- Blob tagslist;
3332
- zManifestFile = mprintf("%smanifest.tags", g.zLocalRoot);
3333
- blob_zero(&tagslist);
3334
- get_checkin_taglist(nvid, &tagslist);
3335
- blob_write_to_file(&tagslist, zManifestFile);
3336
- blob_reset(&tagslist);
3337
- free(zManifestFile);
3338
- }
3339
-
33403311
if( !g.markPrivate ){
33413312
int syncFlags = SYNC_PUSH | SYNC_PULL | SYNC_IFABLE;
33423313
autosync_loop(syncFlags, 0, "commit");
33433314
}
33443315
if( count_nonbranch_children(vid)>1 ){
33453316
--- src/checkin.c
+++ src/checkin.c
@@ -2556,22 +2556,19 @@
2556 int allowEmpty = 0; /* Allow a commit with no changes */
2557 int onlyIfChanges = 0; /* No-op if there are no changes */
2558 int allowFork = 0; /* Allow the commit to fork */
2559 int allowOlder = 0; /* Allow a commit older than its ancestor */
2560 int noVerifyCom = 0; /* Allow suspicious check-in comments */
2561 char *zManifestFile; /* Name of the manifest file */
2562 int useCksum; /* True if checksums should be computed and verified */
2563 int outputManifest; /* True to output "manifest" and "manifest.uuid" */
2564 int dryRunFlag; /* True for a test run. Debugging only */
2565 CheckinInfo sCiInfo; /* Information about this check-in */
2566 const char *zComFile; /* Read commit message from this file */
2567 int nTag = 0; /* Number of --tag arguments */
2568 const char *zTag; /* A single --tag argument */
2569 ManifestFile *pFile; /* File structure in the manifest */
2570 Manifest *pManifest; /* Manifest structure */
2571 Blob manifest; /* Manifest in baseline form */
2572 Blob muuid; /* Manifest uuid */
2573 Blob cksum1, cksum2; /* Before and after commit checksums */
2574 Blob cksum1b; /* Checksum recorded in the manifest */
2575 int szD; /* Size of the delta manifest */
2576 int szB; /* Size of the baseline manifest */
2577 int nConflict = 0; /* Number of unresolved merge conflicts */
@@ -2647,11 +2644,10 @@
2647 sCiInfo.zUserOvrd = find_option("user-override",0,1);
2648 noSign = db_get_boolean("omitsign", 0)|noSign;
2649 if( db_get_boolean("clearsign", 0)==0 ){ noSign = 1; }
2650 useCksum = db_get_boolean("repo-cksum", 1);
2651 bIgnoreSkew = find_option("ignore-clock-skew",0,0)!=0;
2652 outputManifest = db_get_manifest_setting(0);
2653 mxSize = db_large_file_size();
2654 if( find_option("ignore-oversize",0,0)!=0 ) mxSize = 0;
2655 (void)fossil_text_editor();
2656 verify_all_options();
2657
@@ -3209,17 +3205,10 @@
3209 ** and rollback the transaction.
3210 */
3211 if( dryRunFlag ){
3212 blob_write_to_file(&manifest, "");
3213 }
3214 if( outputManifest & MFESTFLG_RAW ){
3215 zManifestFile = mprintf("%smanifest", g.zLocalRoot);
3216 blob_write_to_file(&manifest, zManifestFile);
3217 blob_reset(&manifest);
3218 blob_read_from_file(&manifest, zManifestFile, ExtFILE);
3219 free(zManifestFile);
3220 }
3221
3222 nvid = content_put(&manifest);
3223 if( nvid==0 ){
3224 fossil_fatal("trouble committing manifest: %s", g.zErrMsg);
3225 }
@@ -3242,18 +3231,10 @@
3242 }
3243 }
3244 db_finalize(&q);
3245
3246 fossil_print("New_Version: %s\n", zUuid);
3247 if( outputManifest & MFESTFLG_UUID ){
3248 zManifestFile = mprintf("%smanifest.uuid", g.zLocalRoot);
3249 blob_zero(&muuid);
3250 blob_appendf(&muuid, "%s\n", zUuid);
3251 blob_write_to_file(&muuid, zManifestFile);
3252 free(zManifestFile);
3253 blob_reset(&muuid);
3254 }
3255
3256 /* Update the vfile and vmerge tables */
3257 db_multi_exec(
3258 "DELETE FROM vfile WHERE (vid!=%d OR deleted) AND is_selected(id);"
3259 "DELETE FROM vmerge;"
@@ -3260,11 +3241,11 @@
3260 "UPDATE vfile SET vid=%d;"
3261 "UPDATE vfile SET rid=mrid, mhash=NULL, chnged=0, deleted=0, origname=NULL"
3262 " WHERE is_selected(id);"
3263 , vid, nvid
3264 );
3265 db_set_checkout(nvid);
3266
3267 /* Update the isexe and islink columns of the vfile table */
3268 db_prepare(&q,
3269 "UPDATE vfile SET isexe=:exec, islink=:link"
3270 " WHERE vid=:vid AND pathname=:path AND (isexe!=:exec OR islink!=:link)"
@@ -3325,20 +3306,10 @@
3325 db_end_transaction(1);
3326 return;
3327 }
3328 db_end_transaction(0);
3329
3330 if( outputManifest & MFESTFLG_TAGS ){
3331 Blob tagslist;
3332 zManifestFile = mprintf("%smanifest.tags", g.zLocalRoot);
3333 blob_zero(&tagslist);
3334 get_checkin_taglist(nvid, &tagslist);
3335 blob_write_to_file(&tagslist, zManifestFile);
3336 blob_reset(&tagslist);
3337 free(zManifestFile);
3338 }
3339
3340 if( !g.markPrivate ){
3341 int syncFlags = SYNC_PUSH | SYNC_PULL | SYNC_IFABLE;
3342 autosync_loop(syncFlags, 0, "commit");
3343 }
3344 if( count_nonbranch_children(vid)>1 ){
3345
--- src/checkin.c
+++ src/checkin.c
@@ -2556,22 +2556,19 @@
2556 int allowEmpty = 0; /* Allow a commit with no changes */
2557 int onlyIfChanges = 0; /* No-op if there are no changes */
2558 int allowFork = 0; /* Allow the commit to fork */
2559 int allowOlder = 0; /* Allow a commit older than its ancestor */
2560 int noVerifyCom = 0; /* Allow suspicious check-in comments */
 
2561 int useCksum; /* True if checksums should be computed and verified */
 
2562 int dryRunFlag; /* True for a test run. Debugging only */
2563 CheckinInfo sCiInfo; /* Information about this check-in */
2564 const char *zComFile; /* Read commit message from this file */
2565 int nTag = 0; /* Number of --tag arguments */
2566 const char *zTag; /* A single --tag argument */
2567 ManifestFile *pFile; /* File structure in the manifest */
2568 Manifest *pManifest; /* Manifest structure */
2569 Blob manifest; /* Manifest in baseline form */
 
2570 Blob cksum1, cksum2; /* Before and after commit checksums */
2571 Blob cksum1b; /* Checksum recorded in the manifest */
2572 int szD; /* Size of the delta manifest */
2573 int szB; /* Size of the baseline manifest */
2574 int nConflict = 0; /* Number of unresolved merge conflicts */
@@ -2647,11 +2644,10 @@
2644 sCiInfo.zUserOvrd = find_option("user-override",0,1);
2645 noSign = db_get_boolean("omitsign", 0)|noSign;
2646 if( db_get_boolean("clearsign", 0)==0 ){ noSign = 1; }
2647 useCksum = db_get_boolean("repo-cksum", 1);
2648 bIgnoreSkew = find_option("ignore-clock-skew",0,0)!=0;
 
2649 mxSize = db_large_file_size();
2650 if( find_option("ignore-oversize",0,0)!=0 ) mxSize = 0;
2651 (void)fossil_text_editor();
2652 verify_all_options();
2653
@@ -3209,17 +3205,10 @@
3205 ** and rollback the transaction.
3206 */
3207 if( dryRunFlag ){
3208 blob_write_to_file(&manifest, "");
3209 }
 
 
 
 
 
 
 
3210
3211 nvid = content_put(&manifest);
3212 if( nvid==0 ){
3213 fossil_fatal("trouble committing manifest: %s", g.zErrMsg);
3214 }
@@ -3242,18 +3231,10 @@
3231 }
3232 }
3233 db_finalize(&q);
3234
3235 fossil_print("New_Version: %s\n", zUuid);
 
 
 
 
 
 
 
 
3236
3237 /* Update the vfile and vmerge tables */
3238 db_multi_exec(
3239 "DELETE FROM vfile WHERE (vid!=%d OR deleted) AND is_selected(id);"
3240 "DELETE FROM vmerge;"
@@ -3260,11 +3241,11 @@
3241 "UPDATE vfile SET vid=%d;"
3242 "UPDATE vfile SET rid=mrid, mhash=NULL, chnged=0, deleted=0, origname=NULL"
3243 " WHERE is_selected(id);"
3244 , vid, nvid
3245 );
3246 db_set_checkout(nvid, !dryRunFlag);
3247
3248 /* Update the isexe and islink columns of the vfile table */
3249 db_prepare(&q,
3250 "UPDATE vfile SET isexe=:exec, islink=:link"
3251 " WHERE vid=:vid AND pathname=:path AND (isexe!=:exec OR islink!=:link)"
@@ -3325,20 +3306,10 @@
3306 db_end_transaction(1);
3307 return;
3308 }
3309 db_end_transaction(0);
3310
 
 
 
 
 
 
 
 
 
 
3311 if( !g.markPrivate ){
3312 int syncFlags = SYNC_PUSH | SYNC_PULL | SYNC_IFABLE;
3313 autosync_loop(syncFlags, 0, "commit");
3314 }
3315 if( count_nonbranch_children(vid)>1 ){
3316
+1 -2
--- src/checkout.c
+++ src/checkout.c
@@ -358,13 +358,12 @@
358358
db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
359359
if( !keepFlag ){
360360
vfile_to_disk(vid, 0, !g.fQuiet, promptFlag);
361361
}
362362
checkout_set_all_exe(vid);
363
- manifest_to_disk(vid);
364363
ensure_empty_dirs_created(0);
365
- db_set_checkout(vid);
364
+ db_set_checkout(vid, 1);
366365
undo_reset();
367366
db_multi_exec("DELETE FROM vmerge");
368367
if( !keepFlag && db_get_boolean("repo-cksum",1) ){
369368
vfile_aggregate_checksum_manifest(vid, &cksum1, &cksum1b);
370369
vfile_aggregate_checksum_disk(vid, &cksum2);
371370
--- src/checkout.c
+++ src/checkout.c
@@ -358,13 +358,12 @@
358 db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
359 if( !keepFlag ){
360 vfile_to_disk(vid, 0, !g.fQuiet, promptFlag);
361 }
362 checkout_set_all_exe(vid);
363 manifest_to_disk(vid);
364 ensure_empty_dirs_created(0);
365 db_set_checkout(vid);
366 undo_reset();
367 db_multi_exec("DELETE FROM vmerge");
368 if( !keepFlag && db_get_boolean("repo-cksum",1) ){
369 vfile_aggregate_checksum_manifest(vid, &cksum1, &cksum1b);
370 vfile_aggregate_checksum_disk(vid, &cksum2);
371
--- src/checkout.c
+++ src/checkout.c
@@ -358,13 +358,12 @@
358 db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
359 if( !keepFlag ){
360 vfile_to_disk(vid, 0, !g.fQuiet, promptFlag);
361 }
362 checkout_set_all_exe(vid);
 
363 ensure_empty_dirs_created(0);
364 db_set_checkout(vid, 1);
365 undo_reset();
366 db_multi_exec("DELETE FROM vmerge");
367 if( !keepFlag && db_get_boolean("repo-cksum",1) ){
368 vfile_aggregate_checksum_manifest(vid, &cksum1, &cksum1b);
369 vfile_aggregate_checksum_disk(vid, &cksum2);
370
+5 -2
--- src/db.c
+++ src/db.c
@@ -4425,11 +4425,11 @@
44254425
(char*)0);
44264426
db_delete_on_failure(LOCALDB_NAME);
44274427
db_open_local(0);
44284428
db_lset("repository", zRepo);
44294429
db_record_repository_filename(zRepo);
4430
- db_set_checkout(0);
4430
+ db_set_checkout(0, 0); /* manifest files handled by checkout_cmd */
44314431
azNewArgv[0] = g.argv[0];
44324432
g.argv = azNewArgv;
44334433
if( !emptyFlag ){
44344434
g.argc = 3;
44354435
if( g.zOpenRevision ){
@@ -5666,15 +5666,18 @@
56665666
RELEASE_VERSION, MANIFEST_DATE, MANIFEST_UUID);
56675667
}
56685668
56695669
/*
56705670
** Set the value of the "checkout" entry in the VVAR table.
5671
+** If bWriteManifest is non-zero then also attempt to write the manifest
5672
+** files to disk.
56715673
**
56725674
** Also set "fingerprint" and "checkout-hash".
56735675
*/
5674
-void db_set_checkout(int rid){
5676
+void db_set_checkout(int rid, int bWriteManifest){
56755677
char *z;
5678
+ if( bWriteManifest ) manifest_to_disk(rid);
56765679
db_lset_int("checkout", rid);
56775680
if (rid != 0) {
56785681
z = db_text(0,"SELECT uuid FROM blob WHERE rid=%d",rid);
56795682
db_lset("checkout-hash", z);
56805683
fossil_free(z);
56815684
--- src/db.c
+++ src/db.c
@@ -4425,11 +4425,11 @@
4425 (char*)0);
4426 db_delete_on_failure(LOCALDB_NAME);
4427 db_open_local(0);
4428 db_lset("repository", zRepo);
4429 db_record_repository_filename(zRepo);
4430 db_set_checkout(0);
4431 azNewArgv[0] = g.argv[0];
4432 g.argv = azNewArgv;
4433 if( !emptyFlag ){
4434 g.argc = 3;
4435 if( g.zOpenRevision ){
@@ -5666,15 +5666,18 @@
5666 RELEASE_VERSION, MANIFEST_DATE, MANIFEST_UUID);
5667 }
5668
5669 /*
5670 ** Set the value of the "checkout" entry in the VVAR table.
 
 
5671 **
5672 ** Also set "fingerprint" and "checkout-hash".
5673 */
5674 void db_set_checkout(int rid){
5675 char *z;
 
5676 db_lset_int("checkout", rid);
5677 if (rid != 0) {
5678 z = db_text(0,"SELECT uuid FROM blob WHERE rid=%d",rid);
5679 db_lset("checkout-hash", z);
5680 fossil_free(z);
5681
--- src/db.c
+++ src/db.c
@@ -4425,11 +4425,11 @@
4425 (char*)0);
4426 db_delete_on_failure(LOCALDB_NAME);
4427 db_open_local(0);
4428 db_lset("repository", zRepo);
4429 db_record_repository_filename(zRepo);
4430 db_set_checkout(0, 0); /* manifest files handled by checkout_cmd */
4431 azNewArgv[0] = g.argv[0];
4432 g.argv = azNewArgv;
4433 if( !emptyFlag ){
4434 g.argc = 3;
4435 if( g.zOpenRevision ){
@@ -5666,15 +5666,18 @@
5666 RELEASE_VERSION, MANIFEST_DATE, MANIFEST_UUID);
5667 }
5668
5669 /*
5670 ** Set the value of the "checkout" entry in the VVAR table.
5671 ** If bWriteManifest is non-zero then also attempt to write the manifest
5672 ** files to disk.
5673 **
5674 ** Also set "fingerprint" and "checkout-hash".
5675 */
5676 void db_set_checkout(int rid, int bWriteManifest){
5677 char *z;
5678 if( bWriteManifest ) manifest_to_disk(rid);
5679 db_lset_int("checkout", rid);
5680 if (rid != 0) {
5681 z = db_text(0,"SELECT uuid FROM blob WHERE rid=%d",rid);
5682 db_lset("checkout-hash", z);
5683 fossil_free(z);
5684
+1 -1
--- src/undo.c
+++ src/undo.c
@@ -166,11 +166,11 @@
166166
}
167167
}
168168
ncid = db_lget_int("undo_checkout", 0);
169169
ucid = db_lget_int("checkout", 0);
170170
db_lset_int("undo_checkout", ucid);
171
- db_set_checkout(ncid);
171
+ db_set_checkout(ncid, 1);
172172
}
173173
174174
/*
175175
** Reset the undo memory.
176176
*/
177177
--- src/undo.c
+++ src/undo.c
@@ -166,11 +166,11 @@
166 }
167 }
168 ncid = db_lget_int("undo_checkout", 0);
169 ucid = db_lget_int("checkout", 0);
170 db_lset_int("undo_checkout", ucid);
171 db_set_checkout(ncid);
172 }
173
174 /*
175 ** Reset the undo memory.
176 */
177
--- src/undo.c
+++ src/undo.c
@@ -166,11 +166,11 @@
166 }
167 }
168 ncid = db_lget_int("undo_checkout", 0);
169 ucid = db_lget_int("checkout", 0);
170 db_lset_int("undo_checkout", ucid);
171 db_set_checkout(ncid, 1);
172 }
173
174 /*
175 ** Reset the undo memory.
176 */
177
+1 -2
--- src/update.c
+++ src/update.c
@@ -687,12 +687,11 @@
687687
fossil_free(zPwd);
688688
if( g.argc<=3 ){
689689
/* All files updated. Shift the current check-out to the target. */
690690
db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
691691
checkout_set_all_exe(tid);
692
- manifest_to_disk(tid);
693
- db_set_checkout(tid);
692
+ db_set_checkout(tid, 1);
694693
}else{
695694
/* A subset of files have been checked out. Keep the current
696695
** check-out unchanged. */
697696
db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
698697
}
699698
--- src/update.c
+++ src/update.c
@@ -687,12 +687,11 @@
687 fossil_free(zPwd);
688 if( g.argc<=3 ){
689 /* All files updated. Shift the current check-out to the target. */
690 db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
691 checkout_set_all_exe(tid);
692 manifest_to_disk(tid);
693 db_set_checkout(tid);
694 }else{
695 /* A subset of files have been checked out. Keep the current
696 ** check-out unchanged. */
697 db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
698 }
699
--- src/update.c
+++ src/update.c
@@ -687,12 +687,11 @@
687 fossil_free(zPwd);
688 if( g.argc<=3 ){
689 /* All files updated. Shift the current check-out to the target. */
690 db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
691 checkout_set_all_exe(tid);
692 db_set_checkout(tid, 1);
 
693 }else{
694 /* A subset of files have been checked out. Keep the current
695 ** check-out unchanged. */
696 db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
697 }
698

Keyboard Shortcuts

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