Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Candidate fix for directory renaming issue with the --hard option as reported via the mailing list. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | mvHardDirFix |
| Files: | files | file ages | folders |
| SHA1: |
b86127e187a00bfc0b0025601b8c88a3 |
| User & Date: | mistachkin 2015-07-29 18:44:10.521 |
| Original Comment: | Candidate fix for directory renaming issue with --hard option reports on the mailing list. |
Context
|
2016-03-06
| ||
| 06:26 | Merge updates from trunk. check-in: abd131b83c user: mistachkin tags: mvHardDirFix | |
|
2015-07-29
| ||
| 18:44 | Candidate fix for directory renaming issue with the --hard option as reported via the mailing list. check-in: b86127e187 user: mistachkin tags: mvHardDirFix | |
| 17:35 | minor CGI-in-chroot doc update from the ML. check-in: 1d3a80474b user: stephan tags: trunk | |
Changes
Changes to src/add.c.
| ︙ | ︙ | |||
774 775 776 777 778 779 780 |
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 ){
| > > > > > | | | | | | > | 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 |
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 ){
if( file_isdir(zOldName)==1 ){
if( file_isdir(zNewName)==0 ){
file_rename(zOldName, zNewName);
}
}else{
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 | ** 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 <string.h> #include <errno.h> #include "file.h" /* ** On Windows, include the Platform SDK header file. */ | > | 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 |
const char *zTail = file_tail(z);
if( zTail && zTail!=z ){
return mprintf("%.*s", (int)(zTail-z-1), z);
}else{
return 0;
}
}
/*
** 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;
| > > > > > > > > > > > > > > > > > > > > | 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 |
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 rc;
#if defined(_WIN32)
wchar_t *zMbcsFrom = fossil_utf8_to_filename(zFrom);
wchar_t *zMbcsTo = fossil_utf8_to_filename(zTo);
rc = _wrename(zMbcsFrom, zMbcsTo);
#else
char *zMbcsFrom = fossil_utf8_to_filename(zFrom);
char *zMbcsTo = fossil_utf8_to_filename(zTo);
rc = rename(zMbcsFrom, zMbcsTo);
#endif
fossil_filename_free(zMbcsTo);
fossil_filename_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.
| ︙ | ︙ | |||
51 52 53 54 55 56 57 58 | 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" | > | | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | 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 f12 fossil commit -m "c1" ######################################## # Test 1: Soft Move Relative Directory # ######################################## file mkdir [file join $rootDir subdir1] |
| ︙ | ︙ | |||
385 386 387 388 389 390 391 392 |
}
fossil revert
test rm-hard-absolute-6 {
[normalize_result] eq "REVERTED: f8${undoMsg}"
}
cd $rootDir
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 441 |
}
fossil revert
test rm-hard-absolute-6 {
[normalize_result] eq "REVERTED: 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
|