Fossil SCM
Fix "fossil revert" so that it works on files that have been renamed.
Commit
48798b27194107cec0bb4df97e79e560c882a9c6
Parent
9ae863a5eb004f9…
1 file changed
+10
-5
+10
-5
| --- src/update.c | ||
| +++ src/update.c | ||
| @@ -715,14 +715,18 @@ | ||
| 715 | 715 | int vid; |
| 716 | 716 | vid = db_lget_int("checkout", 0); |
| 717 | 717 | vfile_check_signature(vid, 0); |
| 718 | 718 | db_multi_exec( |
| 719 | 719 | "DELETE FROM vmerge;" |
| 720 | - "INSERT INTO torevert " | |
| 721 | - "SELECT pathname" | |
| 722 | - " FROM vfile " | |
| 723 | - " WHERE chnged OR deleted OR rid=0 OR pathname!=origname;" | |
| 720 | + "INSERT OR IGNORE INTO torevert " | |
| 721 | + " SELECT pathname" | |
| 722 | + " FROM vfile " | |
| 723 | + " WHERE chnged OR deleted OR rid=0 OR pathname!=origname " | |
| 724 | + " UNION ALL " | |
| 725 | + " SELECT origname" | |
| 726 | + " FROM vfile" | |
| 727 | + " WHERE origname!=pathname;" | |
| 724 | 728 | ); |
| 725 | 729 | } |
| 726 | 730 | blob_zero(&record); |
| 727 | 731 | db_prepare(&q, "SELECT name FROM torevert"); |
| 728 | 732 | if( zRevision==0 ){ |
| @@ -736,11 +740,12 @@ | ||
| 736 | 740 | zFile = db_column_text(&q, 0); |
| 737 | 741 | zFull = mprintf("%/%/", g.zLocalRoot, zFile); |
| 738 | 742 | errCode = historical_version_of_file(zRevision, zFile, &record, |
| 739 | 743 | &isLink, &isExe, 0, 2); |
| 740 | 744 | if( errCode==2 ){ |
| 741 | - if( db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q", zFile)==0 ){ | |
| 745 | + if( db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q OR origname=%Q", | |
| 746 | + zFile, zFile)==0 ){ | |
| 742 | 747 | fossil_print("UNMANAGE: %s\n", zFile); |
| 743 | 748 | }else{ |
| 744 | 749 | undo_save(zFile); |
| 745 | 750 | file_delete(zFull); |
| 746 | 751 | fossil_print("DELETE: %s\n", zFile); |
| 747 | 752 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -715,14 +715,18 @@ | |
| 715 | int vid; |
| 716 | vid = db_lget_int("checkout", 0); |
| 717 | vfile_check_signature(vid, 0); |
| 718 | db_multi_exec( |
| 719 | "DELETE FROM vmerge;" |
| 720 | "INSERT INTO torevert " |
| 721 | "SELECT pathname" |
| 722 | " FROM vfile " |
| 723 | " WHERE chnged OR deleted OR rid=0 OR pathname!=origname;" |
| 724 | ); |
| 725 | } |
| 726 | blob_zero(&record); |
| 727 | db_prepare(&q, "SELECT name FROM torevert"); |
| 728 | if( zRevision==0 ){ |
| @@ -736,11 +740,12 @@ | |
| 736 | zFile = db_column_text(&q, 0); |
| 737 | zFull = mprintf("%/%/", g.zLocalRoot, zFile); |
| 738 | errCode = historical_version_of_file(zRevision, zFile, &record, |
| 739 | &isLink, &isExe, 0, 2); |
| 740 | if( errCode==2 ){ |
| 741 | if( db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q", zFile)==0 ){ |
| 742 | fossil_print("UNMANAGE: %s\n", zFile); |
| 743 | }else{ |
| 744 | undo_save(zFile); |
| 745 | file_delete(zFull); |
| 746 | fossil_print("DELETE: %s\n", zFile); |
| 747 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -715,14 +715,18 @@ | |
| 715 | int vid; |
| 716 | vid = db_lget_int("checkout", 0); |
| 717 | vfile_check_signature(vid, 0); |
| 718 | db_multi_exec( |
| 719 | "DELETE FROM vmerge;" |
| 720 | "INSERT OR IGNORE INTO torevert " |
| 721 | " SELECT pathname" |
| 722 | " FROM vfile " |
| 723 | " WHERE chnged OR deleted OR rid=0 OR pathname!=origname " |
| 724 | " UNION ALL " |
| 725 | " SELECT origname" |
| 726 | " FROM vfile" |
| 727 | " WHERE origname!=pathname;" |
| 728 | ); |
| 729 | } |
| 730 | blob_zero(&record); |
| 731 | db_prepare(&q, "SELECT name FROM torevert"); |
| 732 | if( zRevision==0 ){ |
| @@ -736,11 +740,12 @@ | |
| 740 | zFile = db_column_text(&q, 0); |
| 741 | zFull = mprintf("%/%/", g.zLocalRoot, zFile); |
| 742 | errCode = historical_version_of_file(zRevision, zFile, &record, |
| 743 | &isLink, &isExe, 0, 2); |
| 744 | if( errCode==2 ){ |
| 745 | if( db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q OR origname=%Q", |
| 746 | zFile, zFile)==0 ){ |
| 747 | fossil_print("UNMANAGE: %s\n", zFile); |
| 748 | }else{ |
| 749 | undo_save(zFile); |
| 750 | file_delete(zFull); |
| 751 | fossil_print("DELETE: %s\n", zFile); |
| 752 |