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]

ashepilko 2020-06-02 22:34 trunk
Commit 709d2f804f415a6a8c16d9ed8101e13644d0f355cb4b1692c8c80b48882a4533
2 files changed +1 -1 +28
+1 -1
--- src/add.c
+++ src/add.c
@@ -1090,11 +1090,11 @@
10901090
const char *zPath = db_column_text(&q, 0);
10911091
int nPath = db_column_bytes(&q, 0);
10921092
const char *zTail;
10931093
if( nPath==nOrig ){
10941094
zTail = file_tail(zPath);
1095
- }else if( destType==1 ){
1095
+ }else if( origType!=0 && destType==1 ){
10961096
zTail = &zPath[nOrig-strlen(file_tail(zOrig))];
10971097
}else{
10981098
zTail = &zPath[nOrig+1];
10991099
}
11001100
db_multi_exec(
11011101
--- 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
--- test/mv-rm.test
+++ test/mv-rm.test
@@ -50,11 +50,15 @@
5050
file mkdir [file join $rootDir subdirC]
5151
write_file [file join $rootDir subdirC f10] "f10"
5252
write_file [file join $rootDir subdirC f11] "f11"
5353
write_file f12 "f12"
5454
55
+file mkdir [file join $rootDir subdirE a]
56
+write_file [file join $rootDir subdirE a f14] "f14"
57
+
5558
fossil add f1 f2 f3 f4 f5 f6 f7 f8 subdirB/f9 subdirC/f10 subdirC/f11 f12
59
+fossil add subdirE/a/f14
5660
fossil commit -m "c1"
5761
5862
########################################
5963
# Test 1: Soft Move Relative Directory #
6064
########################################
@@ -431,10 +435,34 @@
431435
test mv-file-new-directory-13 {[file size subdirC/f10] == 3}
432436
test mv-file-new-directory-14 {[read_file subdirC/f10] eq "f10"}
433437
test mv-file-new-directory-15 {[file size subdirC/f11] == 3}
434438
test mv-file-new-directory-16 {[read_file subdirC/f11] eq "f11"}
435439
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
+
436464
cd $rootDir
437465
438466
###############################################################################
439467
440468
test_cleanup
441469
--- 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

Keyboard Shortcuts

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