Fossil SCM
revert: Allow reverting of current changes for the whole directory tree.
Commit
a8bb08697a8717789d32e982e5f7ae307b75649499160e825ef82a53824168a8
Parent
363efffe9e27da5…
2 files changed
+64
-14
+164
+64
-14
| --- src/update.c | ||
| +++ src/update.c | ||
| @@ -765,28 +765,31 @@ | ||
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | /* |
| 768 | 768 | ** COMMAND: revert |
| 769 | 769 | ** |
| 770 | -** Usage: %fossil revert ?-r REVISION? ?FILE ...? | |
| 770 | +** Usage: %fossil revert ?OPTIONS? ?FILE ...? | |
| 771 | 771 | ** |
| 772 | 772 | ** Revert to the current repository version of FILE, or to |
| 773 | -** the version associated with baseline REVISION if the -r flag | |
| 774 | -** appears. | |
| 773 | +** the baseline VERSION specified with -r flag. | |
| 775 | 774 | ** |
| 776 | 775 | ** If FILE was part of a rename operation, both the original file |
| 777 | 776 | ** and the renamed file are reverted. |
| 777 | +** | |
| 778 | +** Using a directory name for any of the FILE arguments is the same | |
| 779 | +** as using every subdirectory and file beneath that directory. | |
| 778 | 780 | ** |
| 779 | 781 | ** Revert all files if no file name is provided. |
| 780 | 782 | ** |
| 781 | 783 | ** If a file is reverted accidentally, it can be restored using |
| 782 | 784 | ** the "fossil undo" command. |
| 783 | 785 | ** |
| 784 | 786 | ** Options: |
| 785 | -** -r REVISION revert given FILE(s) back to given REVISION | |
| 787 | +** -r|--revision VERSION Revert given FILE(s) back to given | |
| 788 | +** VERSION | |
| 786 | 789 | ** |
| 787 | -** See also: redo, undo, update | |
| 790 | +** See also: redo, undo, checkout, update | |
| 788 | 791 | */ |
| 789 | 792 | void revert_cmd(void){ |
| 790 | 793 | Manifest *pCoManifest; /* Manifest of current checkout */ |
| 791 | 794 | Manifest *pRvManifest; /* Manifest of selected revert version */ |
| 792 | 795 | ManifestFile *pCoFile; /* File within current checkout manifest */ |
| @@ -794,20 +797,23 @@ | ||
| 794 | 797 | const char *zFile; /* Filename relative to checkout root */ |
| 795 | 798 | const char *zRevision; /* Selected revert version, NULL if current */ |
| 796 | 799 | Blob record = BLOB_INITIALIZER; /* Contents of each reverted file */ |
| 797 | 800 | int i; |
| 798 | 801 | Stmt q; |
| 802 | + int revertAll = 0; | |
| 803 | + int revisionOptNotSupported = 0; | |
| 799 | 804 | |
| 800 | 805 | undo_capture_command_line(); |
| 801 | 806 | zRevision = find_option("revision", "r", 1); |
| 802 | 807 | verify_all_options(); |
| 803 | 808 | |
| 804 | 809 | if( g.argc<2 ){ |
| 805 | 810 | usage("?OPTIONS? [FILE] ..."); |
| 806 | 811 | } |
| 807 | 812 | if( zRevision && g.argc<3 ){ |
| 808 | - fossil_fatal("the --revision option does not work for the entire tree"); | |
| 813 | + fossil_fatal("directories or the entire tree can only be reverted" | |
| 814 | + " back to current version"); | |
| 809 | 815 | } |
| 810 | 816 | db_must_be_within_tree(); |
| 811 | 817 | |
| 812 | 818 | /* Get manifests of revert version and (if different) current checkout. */ |
| 813 | 819 | pRvManifest = historical_manifest(zRevision); |
| @@ -821,21 +827,64 @@ | ||
| 821 | 827 | for(i=2; i<g.argc; i++){ |
| 822 | 828 | Blob fname; |
| 823 | 829 | zFile = mprintf("%/", g.argv[i]); |
| 824 | 830 | blob_zero(&fname); |
| 825 | 831 | file_tree_name(zFile, &fname, 0, 1); |
| 826 | - db_multi_exec( | |
| 827 | - "REPLACE INTO torevert VALUES(%B);" | |
| 828 | - "INSERT OR IGNORE INTO torevert" | |
| 829 | - " SELECT pathname" | |
| 830 | - " FROM vfile" | |
| 831 | - " WHERE origname=%B;", | |
| 832 | - &fname, &fname | |
| 833 | - ); | |
| 832 | + if( blob_eq(&fname, ".") ){ | |
| 833 | + if( zRevision ){ | |
| 834 | + revisionOptNotSupported = 1; | |
| 835 | + break; | |
| 836 | + } | |
| 837 | + revertAll = 1; | |
| 838 | + break; | |
| 839 | + }else if( db_exists( | |
| 840 | + "SELECT pathname" | |
| 841 | + " FROM vfile" | |
| 842 | + " WHERE (substr(pathname,1,length('%q/'))='%q/'" | |
| 843 | + " OR substr(origname,1,length('%q/'))='%q/');", | |
| 844 | + blob_str(&fname), blob_str(&fname), | |
| 845 | + blob_str(&fname), blob_str(&fname)) ){ | |
| 846 | + int vid; | |
| 847 | + vid = db_lget_int("checkout", 0); | |
| 848 | + vfile_check_signature(vid, 0); | |
| 849 | + | |
| 850 | + if( zRevision ){ | |
| 851 | + revisionOptNotSupported = 1; | |
| 852 | + break; | |
| 853 | + } | |
| 854 | + db_multi_exec( | |
| 855 | + "INSERT OR IGNORE INTO torevert" | |
| 856 | + " SELECT pathname" | |
| 857 | + " FROM vfile" | |
| 858 | + " WHERE (substr(pathname,1,length('%q/'))='%q/'" | |
| 859 | + " OR substr(origname,1,length('%q/'))='%q/')" | |
| 860 | + " AND (chnged OR deleted OR rid=0 OR pathname!=origname);", | |
| 861 | + blob_str(&fname), blob_str(&fname), | |
| 862 | + blob_str(&fname), blob_str(&fname) | |
| 863 | + ); | |
| 864 | + }else{ | |
| 865 | + db_multi_exec( | |
| 866 | + "REPLACE INTO torevert VALUES(%B);" | |
| 867 | + "INSERT OR IGNORE INTO torevert" | |
| 868 | + " SELECT pathname" | |
| 869 | + " FROM vfile" | |
| 870 | + " WHERE origname=%B;", | |
| 871 | + &fname, &fname | |
| 872 | + ); | |
| 873 | + } | |
| 834 | 874 | blob_reset(&fname); |
| 835 | 875 | } |
| 836 | 876 | }else{ |
| 877 | + revertAll = 1; | |
| 878 | + } | |
| 879 | + | |
| 880 | + if( revisionOptNotSupported ){ | |
| 881 | + fossil_fatal("directories or the entire tree can only be reverted" | |
| 882 | + " back to current version"); | |
| 883 | + } | |
| 884 | + | |
| 885 | + if ( revertAll ){ | |
| 837 | 886 | int vid; |
| 838 | 887 | vid = db_lget_int("checkout", 0); |
| 839 | 888 | vfile_check_signature(vid, 0); |
| 840 | 889 | db_multi_exec( |
| 841 | 890 | "DELETE FROM vmerge;" |
| @@ -843,10 +892,11 @@ | ||
| 843 | 892 | " SELECT pathname" |
| 844 | 893 | " FROM vfile " |
| 845 | 894 | " WHERE chnged OR deleted OR rid=0 OR pathname!=origname;" |
| 846 | 895 | ); |
| 847 | 896 | } |
| 897 | + | |
| 848 | 898 | db_multi_exec( |
| 849 | 899 | "INSERT OR IGNORE INTO torevert" |
| 850 | 900 | " SELECT origname" |
| 851 | 901 | " FROM vfile" |
| 852 | 902 | " WHERE origname!=pathname AND pathname IN (SELECT name FROM torevert);" |
| 853 | 903 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -765,28 +765,31 @@ | |
| 765 | } |
| 766 | |
| 767 | /* |
| 768 | ** COMMAND: revert |
| 769 | ** |
| 770 | ** Usage: %fossil revert ?-r REVISION? ?FILE ...? |
| 771 | ** |
| 772 | ** Revert to the current repository version of FILE, or to |
| 773 | ** the version associated with baseline REVISION if the -r flag |
| 774 | ** appears. |
| 775 | ** |
| 776 | ** If FILE was part of a rename operation, both the original file |
| 777 | ** and the renamed file are reverted. |
| 778 | ** |
| 779 | ** Revert all files if no file name is provided. |
| 780 | ** |
| 781 | ** If a file is reverted accidentally, it can be restored using |
| 782 | ** the "fossil undo" command. |
| 783 | ** |
| 784 | ** Options: |
| 785 | ** -r REVISION revert given FILE(s) back to given REVISION |
| 786 | ** |
| 787 | ** See also: redo, undo, update |
| 788 | */ |
| 789 | void revert_cmd(void){ |
| 790 | Manifest *pCoManifest; /* Manifest of current checkout */ |
| 791 | Manifest *pRvManifest; /* Manifest of selected revert version */ |
| 792 | ManifestFile *pCoFile; /* File within current checkout manifest */ |
| @@ -794,20 +797,23 @@ | |
| 794 | const char *zFile; /* Filename relative to checkout root */ |
| 795 | const char *zRevision; /* Selected revert version, NULL if current */ |
| 796 | Blob record = BLOB_INITIALIZER; /* Contents of each reverted file */ |
| 797 | int i; |
| 798 | Stmt q; |
| 799 | |
| 800 | undo_capture_command_line(); |
| 801 | zRevision = find_option("revision", "r", 1); |
| 802 | verify_all_options(); |
| 803 | |
| 804 | if( g.argc<2 ){ |
| 805 | usage("?OPTIONS? [FILE] ..."); |
| 806 | } |
| 807 | if( zRevision && g.argc<3 ){ |
| 808 | fossil_fatal("the --revision option does not work for the entire tree"); |
| 809 | } |
| 810 | db_must_be_within_tree(); |
| 811 | |
| 812 | /* Get manifests of revert version and (if different) current checkout. */ |
| 813 | pRvManifest = historical_manifest(zRevision); |
| @@ -821,21 +827,64 @@ | |
| 821 | for(i=2; i<g.argc; i++){ |
| 822 | Blob fname; |
| 823 | zFile = mprintf("%/", g.argv[i]); |
| 824 | blob_zero(&fname); |
| 825 | file_tree_name(zFile, &fname, 0, 1); |
| 826 | db_multi_exec( |
| 827 | "REPLACE INTO torevert VALUES(%B);" |
| 828 | "INSERT OR IGNORE INTO torevert" |
| 829 | " SELECT pathname" |
| 830 | " FROM vfile" |
| 831 | " WHERE origname=%B;", |
| 832 | &fname, &fname |
| 833 | ); |
| 834 | blob_reset(&fname); |
| 835 | } |
| 836 | }else{ |
| 837 | int vid; |
| 838 | vid = db_lget_int("checkout", 0); |
| 839 | vfile_check_signature(vid, 0); |
| 840 | db_multi_exec( |
| 841 | "DELETE FROM vmerge;" |
| @@ -843,10 +892,11 @@ | |
| 843 | " SELECT pathname" |
| 844 | " FROM vfile " |
| 845 | " WHERE chnged OR deleted OR rid=0 OR pathname!=origname;" |
| 846 | ); |
| 847 | } |
| 848 | db_multi_exec( |
| 849 | "INSERT OR IGNORE INTO torevert" |
| 850 | " SELECT origname" |
| 851 | " FROM vfile" |
| 852 | " WHERE origname!=pathname AND pathname IN (SELECT name FROM torevert);" |
| 853 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -765,28 +765,31 @@ | |
| 765 | } |
| 766 | |
| 767 | /* |
| 768 | ** COMMAND: revert |
| 769 | ** |
| 770 | ** Usage: %fossil revert ?OPTIONS? ?FILE ...? |
| 771 | ** |
| 772 | ** Revert to the current repository version of FILE, or to |
| 773 | ** the baseline VERSION specified with -r flag. |
| 774 | ** |
| 775 | ** If FILE was part of a rename operation, both the original file |
| 776 | ** and the renamed file are reverted. |
| 777 | ** |
| 778 | ** Using a directory name for any of the FILE arguments is the same |
| 779 | ** as using every subdirectory and file beneath that directory. |
| 780 | ** |
| 781 | ** Revert all files if no file name is provided. |
| 782 | ** |
| 783 | ** If a file is reverted accidentally, it can be restored using |
| 784 | ** the "fossil undo" command. |
| 785 | ** |
| 786 | ** Options: |
| 787 | ** -r|--revision VERSION Revert given FILE(s) back to given |
| 788 | ** VERSION |
| 789 | ** |
| 790 | ** See also: redo, undo, checkout, update |
| 791 | */ |
| 792 | void revert_cmd(void){ |
| 793 | Manifest *pCoManifest; /* Manifest of current checkout */ |
| 794 | Manifest *pRvManifest; /* Manifest of selected revert version */ |
| 795 | ManifestFile *pCoFile; /* File within current checkout manifest */ |
| @@ -794,20 +797,23 @@ | |
| 797 | const char *zFile; /* Filename relative to checkout root */ |
| 798 | const char *zRevision; /* Selected revert version, NULL if current */ |
| 799 | Blob record = BLOB_INITIALIZER; /* Contents of each reverted file */ |
| 800 | int i; |
| 801 | Stmt q; |
| 802 | int revertAll = 0; |
| 803 | int revisionOptNotSupported = 0; |
| 804 | |
| 805 | undo_capture_command_line(); |
| 806 | zRevision = find_option("revision", "r", 1); |
| 807 | verify_all_options(); |
| 808 | |
| 809 | if( g.argc<2 ){ |
| 810 | usage("?OPTIONS? [FILE] ..."); |
| 811 | } |
| 812 | if( zRevision && g.argc<3 ){ |
| 813 | fossil_fatal("directories or the entire tree can only be reverted" |
| 814 | " back to current version"); |
| 815 | } |
| 816 | db_must_be_within_tree(); |
| 817 | |
| 818 | /* Get manifests of revert version and (if different) current checkout. */ |
| 819 | pRvManifest = historical_manifest(zRevision); |
| @@ -821,21 +827,64 @@ | |
| 827 | for(i=2; i<g.argc; i++){ |
| 828 | Blob fname; |
| 829 | zFile = mprintf("%/", g.argv[i]); |
| 830 | blob_zero(&fname); |
| 831 | file_tree_name(zFile, &fname, 0, 1); |
| 832 | if( blob_eq(&fname, ".") ){ |
| 833 | if( zRevision ){ |
| 834 | revisionOptNotSupported = 1; |
| 835 | break; |
| 836 | } |
| 837 | revertAll = 1; |
| 838 | break; |
| 839 | }else if( db_exists( |
| 840 | "SELECT pathname" |
| 841 | " FROM vfile" |
| 842 | " WHERE (substr(pathname,1,length('%q/'))='%q/'" |
| 843 | " OR substr(origname,1,length('%q/'))='%q/');", |
| 844 | blob_str(&fname), blob_str(&fname), |
| 845 | blob_str(&fname), blob_str(&fname)) ){ |
| 846 | int vid; |
| 847 | vid = db_lget_int("checkout", 0); |
| 848 | vfile_check_signature(vid, 0); |
| 849 | |
| 850 | if( zRevision ){ |
| 851 | revisionOptNotSupported = 1; |
| 852 | break; |
| 853 | } |
| 854 | db_multi_exec( |
| 855 | "INSERT OR IGNORE INTO torevert" |
| 856 | " SELECT pathname" |
| 857 | " FROM vfile" |
| 858 | " WHERE (substr(pathname,1,length('%q/'))='%q/'" |
| 859 | " OR substr(origname,1,length('%q/'))='%q/')" |
| 860 | " AND (chnged OR deleted OR rid=0 OR pathname!=origname);", |
| 861 | blob_str(&fname), blob_str(&fname), |
| 862 | blob_str(&fname), blob_str(&fname) |
| 863 | ); |
| 864 | }else{ |
| 865 | db_multi_exec( |
| 866 | "REPLACE INTO torevert VALUES(%B);" |
| 867 | "INSERT OR IGNORE INTO torevert" |
| 868 | " SELECT pathname" |
| 869 | " FROM vfile" |
| 870 | " WHERE origname=%B;", |
| 871 | &fname, &fname |
| 872 | ); |
| 873 | } |
| 874 | blob_reset(&fname); |
| 875 | } |
| 876 | }else{ |
| 877 | revertAll = 1; |
| 878 | } |
| 879 | |
| 880 | if( revisionOptNotSupported ){ |
| 881 | fossil_fatal("directories or the entire tree can only be reverted" |
| 882 | " back to current version"); |
| 883 | } |
| 884 | |
| 885 | if ( revertAll ){ |
| 886 | int vid; |
| 887 | vid = db_lget_int("checkout", 0); |
| 888 | vfile_check_signature(vid, 0); |
| 889 | db_multi_exec( |
| 890 | "DELETE FROM vmerge;" |
| @@ -843,10 +892,11 @@ | |
| 892 | " SELECT pathname" |
| 893 | " FROM vfile " |
| 894 | " WHERE chnged OR deleted OR rid=0 OR pathname!=origname;" |
| 895 | ); |
| 896 | } |
| 897 | |
| 898 | db_multi_exec( |
| 899 | "INSERT OR IGNORE INTO torevert" |
| 900 | " SELECT origname" |
| 901 | " FROM vfile" |
| 902 | " WHERE origname!=pathname AND pathname IN (SELECT name FROM torevert);" |
| 903 |
+164
| --- test/revert.test | ||
| +++ test/revert.test | ||
| @@ -186,9 +186,173 @@ | ||
| 186 | 186 | test 3-mv-2 {![file exists f1new]} |
| 187 | 187 | revert-test 3-1 {} { |
| 188 | 188 | REVERT f1 |
| 189 | 189 | DELETE f1new |
| 190 | 190 | } -exists {f1} -notexists {f1n} |
| 191 | + | |
| 192 | + | |
| 193 | +# Test reverting of files under a sub-directory | |
| 194 | +test_setup | |
| 195 | +file mkdir d | |
| 196 | +write_file d/f1 "d/f1" | |
| 197 | +write_file d/f2 "d/f2" | |
| 198 | +write_file d/f3 "d/f3" | |
| 199 | +write_file d/f4 "d/f4" | |
| 200 | + | |
| 201 | +fossil add d | |
| 202 | +fossil delete d/f1 | |
| 203 | +fossil commit -m "d/f2 d/f3 d/f4" | |
| 204 | + | |
| 205 | +## Changes to revert | |
| 206 | +fossil add d/f1 | |
| 207 | +write_file d/f2 "4-1:d/f2" | |
| 208 | +fossil changes d/f2 | |
| 209 | +fossil delete --soft d/f3 | |
| 210 | + | |
| 211 | +revert-test 4-1 {d/f1} { | |
| 212 | + UNMANAGE d/f1 | |
| 213 | +} -changes { | |
| 214 | + EDITED d/f2 | |
| 215 | + DELETED d/f3 | |
| 216 | +} -addremove { | |
| 217 | + ADDED d/f1 | |
| 218 | +} -exists {d/f1 d/f2 d/f3} | |
| 219 | + | |
| 220 | +revert-test 4-2 {d/f2} { | |
| 221 | + REVERT d/f2 | |
| 222 | +} -changes { | |
| 223 | + ADDED d/f1 | |
| 224 | + DELETED d/f3 | |
| 225 | +} -exists {d/f1 d/f2 d/f3} | |
| 226 | + | |
| 227 | +revert-test 4-3 {d/f3} { | |
| 228 | + REVERT d/f3 | |
| 229 | +} -changes { | |
| 230 | + ADDED d/f1 | |
| 231 | + EDITED d/f2 | |
| 232 | +} -exists {d/f1 d/f2 d/f3} | |
| 233 | + | |
| 234 | +fossil mv --soft d/f4 d/f4new | |
| 235 | +test 4-4-mv-1 {[file exists d/f4]} | |
| 236 | +test 4-4-mv-2 {![file exists d/f4new]} | |
| 237 | +revert-test 4-4 {d/f4} { | |
| 238 | + DELETE d/f4new | |
| 239 | + REVERT d/f4 | |
| 240 | +} -changes { | |
| 241 | + ADDED d/f1 | |
| 242 | + EDITED d/f2 | |
| 243 | + DELETED d/f3 | |
| 244 | +} -exists {d/f4} -notexists {d/f4new} | |
| 245 | + | |
| 246 | +## Commit changes before testing reverting of directory rename, | |
| 247 | +## otherwise there're could be sequencing issues | |
| 248 | +fossil redo | |
| 249 | +fossil commit -m "4-5:setup" | |
| 250 | + | |
| 251 | +fossil mv --soft d dnew | |
| 252 | +revert-test 4-5 {d/f1 d/f2 d/f3 d/f4} { | |
| 253 | + REVERT d/f1 | |
| 254 | + REVERT d/f2 | |
| 255 | + UNMANAGE d/f3 | |
| 256 | + REVERT d/f4 | |
| 257 | + DELETE dnew/f1 | |
| 258 | + DELETE dnew/f2 | |
| 259 | + DELETE dnew/f4 | |
| 260 | +} -addremove { | |
| 261 | + ADDED d/f3 | |
| 262 | +} -exists {d/f1 d/f2 d/f3 d/f4} -notexists {dnew} | |
| 263 | + | |
| 264 | + | |
| 265 | +## Test reverting of changes in whole sub-directory tree | |
| 266 | +test_setup | |
| 267 | +file mkdir d | |
| 268 | +write_file f0 "f0" | |
| 269 | +write_file d/f1 "d/f1" | |
| 270 | +write_file d/f2 "d/f2" | |
| 271 | +write_file d/f3 "d/f3" | |
| 272 | +write_file d/f4 "d/f4" | |
| 273 | + | |
| 274 | +fossil add f0 d | |
| 275 | +fossil delete d/f1 | |
| 276 | +fossil commit -m "f0 d/f2 d/f3 d/f4" | |
| 277 | + | |
| 278 | +## Changes to revert | |
| 279 | +fossil add d/f1 | |
| 280 | +write_file d/f2 "5-1:d/f2" | |
| 281 | +fossil changes d/f2 | |
| 282 | +fossil delete --soft d/f3 | |
| 283 | + | |
| 284 | +revert-test 5-1 {d} { | |
| 285 | + UNMANAGE d/f1 | |
| 286 | + REVERT d/f2 | |
| 287 | + REVERT d/f3 | |
| 288 | +} -addremove { | |
| 289 | + ADDED d/f1 | |
| 290 | +} -exists {f0 d/f1 d/f2 d/f3} | |
| 291 | + | |
| 292 | +write_file f0 "5-2:f0" | |
| 293 | +fossil changes f0 | |
| 294 | +revert-test 5-2 {f0 d} { | |
| 295 | + UNMANAGE d/f1 | |
| 296 | + REVERT d/f2 | |
| 297 | + REVERT d/f3 | |
| 298 | + REVERT f0 | |
| 299 | +} -addremove { | |
| 300 | + ADDED d/f1 | |
| 301 | +} -exists {f0 d/f1 d/f2 d/f3} | |
| 302 | + | |
| 303 | +## Commit changes before testing the revert of directory rename, | |
| 304 | +## otherwise there're could be sequencing issues | |
| 305 | +fossil commit -m "5-3:setup" | |
| 306 | + | |
| 307 | +fossil changes | |
| 308 | + | |
| 309 | +fossil mv --soft d dnew | |
| 310 | +revert-test 5-3 {d} { | |
| 311 | + REVERT d/f1 | |
| 312 | + REVERT d/f2 | |
| 313 | + REVERT d/f4 | |
| 314 | + DELETE dnew/f1 | |
| 315 | + DELETE dnew/f2 | |
| 316 | + DELETE dnew/f4 | |
| 317 | +} -addremove { | |
| 318 | + ADDED d/f3 | |
| 319 | +} -exists {f0 d/f1 d/f2 d/f3 d/f4} -notexists {dnew} | |
| 320 | + | |
| 321 | +## Reset/redo the undone results of revert to get to a clean checkout | |
| 322 | +fossil redo | |
| 323 | + | |
| 324 | +file mkdir d/e | |
| 325 | +file mkdir d/e/f | |
| 326 | +write_file d/e/fe1 "d/e/fe1" | |
| 327 | +write_file d/e/f/ff1 "d/e/f/ff1" | |
| 328 | + | |
| 329 | +file mkdir d1 | |
| 330 | +file mkdir d1/e | |
| 331 | +write_file d1/e/fe1 "d1/e/fe1" | |
| 332 | +write_file d1/e/fe2 "d1/e/fe2" | |
| 333 | + | |
| 334 | +fossil add d1/e/fe1 | |
| 335 | +fossil commit d1/e/fe1 -m "d1/e/fe1" | |
| 336 | + | |
| 337 | +write_file d1/e/fe1 "5-4:d1/e/fe1" | |
| 338 | +fossil changes d1/e/fe1 | |
| 339 | +fossil add d d1 | |
| 340 | + | |
| 341 | +revert-test 5-4 {d d1} { | |
| 342 | + UNMANAGE d/f3 | |
| 343 | + UNMANAGE d/e/fe1 | |
| 344 | + UNMANAGE d/e/f/ff1 | |
| 345 | + REVERT d1/e/fe1 | |
| 346 | + UNMANAGE d1/e/fe2 | |
| 347 | +} -addremove { | |
| 348 | + ADDED d/f3 | |
| 349 | + ADDED d/e/fe1 | |
| 350 | + ADDED d/e/f/ff1 | |
| 351 | + ADDED d1/e/fe2 | |
| 352 | +} -exists {d/f1 d/f2 d/f3 d/f4 d/e/fe1 d/e/fe1 d/e/f/ff1 | |
| 353 | + d1/e/fe1 d1/e/fe2} | |
| 354 | + | |
| 191 | 355 | |
| 192 | 356 | ############################################################################### |
| 193 | 357 | |
| 194 | 358 | test_cleanup |
| 195 | 359 |
| --- test/revert.test | |
| +++ test/revert.test | |
| @@ -186,9 +186,173 @@ | |
| 186 | test 3-mv-2 {![file exists f1new]} |
| 187 | revert-test 3-1 {} { |
| 188 | REVERT f1 |
| 189 | DELETE f1new |
| 190 | } -exists {f1} -notexists {f1n} |
| 191 | |
| 192 | ############################################################################### |
| 193 | |
| 194 | test_cleanup |
| 195 |
| --- test/revert.test | |
| +++ test/revert.test | |
| @@ -186,9 +186,173 @@ | |
| 186 | test 3-mv-2 {![file exists f1new]} |
| 187 | revert-test 3-1 {} { |
| 188 | REVERT f1 |
| 189 | DELETE f1new |
| 190 | } -exists {f1} -notexists {f1n} |
| 191 | |
| 192 | |
| 193 | # Test reverting of files under a sub-directory |
| 194 | test_setup |
| 195 | file mkdir d |
| 196 | write_file d/f1 "d/f1" |
| 197 | write_file d/f2 "d/f2" |
| 198 | write_file d/f3 "d/f3" |
| 199 | write_file d/f4 "d/f4" |
| 200 | |
| 201 | fossil add d |
| 202 | fossil delete d/f1 |
| 203 | fossil commit -m "d/f2 d/f3 d/f4" |
| 204 | |
| 205 | ## Changes to revert |
| 206 | fossil add d/f1 |
| 207 | write_file d/f2 "4-1:d/f2" |
| 208 | fossil changes d/f2 |
| 209 | fossil delete --soft d/f3 |
| 210 | |
| 211 | revert-test 4-1 {d/f1} { |
| 212 | UNMANAGE d/f1 |
| 213 | } -changes { |
| 214 | EDITED d/f2 |
| 215 | DELETED d/f3 |
| 216 | } -addremove { |
| 217 | ADDED d/f1 |
| 218 | } -exists {d/f1 d/f2 d/f3} |
| 219 | |
| 220 | revert-test 4-2 {d/f2} { |
| 221 | REVERT d/f2 |
| 222 | } -changes { |
| 223 | ADDED d/f1 |
| 224 | DELETED d/f3 |
| 225 | } -exists {d/f1 d/f2 d/f3} |
| 226 | |
| 227 | revert-test 4-3 {d/f3} { |
| 228 | REVERT d/f3 |
| 229 | } -changes { |
| 230 | ADDED d/f1 |
| 231 | EDITED d/f2 |
| 232 | } -exists {d/f1 d/f2 d/f3} |
| 233 | |
| 234 | fossil mv --soft d/f4 d/f4new |
| 235 | test 4-4-mv-1 {[file exists d/f4]} |
| 236 | test 4-4-mv-2 {![file exists d/f4new]} |
| 237 | revert-test 4-4 {d/f4} { |
| 238 | DELETE d/f4new |
| 239 | REVERT d/f4 |
| 240 | } -changes { |
| 241 | ADDED d/f1 |
| 242 | EDITED d/f2 |
| 243 | DELETED d/f3 |
| 244 | } -exists {d/f4} -notexists {d/f4new} |
| 245 | |
| 246 | ## Commit changes before testing reverting of directory rename, |
| 247 | ## otherwise there're could be sequencing issues |
| 248 | fossil redo |
| 249 | fossil commit -m "4-5:setup" |
| 250 | |
| 251 | fossil mv --soft d dnew |
| 252 | revert-test 4-5 {d/f1 d/f2 d/f3 d/f4} { |
| 253 | REVERT d/f1 |
| 254 | REVERT d/f2 |
| 255 | UNMANAGE d/f3 |
| 256 | REVERT d/f4 |
| 257 | DELETE dnew/f1 |
| 258 | DELETE dnew/f2 |
| 259 | DELETE dnew/f4 |
| 260 | } -addremove { |
| 261 | ADDED d/f3 |
| 262 | } -exists {d/f1 d/f2 d/f3 d/f4} -notexists {dnew} |
| 263 | |
| 264 | |
| 265 | ## Test reverting of changes in whole sub-directory tree |
| 266 | test_setup |
| 267 | file mkdir d |
| 268 | write_file f0 "f0" |
| 269 | write_file d/f1 "d/f1" |
| 270 | write_file d/f2 "d/f2" |
| 271 | write_file d/f3 "d/f3" |
| 272 | write_file d/f4 "d/f4" |
| 273 | |
| 274 | fossil add f0 d |
| 275 | fossil delete d/f1 |
| 276 | fossil commit -m "f0 d/f2 d/f3 d/f4" |
| 277 | |
| 278 | ## Changes to revert |
| 279 | fossil add d/f1 |
| 280 | write_file d/f2 "5-1:d/f2" |
| 281 | fossil changes d/f2 |
| 282 | fossil delete --soft d/f3 |
| 283 | |
| 284 | revert-test 5-1 {d} { |
| 285 | UNMANAGE d/f1 |
| 286 | REVERT d/f2 |
| 287 | REVERT d/f3 |
| 288 | } -addremove { |
| 289 | ADDED d/f1 |
| 290 | } -exists {f0 d/f1 d/f2 d/f3} |
| 291 | |
| 292 | write_file f0 "5-2:f0" |
| 293 | fossil changes f0 |
| 294 | revert-test 5-2 {f0 d} { |
| 295 | UNMANAGE d/f1 |
| 296 | REVERT d/f2 |
| 297 | REVERT d/f3 |
| 298 | REVERT f0 |
| 299 | } -addremove { |
| 300 | ADDED d/f1 |
| 301 | } -exists {f0 d/f1 d/f2 d/f3} |
| 302 | |
| 303 | ## Commit changes before testing the revert of directory rename, |
| 304 | ## otherwise there're could be sequencing issues |
| 305 | fossil commit -m "5-3:setup" |
| 306 | |
| 307 | fossil changes |
| 308 | |
| 309 | fossil mv --soft d dnew |
| 310 | revert-test 5-3 {d} { |
| 311 | REVERT d/f1 |
| 312 | REVERT d/f2 |
| 313 | REVERT d/f4 |
| 314 | DELETE dnew/f1 |
| 315 | DELETE dnew/f2 |
| 316 | DELETE dnew/f4 |
| 317 | } -addremove { |
| 318 | ADDED d/f3 |
| 319 | } -exists {f0 d/f1 d/f2 d/f3 d/f4} -notexists {dnew} |
| 320 | |
| 321 | ## Reset/redo the undone results of revert to get to a clean checkout |
| 322 | fossil redo |
| 323 | |
| 324 | file mkdir d/e |
| 325 | file mkdir d/e/f |
| 326 | write_file d/e/fe1 "d/e/fe1" |
| 327 | write_file d/e/f/ff1 "d/e/f/ff1" |
| 328 | |
| 329 | file mkdir d1 |
| 330 | file mkdir d1/e |
| 331 | write_file d1/e/fe1 "d1/e/fe1" |
| 332 | write_file d1/e/fe2 "d1/e/fe2" |
| 333 | |
| 334 | fossil add d1/e/fe1 |
| 335 | fossil commit d1/e/fe1 -m "d1/e/fe1" |
| 336 | |
| 337 | write_file d1/e/fe1 "5-4:d1/e/fe1" |
| 338 | fossil changes d1/e/fe1 |
| 339 | fossil add d d1 |
| 340 | |
| 341 | revert-test 5-4 {d d1} { |
| 342 | UNMANAGE d/f3 |
| 343 | UNMANAGE d/e/fe1 |
| 344 | UNMANAGE d/e/f/ff1 |
| 345 | REVERT d1/e/fe1 |
| 346 | UNMANAGE d1/e/fe2 |
| 347 | } -addremove { |
| 348 | ADDED d/f3 |
| 349 | ADDED d/e/fe1 |
| 350 | ADDED d/e/f/ff1 |
| 351 | ADDED d1/e/fe2 |
| 352 | } -exists {d/f1 d/f2 d/f3 d/f4 d/e/fe1 d/e/fe1 d/e/f/ff1 |
| 353 | d1/e/fe1 d1/e/fe2} |
| 354 | |
| 355 | |
| 356 | ############################################################################### |
| 357 | |
| 358 | test_cleanup |
| 359 |