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.
Commit
79552047323135a999aea75081253d18db77964ccab5b076457daee56fb16a46
Parent
8d9ab429e6a0815…
1 file changed
+12
-1
+12
-1
| --- src/purge.c | ||
| +++ src/purge.c | ||
| @@ -604,18 +604,29 @@ | ||
| 604 | 604 | int vid; |
| 605 | 605 | if( find_option("explain",0,0)!=0 || find_option("dry-run",0,0)!=0 ){ |
| 606 | 606 | purgeFlags |= PURGE_EXPLAIN_ONLY; |
| 607 | 607 | } |
| 608 | 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 | + } | |
| 609 | 621 | db_begin_transaction(); |
| 610 | 622 | if( g.argc<=3 ) usage("checkins TAGS... [OPTIONS]"); |
| 611 | 623 | db_multi_exec("CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY)"); |
| 612 | 624 | for(i=3; i<g.argc; i++){ |
| 613 | 625 | int r = name_to_typed_rid(g.argv[i], "br"); |
| 614 | 626 | compute_descendants(r, 1000000000); |
| 615 | 627 | } |
| 616 | - vid = g.localOpen ? db_lget_int("checkout",0) : 0; | |
| 617 | 628 | if( db_exists("SELECT 1 FROM ok WHERE rid=%d",vid) ){ |
| 618 | 629 | fossil_fatal("cannot purge the current check-out"); |
| 619 | 630 | } |
| 620 | 631 | find_checkin_associates("ok", 1); |
| 621 | 632 | purge_artifact_list("ok", "", purgeFlags); |
| 622 | 633 |
| --- 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 |