Fossil SCM
Show an error message when trying to rename one file on top of another, rather than throwing a uniqueness constraint. Ticket [1e43138b8b8e90f]
Commit
14fdae7e4018df438771a1b14cd607bcc13f1168
Parent
28272fa125bb160…
1 file changed
+10
+10
| --- src/add.c | ||
| +++ src/add.c | ||
| @@ -500,10 +500,20 @@ | ||
| 500 | 500 | ** Rename a single file. |
| 501 | 501 | ** |
| 502 | 502 | ** The original name of the file is zOrig. The new filename is zNew. |
| 503 | 503 | */ |
| 504 | 504 | static void mv_one_file(int vid, const char *zOrig, const char *zNew){ |
| 505 | + int x = db_int(-1, "SELECT deleted FROM vfile WHERE pathname=%Q", zNew); | |
| 506 | + if( x>=0 ){ | |
| 507 | + if( x==0 ){ | |
| 508 | + fossil_fatal("cannot rename '%s' to '%s' since another file named '%s'" | |
| 509 | + " is currently under management", zOrig, zNew, zNew); | |
| 510 | + }else{ | |
| 511 | + fossil_fatal("cannot rename '%s' to '%s' since the delete of '%s' has " | |
| 512 | + "not yet been committed", zOrig, zNew, zNew); | |
| 513 | + } | |
| 514 | + } | |
| 505 | 515 | fossil_print("RENAME %s %s\n", zOrig, zNew); |
| 506 | 516 | db_multi_exec( |
| 507 | 517 | "UPDATE vfile SET pathname='%q' WHERE pathname='%q' AND vid=%d", |
| 508 | 518 | zNew, zOrig, vid |
| 509 | 519 | ); |
| 510 | 520 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -500,10 +500,20 @@ | |
| 500 | ** Rename a single file. |
| 501 | ** |
| 502 | ** The original name of the file is zOrig. The new filename is zNew. |
| 503 | */ |
| 504 | static void mv_one_file(int vid, const char *zOrig, const char *zNew){ |
| 505 | fossil_print("RENAME %s %s\n", zOrig, zNew); |
| 506 | db_multi_exec( |
| 507 | "UPDATE vfile SET pathname='%q' WHERE pathname='%q' AND vid=%d", |
| 508 | zNew, zOrig, vid |
| 509 | ); |
| 510 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -500,10 +500,20 @@ | |
| 500 | ** Rename a single file. |
| 501 | ** |
| 502 | ** The original name of the file is zOrig. The new filename is zNew. |
| 503 | */ |
| 504 | static void mv_one_file(int vid, const char *zOrig, const char *zNew){ |
| 505 | int x = db_int(-1, "SELECT deleted FROM vfile WHERE pathname=%Q", zNew); |
| 506 | if( x>=0 ){ |
| 507 | if( x==0 ){ |
| 508 | fossil_fatal("cannot rename '%s' to '%s' since another file named '%s'" |
| 509 | " is currently under management", zOrig, zNew, zNew); |
| 510 | }else{ |
| 511 | fossil_fatal("cannot rename '%s' to '%s' since the delete of '%s' has " |
| 512 | "not yet been committed", zOrig, zNew, zNew); |
| 513 | } |
| 514 | } |
| 515 | fossil_print("RENAME %s %s\n", zOrig, zNew); |
| 516 | db_multi_exec( |
| 517 | "UPDATE vfile SET pathname='%q' WHERE pathname='%q' AND vid=%d", |
| 518 | zNew, zOrig, vid |
| 519 | ); |
| 520 |