Fossil

Check-in [709d2f80]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:mv: Handle the case of soft-renaming of a managed sub-directory that was already renamed at the file-system level; see forumpost/f5b13591e3
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 709d2f804f415a6a8c16d9ed8101e13644d0f355cb4b1692c8c80b48882a4533
User & Date: ashepilko 2020-06-02 22:34:09
Context
2020-06-03
22:43
Squelched a compiler warning reported at https://fossil-scm.org/forum/forumpost/4215cf68c7. ... (check-in: 35ce9e3e user: stephan tags: trunk)
2020-06-02
22:34
mv: Handle the case of soft-renaming of a managed sub-directory that was already renamed at the file-system level; see forumpost/f5b13591e3 ... (check-in: 709d2f80 user: ashepilko tags: trunk)
20:05
Add the safe-html setting that determines which kinds of documents are allowed to generate unsafe HTML from Markdown. ... (check-in: 89b6dda9 user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/add.c.

1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
      );
      while( db_step(&q)==SQLITE_ROW ){
        const char *zPath = db_column_text(&q, 0);
        int nPath = db_column_bytes(&q, 0);
        const char *zTail;
        if( nPath==nOrig ){
          zTail = file_tail(zPath);
        }else if( destType==1 ){
          zTail = &zPath[nOrig-strlen(file_tail(zOrig))];
        }else{
          zTail = &zPath[nOrig+1];
        }
        db_multi_exec(
          "INSERT INTO mv VALUES('%q','%q%q')",
          zPath, blob_str(&dest), zTail







|







1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
      );
      while( db_step(&q)==SQLITE_ROW ){
        const char *zPath = db_column_text(&q, 0);
        int nPath = db_column_bytes(&q, 0);
        const char *zTail;
        if( nPath==nOrig ){
          zTail = file_tail(zPath);
        }else if( origType!=0 && destType==1 ){
          zTail = &zPath[nOrig-strlen(file_tail(zOrig))];
        }else{
          zTail = &zPath[nOrig+1];
        }
        db_multi_exec(
          "INSERT INTO mv VALUES('%q','%q%q')",
          zPath, blob_str(&dest), zTail

Changes to test/mv-rm.test.

48
49
50
51
52
53
54



55

56
57
58
59
60
61
62
write_file [file join $rootDir subdirB f9] "f9"

file mkdir [file join $rootDir subdirC]
write_file [file join $rootDir subdirC f10] "f10"
write_file [file join $rootDir subdirC f11] "f11"
write_file f12 "f12"




fossil add f1 f2 f3 f4 f5 f6 f7 f8 subdirB/f9 subdirC/f10 subdirC/f11 f12

fossil commit -m "c1"

########################################
# Test 1: Soft Move Relative Directory #
########################################

file mkdir [file join $rootDir subdir1]







>
>
>

>







48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
write_file [file join $rootDir subdirB f9] "f9"

file mkdir [file join $rootDir subdirC]
write_file [file join $rootDir subdirC f10] "f10"
write_file [file join $rootDir subdirC f11] "f11"
write_file f12 "f12"

file mkdir [file join $rootDir subdirE a]
write_file [file join $rootDir subdirE a f14] "f14"

fossil add f1 f2 f3 f4 f5 f6 f7 f8 subdirB/f9 subdirC/f10 subdirC/f11 f12
fossil add subdirE/a/f14
fossil commit -m "c1"

########################################
# Test 1: Soft Move Relative Directory #
########################################

file mkdir [file join $rootDir subdir1]
429
430
431
432
433
434
435
























436
437
438
439
440
}

test mv-file-new-directory-13 {[file size subdirC/f10] == 3}
test mv-file-new-directory-14 {[read_file subdirC/f10] eq "f10"}
test mv-file-new-directory-15 {[file size subdirC/f11] == 3}
test mv-file-new-directory-16 {[read_file subdirC/f11] eq "f11"}

























cd $rootDir

###############################################################################

test_cleanup







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>





433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
}

test mv-file-new-directory-13 {[file size subdirC/f10] == 3}
test mv-file-new-directory-14 {[read_file subdirC/f10] eq "f10"}
test mv-file-new-directory-15 {[file size subdirC/f11] == 3}
test mv-file-new-directory-16 {[read_file subdirC/f11] eq "f11"}

cd $rootDir

###############################################################################
# Test 19: Follow-up Soft Rename of a Directory Already Renamed on Filesystem #
###############################################################################

file rename [file join $rootDir subdirE/a] [file join $rootDir subdirE/a_renamed]

fossil mv subdirE/a subdirE/a_renamed
test mv-soft-already-renamed-directory-1 {
  [normalize_result] eq "RENAME subdirE/a/f14 subdirE/a_renamed/f14"
}

test mv-soft-already-renamed-directory-2 {[file size subdirE/a_renamed/f14] == 3}
test mv-soft-already-renamed-directory-3 {[read_file subdirE/a_renamed/f14] eq "f14"}

fossil revert
test mv-soft-already-renamed-directory-4 {
  [normalize_result] eq "DELETE   subdirE/a_renamed/f14\nREVERT   subdirE/a/f14${undoMsg}"
}

test mv-soft-already-renamed-directory-5 {[file size subdirE/a/f14] == 3}
test mv-soft-already-renamed-directory-6 {[read_file subdirE/a/f14] eq "f14"}

cd $rootDir

###############################################################################

test_cleanup