Fossil SCM

Show an error message when trying to rename one file on top of another, rather than throwing a uniqueness constraint. Ticket [1e43138b8b8e90f]

drh 2012-11-07 11:27 trunk
Commit 14fdae7e4018df438771a1b14cd607bcc13f1168
1 file changed +10
+10
--- src/add.c
+++ src/add.c
@@ -500,10 +500,20 @@
500500
** Rename a single file.
501501
**
502502
** The original name of the file is zOrig. The new filename is zNew.
503503
*/
504504
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
+ }
505515
fossil_print("RENAME %s %s\n", zOrig, zNew);
506516
db_multi_exec(
507517
"UPDATE vfile SET pathname='%q' WHERE pathname='%q' AND vid=%d",
508518
zNew, zOrig, vid
509519
);
510520
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button