Fossil SCM

Make "fossil purge checkins" with -R still refuse to purge the current check-out when it is run inside a check-out of that same repository.

dmestas 2026-11-17 13:40 UTC small-fixes-2
Commit 79552047323135a999aea75081253d18db77964ccab5b076457daee56fb16a46
1 file changed +12 -1
+12 -1
--- src/purge.c
+++ src/purge.c
@@ -604,18 +604,29 @@
604604
int vid;
605605
if( find_option("explain",0,0)!=0 || find_option("dry-run",0,0)!=0 ){
606606
purgeFlags |= PURGE_EXPLAIN_ONLY;
607607
}
608608
verify_all_options();
609
+ /* Find the current check-out, if there is one in this directory for
610
+ ** this repository, even when the repository was named with -R. */
611
+ vid = 0;
612
+ if( g.localOpen ){
613
+ vid = db_lget_int("checkout",0);
614
+ }else if( db_open_local(0) ){
615
+ char *zRepo = file_canonical_name_dup(g.zRepositoryName);
616
+ if( fossil_strcmp(zRepo, db_repository_filename())==0 ){
617
+ vid = db_lget_int("checkout",0);
618
+ }
619
+ fossil_free(zRepo);
620
+ }
609621
db_begin_transaction();
610622
if( g.argc<=3 ) usage("checkins TAGS... [OPTIONS]");
611623
db_multi_exec("CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY)");
612624
for(i=3; i<g.argc; i++){
613625
int r = name_to_typed_rid(g.argv[i], "br");
614626
compute_descendants(r, 1000000000);
615627
}
616
- vid = g.localOpen ? db_lget_int("checkout",0) : 0;
617628
if( db_exists("SELECT 1 FROM ok WHERE rid=%d",vid) ){
618629
fossil_fatal("cannot purge the current check-out");
619630
}
620631
find_checkin_associates("ok", 1);
621632
purge_artifact_list("ok", "", purgeFlags);
622633
--- src/purge.c
+++ src/purge.c
@@ -604,18 +604,29 @@
604 int vid;
605 if( find_option("explain",0,0)!=0 || find_option("dry-run",0,0)!=0 ){
606 purgeFlags |= PURGE_EXPLAIN_ONLY;
607 }
608 verify_all_options();
 
 
 
 
 
 
 
 
 
 
 
 
609 db_begin_transaction();
610 if( g.argc<=3 ) usage("checkins TAGS... [OPTIONS]");
611 db_multi_exec("CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY)");
612 for(i=3; i<g.argc; i++){
613 int r = name_to_typed_rid(g.argv[i], "br");
614 compute_descendants(r, 1000000000);
615 }
616 vid = g.localOpen ? db_lget_int("checkout",0) : 0;
617 if( db_exists("SELECT 1 FROM ok WHERE rid=%d",vid) ){
618 fossil_fatal("cannot purge the current check-out");
619 }
620 find_checkin_associates("ok", 1);
621 purge_artifact_list("ok", "", purgeFlags);
622
--- src/purge.c
+++ src/purge.c
@@ -604,18 +604,29 @@
604 int vid;
605 if( find_option("explain",0,0)!=0 || find_option("dry-run",0,0)!=0 ){
606 purgeFlags |= PURGE_EXPLAIN_ONLY;
607 }
608 verify_all_options();
609 /* Find the current check-out, if there is one in this directory for
610 ** this repository, even when the repository was named with -R. */
611 vid = 0;
612 if( g.localOpen ){
613 vid = db_lget_int("checkout",0);
614 }else if( db_open_local(0) ){
615 char *zRepo = file_canonical_name_dup(g.zRepositoryName);
616 if( fossil_strcmp(zRepo, db_repository_filename())==0 ){
617 vid = db_lget_int("checkout",0);
618 }
619 fossil_free(zRepo);
620 }
621 db_begin_transaction();
622 if( g.argc<=3 ) usage("checkins TAGS... [OPTIONS]");
623 db_multi_exec("CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY)");
624 for(i=3; i<g.argc; i++){
625 int r = name_to_typed_rid(g.argv[i], "br");
626 compute_descendants(r, 1000000000);
627 }
 
628 if( db_exists("SELECT 1 FROM ok WHERE rid=%d",vid) ){
629 fossil_fatal("cannot purge the current check-out");
630 }
631 find_checkin_associates("ok", 1);
632 purge_artifact_list("ok", "", purgeFlags);
633

Keyboard Shortcuts

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