Fossil SCM
mv: Handle the case of soft-renaming of a managed sub-directory that was already renamed at the file-system level; see [https://fossil-scm.org/forum/forumpost/f5b13591e3|forumpost/f5b13591e3]
Commit
709d2f804f415a6a8c16d9ed8101e13644d0f355cb4b1692c8c80b48882a4533
Parent
89b6dda99c45533…
2 files changed
+1
-1
+28
+1
-1
| --- src/add.c | ||
| +++ src/add.c | ||
| @@ -1090,11 +1090,11 @@ | ||
| 1090 | 1090 | const char *zPath = db_column_text(&q, 0); |
| 1091 | 1091 | int nPath = db_column_bytes(&q, 0); |
| 1092 | 1092 | const char *zTail; |
| 1093 | 1093 | if( nPath==nOrig ){ |
| 1094 | 1094 | zTail = file_tail(zPath); |
| 1095 | - }else if( destType==1 ){ | |
| 1095 | + }else if( origType!=0 && destType==1 ){ | |
| 1096 | 1096 | zTail = &zPath[nOrig-strlen(file_tail(zOrig))]; |
| 1097 | 1097 | }else{ |
| 1098 | 1098 | zTail = &zPath[nOrig+1]; |
| 1099 | 1099 | } |
| 1100 | 1100 | db_multi_exec( |
| 1101 | 1101 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -1090,11 +1090,11 @@ | |
| 1090 | const char *zPath = db_column_text(&q, 0); |
| 1091 | int nPath = db_column_bytes(&q, 0); |
| 1092 | const char *zTail; |
| 1093 | if( nPath==nOrig ){ |
| 1094 | zTail = file_tail(zPath); |
| 1095 | }else if( destType==1 ){ |
| 1096 | zTail = &zPath[nOrig-strlen(file_tail(zOrig))]; |
| 1097 | }else{ |
| 1098 | zTail = &zPath[nOrig+1]; |
| 1099 | } |
| 1100 | db_multi_exec( |
| 1101 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -1090,11 +1090,11 @@ | |
| 1090 | const char *zPath = db_column_text(&q, 0); |
| 1091 | int nPath = db_column_bytes(&q, 0); |
| 1092 | const char *zTail; |
| 1093 | if( nPath==nOrig ){ |
| 1094 | zTail = file_tail(zPath); |
| 1095 | }else if( origType!=0 && destType==1 ){ |
| 1096 | zTail = &zPath[nOrig-strlen(file_tail(zOrig))]; |
| 1097 | }else{ |
| 1098 | zTail = &zPath[nOrig+1]; |
| 1099 | } |
| 1100 | db_multi_exec( |
| 1101 |
+28
| --- test/mv-rm.test | ||
| +++ test/mv-rm.test | ||
| @@ -50,11 +50,15 @@ | ||
| 50 | 50 | file mkdir [file join $rootDir subdirC] |
| 51 | 51 | write_file [file join $rootDir subdirC f10] "f10" |
| 52 | 52 | write_file [file join $rootDir subdirC f11] "f11" |
| 53 | 53 | write_file f12 "f12" |
| 54 | 54 | |
| 55 | +file mkdir [file join $rootDir subdirE a] | |
| 56 | +write_file [file join $rootDir subdirE a f14] "f14" | |
| 57 | + | |
| 55 | 58 | fossil add f1 f2 f3 f4 f5 f6 f7 f8 subdirB/f9 subdirC/f10 subdirC/f11 f12 |
| 59 | +fossil add subdirE/a/f14 | |
| 56 | 60 | fossil commit -m "c1" |
| 57 | 61 | |
| 58 | 62 | ######################################## |
| 59 | 63 | # Test 1: Soft Move Relative Directory # |
| 60 | 64 | ######################################## |
| @@ -431,10 +435,34 @@ | ||
| 431 | 435 | test mv-file-new-directory-13 {[file size subdirC/f10] == 3} |
| 432 | 436 | test mv-file-new-directory-14 {[read_file subdirC/f10] eq "f10"} |
| 433 | 437 | test mv-file-new-directory-15 {[file size subdirC/f11] == 3} |
| 434 | 438 | test mv-file-new-directory-16 {[read_file subdirC/f11] eq "f11"} |
| 435 | 439 | |
| 440 | +cd $rootDir | |
| 441 | + | |
| 442 | +############################################################################### | |
| 443 | +# Test 19: Follow-up Soft Rename of a Directory Already Renamed on Filesystem # | |
| 444 | +############################################################################### | |
| 445 | + | |
| 446 | +file rename [file join $rootDir subdirE/a] [file join $rootDir subdirE/a_renamed] | |
| 447 | + | |
| 448 | +fossil mv subdirE/a subdirE/a_renamed | |
| 449 | +test mv-soft-already-renamed-directory-1 { | |
| 450 | + [normalize_result] eq "RENAME subdirE/a/f14 subdirE/a_renamed/f14" | |
| 451 | +} | |
| 452 | + | |
| 453 | +test mv-soft-already-renamed-directory-2 {[file size subdirE/a_renamed/f14] == 3} | |
| 454 | +test mv-soft-already-renamed-directory-3 {[read_file subdirE/a_renamed/f14] eq "f14"} | |
| 455 | + | |
| 456 | +fossil revert | |
| 457 | +test mv-soft-already-renamed-directory-4 { | |
| 458 | + [normalize_result] eq "DELETE subdirE/a_renamed/f14\nREVERT subdirE/a/f14${undoMsg}" | |
| 459 | +} | |
| 460 | + | |
| 461 | +test mv-soft-already-renamed-directory-5 {[file size subdirE/a/f14] == 3} | |
| 462 | +test mv-soft-already-renamed-directory-6 {[read_file subdirE/a/f14] eq "f14"} | |
| 463 | + | |
| 436 | 464 | cd $rootDir |
| 437 | 465 | |
| 438 | 466 | ############################################################################### |
| 439 | 467 | |
| 440 | 468 | test_cleanup |
| 441 | 469 |
| --- test/mv-rm.test | |
| +++ test/mv-rm.test | |
| @@ -50,11 +50,15 @@ | |
| 50 | file mkdir [file join $rootDir subdirC] |
| 51 | write_file [file join $rootDir subdirC f10] "f10" |
| 52 | write_file [file join $rootDir subdirC f11] "f11" |
| 53 | write_file f12 "f12" |
| 54 | |
| 55 | fossil add f1 f2 f3 f4 f5 f6 f7 f8 subdirB/f9 subdirC/f10 subdirC/f11 f12 |
| 56 | fossil commit -m "c1" |
| 57 | |
| 58 | ######################################## |
| 59 | # Test 1: Soft Move Relative Directory # |
| 60 | ######################################## |
| @@ -431,10 +435,34 @@ | |
| 431 | test mv-file-new-directory-13 {[file size subdirC/f10] == 3} |
| 432 | test mv-file-new-directory-14 {[read_file subdirC/f10] eq "f10"} |
| 433 | test mv-file-new-directory-15 {[file size subdirC/f11] == 3} |
| 434 | test mv-file-new-directory-16 {[read_file subdirC/f11] eq "f11"} |
| 435 | |
| 436 | cd $rootDir |
| 437 | |
| 438 | ############################################################################### |
| 439 | |
| 440 | test_cleanup |
| 441 |
| --- test/mv-rm.test | |
| +++ test/mv-rm.test | |
| @@ -50,11 +50,15 @@ | |
| 50 | file mkdir [file join $rootDir subdirC] |
| 51 | write_file [file join $rootDir subdirC f10] "f10" |
| 52 | write_file [file join $rootDir subdirC f11] "f11" |
| 53 | write_file f12 "f12" |
| 54 | |
| 55 | file mkdir [file join $rootDir subdirE a] |
| 56 | write_file [file join $rootDir subdirE a f14] "f14" |
| 57 | |
| 58 | fossil add f1 f2 f3 f4 f5 f6 f7 f8 subdirB/f9 subdirC/f10 subdirC/f11 f12 |
| 59 | fossil add subdirE/a/f14 |
| 60 | fossil commit -m "c1" |
| 61 | |
| 62 | ######################################## |
| 63 | # Test 1: Soft Move Relative Directory # |
| 64 | ######################################## |
| @@ -431,10 +435,34 @@ | |
| 435 | test mv-file-new-directory-13 {[file size subdirC/f10] == 3} |
| 436 | test mv-file-new-directory-14 {[read_file subdirC/f10] eq "f10"} |
| 437 | test mv-file-new-directory-15 {[file size subdirC/f11] == 3} |
| 438 | test mv-file-new-directory-16 {[read_file subdirC/f11] eq "f11"} |
| 439 | |
| 440 | cd $rootDir |
| 441 | |
| 442 | ############################################################################### |
| 443 | # Test 19: Follow-up Soft Rename of a Directory Already Renamed on Filesystem # |
| 444 | ############################################################################### |
| 445 | |
| 446 | file rename [file join $rootDir subdirE/a] [file join $rootDir subdirE/a_renamed] |
| 447 | |
| 448 | fossil mv subdirE/a subdirE/a_renamed |
| 449 | test mv-soft-already-renamed-directory-1 { |
| 450 | [normalize_result] eq "RENAME subdirE/a/f14 subdirE/a_renamed/f14" |
| 451 | } |
| 452 | |
| 453 | test mv-soft-already-renamed-directory-2 {[file size subdirE/a_renamed/f14] == 3} |
| 454 | test mv-soft-already-renamed-directory-3 {[read_file subdirE/a_renamed/f14] eq "f14"} |
| 455 | |
| 456 | fossil revert |
| 457 | test mv-soft-already-renamed-directory-4 { |
| 458 | [normalize_result] eq "DELETE subdirE/a_renamed/f14\nREVERT subdirE/a/f14${undoMsg}" |
| 459 | } |
| 460 | |
| 461 | test mv-soft-already-renamed-directory-5 {[file size subdirE/a/f14] == 3} |
| 462 | test mv-soft-already-renamed-directory-6 {[read_file subdirE/a/f14] eq "f14"} |
| 463 | |
| 464 | cd $rootDir |
| 465 | |
| 466 | ############################################################################### |
| 467 | |
| 468 | test_cleanup |
| 469 |