Fossil SCM
Fix reverting the combination of a renamed file and an added file that uses the renamed file's original filename. (This previously failed on a UNIQUE constraint.)
Commit
bd0b09e50b80461e13c6d2fbdf7d6b4aba128f98
Parent
3949c9a33e219ca…
2 files changed
+1
-1
+19
+1
-1
| --- src/update.c | ||
| +++ src/update.c | ||
| @@ -764,11 +764,11 @@ | ||
| 764 | 764 | undo_save(zFile); |
| 765 | 765 | file_delete(zFull); |
| 766 | 766 | fossil_print("DELETE: %s\n", zFile); |
| 767 | 767 | } |
| 768 | 768 | db_multi_exec( |
| 769 | - "UPDATE vfile" | |
| 769 | + "UPDATE OR REPLACE vfile" | |
| 770 | 770 | " SET pathname=origname, origname=NULL" |
| 771 | 771 | " WHERE pathname=%Q AND origname!=pathname;" |
| 772 | 772 | "DELETE FROM vfile WHERE pathname=%Q", |
| 773 | 773 | zFile, zFile |
| 774 | 774 | ); |
| 775 | 775 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -764,11 +764,11 @@ | |
| 764 | undo_save(zFile); |
| 765 | file_delete(zFull); |
| 766 | fossil_print("DELETE: %s\n", zFile); |
| 767 | } |
| 768 | db_multi_exec( |
| 769 | "UPDATE vfile" |
| 770 | " SET pathname=origname, origname=NULL" |
| 771 | " WHERE pathname=%Q AND origname!=pathname;" |
| 772 | "DELETE FROM vfile WHERE pathname=%Q", |
| 773 | zFile, zFile |
| 774 | ); |
| 775 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -764,11 +764,11 @@ | |
| 764 | undo_save(zFile); |
| 765 | file_delete(zFull); |
| 766 | fossil_print("DELETE: %s\n", zFile); |
| 767 | } |
| 768 | db_multi_exec( |
| 769 | "UPDATE OR REPLACE vfile" |
| 770 | " SET pathname=origname, origname=NULL" |
| 771 | " WHERE pathname=%Q AND origname!=pathname;" |
| 772 | "DELETE FROM vfile WHERE pathname=%Q", |
| 773 | zFile, zFile |
| 774 | ); |
| 775 |
+19
| --- test/revert.test | ||
| +++ test/revert.test | ||
| @@ -134,5 +134,24 @@ | ||
| 134 | 134 | } -changes { |
| 135 | 135 | DELETED f1 |
| 136 | 136 | } -addremove { |
| 137 | 137 | ADDED f0 |
| 138 | 138 | } -exists {f0 f2 f3} -notexists {f1 f3n} |
| 139 | + | |
| 140 | + | |
| 141 | +# Test reverting the combination of a renamed file and an added file that | |
| 142 | +# uses the renamed file's original filename. | |
| 143 | +# | |
| 144 | +repo_init | |
| 145 | +write_file f1 "f1" | |
| 146 | +fossil add f1 | |
| 147 | +fossil commit -m "add f1" | |
| 148 | + | |
| 149 | +write_file f1n "f1n" | |
| 150 | +fossil mv f1 f1n | |
| 151 | +write_file f1 "f1b" | |
| 152 | +fossil add f1 | |
| 153 | + | |
| 154 | +revert-test 2-1 {} { | |
| 155 | + REVERTED: f1 | |
| 156 | + DELETE: f1n | |
| 157 | +} -exists {f1} -notexists {f1n} | |
| 139 | 158 |
| --- test/revert.test | |
| +++ test/revert.test | |
| @@ -134,5 +134,24 @@ | |
| 134 | } -changes { |
| 135 | DELETED f1 |
| 136 | } -addremove { |
| 137 | ADDED f0 |
| 138 | } -exists {f0 f2 f3} -notexists {f1 f3n} |
| 139 |
| --- test/revert.test | |
| +++ test/revert.test | |
| @@ -134,5 +134,24 @@ | |
| 134 | } -changes { |
| 135 | DELETED f1 |
| 136 | } -addremove { |
| 137 | ADDED f0 |
| 138 | } -exists {f0 f2 f3} -notexists {f1 f3n} |
| 139 | |
| 140 | |
| 141 | # Test reverting the combination of a renamed file and an added file that |
| 142 | # uses the renamed file's original filename. |
| 143 | # |
| 144 | repo_init |
| 145 | write_file f1 "f1" |
| 146 | fossil add f1 |
| 147 | fossil commit -m "add f1" |
| 148 | |
| 149 | write_file f1n "f1n" |
| 150 | fossil mv f1 f1n |
| 151 | write_file f1 "f1b" |
| 152 | fossil add f1 |
| 153 | |
| 154 | revert-test 2-1 {} { |
| 155 | REVERTED: f1 |
| 156 | DELETE: f1n |
| 157 | } -exists {f1} -notexists {f1n} |
| 158 |