Fossil

Changes On Branch 12453740c7089157
Login

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

Changes In Branch mvHardDirFix Through [12453740c7] Excluding Merge-Ins

This is equivalent to a diff from 93f514ca2c to 12453740c7

2016-03-12
00:47
Update the expected results of the tests to account for trunk changes. Closed-Leaf check-in: b511398536 user: mistachkin tags: mvHardDirFix
2016-03-11
23:38
Fix compilation issues cause by the trunk merge. check-in: 12453740c7 user: mistachkin tags: mvHardDirFix
2016-03-08
19:37
Cleanup, modularize, and robustify all test setup and cleanup. check-in: fa59221693 user: mistachkin tags: trunk
2016-03-06
06:38
Merge updates from trunk. check-in: ccf01b243f user: mistachkin tags: stash-fixes
06:35
Merge updates from trunk. Closed-Leaf check-in: ff4a4fe6b2 user: mistachkin tags: pending-review
06:35
Merge updates from trunk. Closed-Leaf check-in: 4bd2b54592 user: mistachkin tags: pending-review
06:34
Merge updates from trunk. Closed-Leaf check-in: 370c003d15 user: mistachkin tags: baruch_timeline_fixes
06:28
Merge updates from trunk. Closed-Leaf check-in: 45ed23d946 user: mistachkin tags: altBaseUrlRepoDir
06:26
Merge updates from trunk. check-in: abd131b83c user: mistachkin tags: mvHardDirFix
2016-03-05
20:01
Added add_content_sql_commands() to /admin_sql, as per ML discussion. check-in: 93f514ca2c user: stephan tags: trunk
2016-03-02
02:10
Permit the TH1 hooks subsystem to check for the configuration without raising a 'fatal' error. check-in: b06cd631f1 user: mistachkin tags: trunk

Changes to src/add.c.
783
784
785
786
787
788
789







790
791
792
793
794
795







796
797
798
799
800
801
802
783
784
785
786
787
788
789
790
791
792
793
794
795
796






797
798
799
800
801
802
803
804
805
806
807
808
809
810







+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+







  Stmt move;
  if( db_table_exists(db_name("temp"), "fmove") ){
    db_prepare(&move, "SELECT x, y FROM fmove ORDER BY x;");
    while( db_step(&move)==SQLITE_ROW ){
      const char *zOldName = db_column_text(&move, 0);
      const char *zNewName = db_column_text(&move, 1);
      if( !dryRunFlag ){
        int isOldDir = file_isdir(zOldName);
        if( isOldDir==1 ){
          int isNewDir = file_isdir(zNewName);
          if( isNewDir==0 ){
            file_rename(zOldName, zNewName, isOldDir, isNewDir);
          }
        }else{
        if( file_wd_islink(zOldName) ){
          symlink_copy(zOldName, zNewName);
        }else{
          file_copy(zOldName, zNewName);
        }
        file_delete(zOldName);
          if( file_wd_islink(zOldName) ){
            symlink_copy(zOldName, zNewName);
          }else{
            file_copy(zOldName, zNewName);
          }
          file_delete(zOldName);
        }
      }
      fossil_print("MOVED_FILE %s\n", zOldName);
    }
    db_finalize(&move);
    db_multi_exec("DROP TABLE fmove;");
  }
}
Changes to src/file.c.
22
23
24
25
26
27
28

29
30
31
32
33
34
35
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36







+







** Functions named file_wd_* are to be used for files inside working
** directories. They follow symlinks depending on 'allow-symlinks' setting.
*/
#include "config.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "file.h"

/*
** On Windows, include the Platform SDK header file.
*/
396
397
398
399
400
401
402

























403
404
405
406
407
408
409
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







  const char *zTail = file_tail(z);
  if( zTail && zTail!=z ){
    return mprintf("%.*s", (int)(zTail-z-1), z);
  }else{
    return 0;
  }
}

/*
** Rename a file or directory.
** Returns zero upon success.
*/
int file_rename(
  const char *zFrom,
  const char *zTo,
  int isFromDir,
  int isToDir
){
  int rc;
#if defined(_WIN32)
  wchar_t *zMbcsFrom = fossil_utf8_to_path(zFrom, isFromDir);
  wchar_t *zMbcsTo = fossil_utf8_to_path(zTo, isToDir);
  rc = _wrename(zMbcsFrom, zMbcsTo);
#else
  char *zMbcsFrom = fossil_utf8_to_path(zFrom, isFromDir);
  char *zMbcsTo = fossil_utf8_to_path(zTo, isToDir);
  rc = rename(zMbcsFrom, zMbcsTo);
#endif
  fossil_path_free(zMbcsTo);
  fossil_path_free(zMbcsFrom);
  return rc;
}

/*
** Copy the content of a file from one place to another.
*/
void file_copy(const char *zFrom, const char *zTo){
  FILE *in, *out;
  int got;
Changes to test/mv-rm.test.
50
51
52
53
54
55
56

57
58

59
60
61
62
63
64
65
50
51
52
53
54
55
56
57
58

59
60
61
62
63
64
65
66







+

-
+








file mkdir [file join $rootDir subdirB]
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
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]
384
385
386
387
388
389
390
391
















































385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440








+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
}

fossil revert
test rm-hard-absolute-6 {
  [normalize_result] eq "REVERT   f8${undoMsg}"
}

cd $rootDir

#######################################
# Test 17: Move File to New Directory #
#######################################

fossil mv --hard f12 d2/f13
test mv-file-new-directory-1 {
  [normalize_result] eq "RENAME f12 d2/f13\nMOVED_FILE ${rootDir}/f12"
}

test mv-file-new-directory-2 {[file size d2/f13] == 3}
test mv-file-new-directory-3 {[read_file d2/f13] eq "f12"}

fossil revert
test mv-file-new-directory-4 {
  [normalize_result] eq "DELETE: d2/f13\nREVERTED: f12${undoMsg}"
}

test mv-file-new-directory-5 {[file size f12] == 3}
test mv-file-new-directory-6 {[read_file f12] eq "f12"}

cd $rootDir

############################################
# Test 18: Move Directory to New Directory #
############################################

fossil mv --hard subdirC subdirD
test mv-file-new-directory-7 {
  [normalize_result] eq "RENAME subdirC subdirD\nMOVED_FILE ${rootDir}/subdirC"
}

test mv-file-new-directory-8 {[file size subdirD/f10] == 3}
test mv-file-new-directory-9 {[read_file subdirD/f10] eq "f10"}
test mv-file-new-directory-10 {[file size subdirD/f11] == 3}
test mv-file-new-directory-11 {[read_file subdirD/f11] eq "f11"}

fossil revert
test mv-file-new-directory-12 {
  [normalize_result] eq "REVERTED: subdirC/f10\nREVERTED: subdirC/f11${undoMsg}"
}

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