Fossil SCM
Enhance file_tree_name() to be capable of producing absolute paths within the local tree. Fix --hard option to mv/rm to enable them to work properly with certain relative paths.
Commit
c56a387d47e5efde4a87d1e4a78b5430330caa0b
Parent
74836bc8ae09edd…
17 files changed
+40
-36
+5
-5
+2
-1
+1
-1
+2
-2
+53
-12
+4
-4
+1
-1
+1
-1
+1
-1
+2
-2
+31
+5
-5
+1
-1
+82
+2
-4
+4
-4
+40
-36
| --- src/add.c | ||
| +++ src/add.c | ||
| @@ -91,11 +91,11 @@ | ||
| 91 | 91 | |
| 92 | 92 | if( cachedManifest == -1 ){ |
| 93 | 93 | Blob repo; |
| 94 | 94 | cachedManifest = db_get_boolean("manifest",0); |
| 95 | 95 | blob_zero(&repo); |
| 96 | - if( file_tree_name(g.zRepositoryName, &repo, 0) ){ | |
| 96 | + if( file_tree_name(g.zRepositoryName, &repo, 0, 0) ){ | |
| 97 | 97 | const char *zRepo = blob_str(&repo); |
| 98 | 98 | azRepo[0] = zRepo; |
| 99 | 99 | azRepo[1] = mprintf("%s-journal", zRepo); |
| 100 | 100 | azRepo[2] = mprintf("%s-wal", zRepo); |
| 101 | 101 | azRepo[3] = mprintf("%s-shm", zRepo); |
| @@ -201,11 +201,11 @@ | ||
| 201 | 201 | const char *zReserved; /* Name of a reserved file */ |
| 202 | 202 | Blob repoName; /* Treename of the repository */ |
| 203 | 203 | Stmt loop; /* SQL to loop over all files to add */ |
| 204 | 204 | int (*xCmp)(const char*,const char*); |
| 205 | 205 | |
| 206 | - if( !file_tree_name(g.zRepositoryName, &repoName, 0) ){ | |
| 206 | + if( !file_tree_name(g.zRepositoryName, &repoName, 0, 0) ){ | |
| 207 | 207 | blob_zero(&repoName); |
| 208 | 208 | zRepo = ""; |
| 209 | 209 | }else{ |
| 210 | 210 | zRepo = blob_str(&repoName); |
| 211 | 211 | } |
| @@ -307,11 +307,11 @@ | ||
| 307 | 307 | int isDir; |
| 308 | 308 | Blob fullName; |
| 309 | 309 | |
| 310 | 310 | /* file_tree_name() throws a fatal error if g.argv[i] is outside of the |
| 311 | 311 | ** checkout. */ |
| 312 | - file_tree_name(g.argv[i], &fullName, 1); | |
| 312 | + file_tree_name(g.argv[i], &fullName, 0, 1); | |
| 313 | 313 | blob_reset(&fullName); |
| 314 | 314 | |
| 315 | 315 | file_canonical_name(g.argv[i], &fullName, 0); |
| 316 | 316 | zName = blob_str(&fullName); |
| 317 | 317 | isDir = file_wd_isdir(zName); |
| @@ -365,11 +365,11 @@ | ||
| 365 | 365 | if( !tableCreated ){ |
| 366 | 366 | db_multi_exec("CREATE TEMP TABLE fremove(x TEXT PRIMARY KEY %s)", |
| 367 | 367 | filename_collation()); |
| 368 | 368 | tableCreated = 1; |
| 369 | 369 | } |
| 370 | - file_canonical_name(zOldName, &fullOldName, 0); | |
| 370 | + file_tree_name(zOldName, &fullOldName, 1, 1); | |
| 371 | 371 | db_multi_exec("INSERT INTO fremove VALUES('%q');", blob_str(&fullOldName)); |
| 372 | 372 | blob_reset(&fullOldName); |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | /* |
| @@ -384,20 +384,22 @@ | ||
| 384 | 384 | */ |
| 385 | 385 | static void process_files_to_remove( |
| 386 | 386 | int dryRunFlag /* Zero to actually operate on the file-system. */ |
| 387 | 387 | ){ |
| 388 | 388 | Stmt remove; |
| 389 | - db_prepare(&remove, "SELECT x FROM fremove ORDER BY x;"); | |
| 390 | - while( db_step(&remove)==SQLITE_ROW ){ | |
| 391 | - const char *zOldName = db_column_text(&remove, 0); | |
| 392 | - if( !dryRunFlag ){ | |
| 393 | - file_delete(zOldName); | |
| 394 | - } | |
| 395 | - fossil_print("DELETED_FILE %s\n", zOldName); | |
| 396 | - } | |
| 397 | - db_finalize(&remove); | |
| 398 | - db_multi_exec("DROP TABLE fremove;"); | |
| 389 | + if( db_table_exists(db_name("temp"), "fremove") ){ | |
| 390 | + db_prepare(&remove, "SELECT x FROM fremove ORDER BY x;"); | |
| 391 | + while( db_step(&remove)==SQLITE_ROW ){ | |
| 392 | + const char *zOldName = db_column_text(&remove, 0); | |
| 393 | + if( !dryRunFlag ){ | |
| 394 | + file_delete(zOldName); | |
| 395 | + } | |
| 396 | + fossil_print("DELETED_FILE %s\n", zOldName); | |
| 397 | + } | |
| 398 | + db_finalize(&remove); | |
| 399 | + db_multi_exec("DROP TABLE fremove;"); | |
| 400 | + } | |
| 399 | 401 | } |
| 400 | 402 | |
| 401 | 403 | /* |
| 402 | 404 | ** COMMAND: rm |
| 403 | 405 | ** COMMAND: delete |
| @@ -464,11 +466,11 @@ | ||
| 464 | 466 | filename_collation()); |
| 465 | 467 | for(i=2; i<g.argc; i++){ |
| 466 | 468 | Blob treeName; |
| 467 | 469 | char *zTreeName; |
| 468 | 470 | |
| 469 | - file_tree_name(g.argv[i], &treeName, 1); | |
| 471 | + file_tree_name(g.argv[i], &treeName, 0, 1); | |
| 470 | 472 | zTreeName = blob_str(&treeName); |
| 471 | 473 | db_multi_exec( |
| 472 | 474 | "INSERT OR IGNORE INTO sfile" |
| 473 | 475 | " SELECT pathname FROM vfile" |
| 474 | 476 | " WHERE (pathname=%Q %s" |
| @@ -746,12 +748,12 @@ | ||
| 746 | 748 | if( !tableCreated ){ |
| 747 | 749 | db_multi_exec("CREATE TEMP TABLE fmove(x TEXT PRIMARY KEY %s, y TEXT %s)", |
| 748 | 750 | filename_collation(), filename_collation()); |
| 749 | 751 | tableCreated = 1; |
| 750 | 752 | } |
| 751 | - file_canonical_name(zOldName, &fullOldName, 0); | |
| 752 | - file_canonical_name(zNewName, &fullNewName, 0); | |
| 753 | + file_tree_name(zOldName, &fullOldName, 1, 1); | |
| 754 | + file_tree_name(zNewName, &fullNewName, 1, 1); | |
| 753 | 755 | db_multi_exec("INSERT INTO fmove VALUES('%q','%q');", |
| 754 | 756 | blob_str(&fullOldName), blob_str(&fullNewName)); |
| 755 | 757 | blob_reset(&fullNewName); |
| 756 | 758 | blob_reset(&fullOldName); |
| 757 | 759 | } |
| @@ -768,26 +770,28 @@ | ||
| 768 | 770 | */ |
| 769 | 771 | static void process_files_to_move( |
| 770 | 772 | int dryRunFlag /* Zero to actually operate on the file-system. */ |
| 771 | 773 | ){ |
| 772 | 774 | Stmt move; |
| 773 | - db_prepare(&move, "SELECT x, y FROM fmove ORDER BY x;"); | |
| 774 | - while( db_step(&move)==SQLITE_ROW ){ | |
| 775 | - const char *zOldName = db_column_text(&move, 0); | |
| 776 | - const char *zNewName = db_column_text(&move, 1); | |
| 777 | - if( !dryRunFlag ){ | |
| 778 | - if( file_wd_islink(zOldName) ){ | |
| 779 | - symlink_copy(zOldName, zNewName); | |
| 780 | - }else{ | |
| 781 | - file_copy(zOldName, zNewName); | |
| 782 | - } | |
| 783 | - file_delete(zOldName); | |
| 784 | - } | |
| 785 | - fossil_print("MOVED_FILE %s\n", zOldName); | |
| 786 | - } | |
| 787 | - db_finalize(&move); | |
| 788 | - db_multi_exec("DROP TABLE fmove;"); | |
| 775 | + if( db_table_exists(db_name("temp"), "fmove") ){ | |
| 776 | + db_prepare(&move, "SELECT x, y FROM fmove ORDER BY x;"); | |
| 777 | + while( db_step(&move)==SQLITE_ROW ){ | |
| 778 | + const char *zOldName = db_column_text(&move, 0); | |
| 779 | + const char *zNewName = db_column_text(&move, 1); | |
| 780 | + if( !dryRunFlag ){ | |
| 781 | + if( file_wd_islink(zOldName) ){ | |
| 782 | + symlink_copy(zOldName, zNewName); | |
| 783 | + }else{ | |
| 784 | + file_copy(zOldName, zNewName); | |
| 785 | + } | |
| 786 | + file_delete(zOldName); | |
| 787 | + } | |
| 788 | + fossil_print("MOVED_FILE %s\n", zOldName); | |
| 789 | + } | |
| 790 | + db_finalize(&move); | |
| 791 | + db_multi_exec("DROP TABLE fmove;"); | |
| 792 | + } | |
| 789 | 793 | } |
| 790 | 794 | |
| 791 | 795 | /* |
| 792 | 796 | ** COMMAND: mv |
| 793 | 797 | ** COMMAND: rename* |
| @@ -860,11 +864,11 @@ | ||
| 860 | 864 | moveFiles = db_get_boolean("mv-rm-files",0); |
| 861 | 865 | #else |
| 862 | 866 | moveFiles = FOSSIL_MV_RM_FILE; |
| 863 | 867 | #endif |
| 864 | 868 | } |
| 865 | - file_tree_name(zDest, &dest, 1); | |
| 869 | + file_tree_name(zDest, &dest, 0, 1); | |
| 866 | 870 | db_multi_exec( |
| 867 | 871 | "UPDATE vfile SET origname=pathname WHERE origname IS NULL;" |
| 868 | 872 | ); |
| 869 | 873 | db_multi_exec( |
| 870 | 874 | "CREATE TEMP TABLE mv(f TEXT UNIQUE ON CONFLICT IGNORE, t TEXT);" |
| @@ -872,11 +876,11 @@ | ||
| 872 | 876 | if( file_wd_isdir(zDest)!=1 ){ |
| 873 | 877 | Blob orig; |
| 874 | 878 | if( g.argc!=4 ){ |
| 875 | 879 | usage("OLDNAME NEWNAME"); |
| 876 | 880 | } |
| 877 | - file_tree_name(g.argv[2], &orig, 1); | |
| 881 | + file_tree_name(g.argv[2], &orig, 0, 1); | |
| 878 | 882 | db_multi_exec( |
| 879 | 883 | "INSERT INTO mv VALUES(%B,%B)", &orig, &dest |
| 880 | 884 | ); |
| 881 | 885 | }else{ |
| 882 | 886 | if( blob_eq(&dest, ".") ){ |
| @@ -886,11 +890,11 @@ | ||
| 886 | 890 | } |
| 887 | 891 | for(i=2; i<g.argc-1; i++){ |
| 888 | 892 | Blob orig; |
| 889 | 893 | char *zOrig; |
| 890 | 894 | int nOrig; |
| 891 | - file_tree_name(g.argv[i], &orig, 1); | |
| 895 | + file_tree_name(g.argv[i], &orig, 0, 1); | |
| 892 | 896 | zOrig = blob_str(&orig); |
| 893 | 897 | nOrig = blob_size(&orig); |
| 894 | 898 | db_prepare(&q, |
| 895 | 899 | "SELECT pathname FROM vfile" |
| 896 | 900 | " WHERE vid=%d" |
| 897 | 901 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -91,11 +91,11 @@ | |
| 91 | |
| 92 | if( cachedManifest == -1 ){ |
| 93 | Blob repo; |
| 94 | cachedManifest = db_get_boolean("manifest",0); |
| 95 | blob_zero(&repo); |
| 96 | if( file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| 97 | const char *zRepo = blob_str(&repo); |
| 98 | azRepo[0] = zRepo; |
| 99 | azRepo[1] = mprintf("%s-journal", zRepo); |
| 100 | azRepo[2] = mprintf("%s-wal", zRepo); |
| 101 | azRepo[3] = mprintf("%s-shm", zRepo); |
| @@ -201,11 +201,11 @@ | |
| 201 | const char *zReserved; /* Name of a reserved file */ |
| 202 | Blob repoName; /* Treename of the repository */ |
| 203 | Stmt loop; /* SQL to loop over all files to add */ |
| 204 | int (*xCmp)(const char*,const char*); |
| 205 | |
| 206 | if( !file_tree_name(g.zRepositoryName, &repoName, 0) ){ |
| 207 | blob_zero(&repoName); |
| 208 | zRepo = ""; |
| 209 | }else{ |
| 210 | zRepo = blob_str(&repoName); |
| 211 | } |
| @@ -307,11 +307,11 @@ | |
| 307 | int isDir; |
| 308 | Blob fullName; |
| 309 | |
| 310 | /* file_tree_name() throws a fatal error if g.argv[i] is outside of the |
| 311 | ** checkout. */ |
| 312 | file_tree_name(g.argv[i], &fullName, 1); |
| 313 | blob_reset(&fullName); |
| 314 | |
| 315 | file_canonical_name(g.argv[i], &fullName, 0); |
| 316 | zName = blob_str(&fullName); |
| 317 | isDir = file_wd_isdir(zName); |
| @@ -365,11 +365,11 @@ | |
| 365 | if( !tableCreated ){ |
| 366 | db_multi_exec("CREATE TEMP TABLE fremove(x TEXT PRIMARY KEY %s)", |
| 367 | filename_collation()); |
| 368 | tableCreated = 1; |
| 369 | } |
| 370 | file_canonical_name(zOldName, &fullOldName, 0); |
| 371 | db_multi_exec("INSERT INTO fremove VALUES('%q');", blob_str(&fullOldName)); |
| 372 | blob_reset(&fullOldName); |
| 373 | } |
| 374 | |
| 375 | /* |
| @@ -384,20 +384,22 @@ | |
| 384 | */ |
| 385 | static void process_files_to_remove( |
| 386 | int dryRunFlag /* Zero to actually operate on the file-system. */ |
| 387 | ){ |
| 388 | Stmt remove; |
| 389 | db_prepare(&remove, "SELECT x FROM fremove ORDER BY x;"); |
| 390 | while( db_step(&remove)==SQLITE_ROW ){ |
| 391 | const char *zOldName = db_column_text(&remove, 0); |
| 392 | if( !dryRunFlag ){ |
| 393 | file_delete(zOldName); |
| 394 | } |
| 395 | fossil_print("DELETED_FILE %s\n", zOldName); |
| 396 | } |
| 397 | db_finalize(&remove); |
| 398 | db_multi_exec("DROP TABLE fremove;"); |
| 399 | } |
| 400 | |
| 401 | /* |
| 402 | ** COMMAND: rm |
| 403 | ** COMMAND: delete |
| @@ -464,11 +466,11 @@ | |
| 464 | filename_collation()); |
| 465 | for(i=2; i<g.argc; i++){ |
| 466 | Blob treeName; |
| 467 | char *zTreeName; |
| 468 | |
| 469 | file_tree_name(g.argv[i], &treeName, 1); |
| 470 | zTreeName = blob_str(&treeName); |
| 471 | db_multi_exec( |
| 472 | "INSERT OR IGNORE INTO sfile" |
| 473 | " SELECT pathname FROM vfile" |
| 474 | " WHERE (pathname=%Q %s" |
| @@ -746,12 +748,12 @@ | |
| 746 | if( !tableCreated ){ |
| 747 | db_multi_exec("CREATE TEMP TABLE fmove(x TEXT PRIMARY KEY %s, y TEXT %s)", |
| 748 | filename_collation(), filename_collation()); |
| 749 | tableCreated = 1; |
| 750 | } |
| 751 | file_canonical_name(zOldName, &fullOldName, 0); |
| 752 | file_canonical_name(zNewName, &fullNewName, 0); |
| 753 | db_multi_exec("INSERT INTO fmove VALUES('%q','%q');", |
| 754 | blob_str(&fullOldName), blob_str(&fullNewName)); |
| 755 | blob_reset(&fullNewName); |
| 756 | blob_reset(&fullOldName); |
| 757 | } |
| @@ -768,26 +770,28 @@ | |
| 768 | */ |
| 769 | static void process_files_to_move( |
| 770 | int dryRunFlag /* Zero to actually operate on the file-system. */ |
| 771 | ){ |
| 772 | Stmt move; |
| 773 | db_prepare(&move, "SELECT x, y FROM fmove ORDER BY x;"); |
| 774 | while( db_step(&move)==SQLITE_ROW ){ |
| 775 | const char *zOldName = db_column_text(&move, 0); |
| 776 | const char *zNewName = db_column_text(&move, 1); |
| 777 | if( !dryRunFlag ){ |
| 778 | if( file_wd_islink(zOldName) ){ |
| 779 | symlink_copy(zOldName, zNewName); |
| 780 | }else{ |
| 781 | file_copy(zOldName, zNewName); |
| 782 | } |
| 783 | file_delete(zOldName); |
| 784 | } |
| 785 | fossil_print("MOVED_FILE %s\n", zOldName); |
| 786 | } |
| 787 | db_finalize(&move); |
| 788 | db_multi_exec("DROP TABLE fmove;"); |
| 789 | } |
| 790 | |
| 791 | /* |
| 792 | ** COMMAND: mv |
| 793 | ** COMMAND: rename* |
| @@ -860,11 +864,11 @@ | |
| 860 | moveFiles = db_get_boolean("mv-rm-files",0); |
| 861 | #else |
| 862 | moveFiles = FOSSIL_MV_RM_FILE; |
| 863 | #endif |
| 864 | } |
| 865 | file_tree_name(zDest, &dest, 1); |
| 866 | db_multi_exec( |
| 867 | "UPDATE vfile SET origname=pathname WHERE origname IS NULL;" |
| 868 | ); |
| 869 | db_multi_exec( |
| 870 | "CREATE TEMP TABLE mv(f TEXT UNIQUE ON CONFLICT IGNORE, t TEXT);" |
| @@ -872,11 +876,11 @@ | |
| 872 | if( file_wd_isdir(zDest)!=1 ){ |
| 873 | Blob orig; |
| 874 | if( g.argc!=4 ){ |
| 875 | usage("OLDNAME NEWNAME"); |
| 876 | } |
| 877 | file_tree_name(g.argv[2], &orig, 1); |
| 878 | db_multi_exec( |
| 879 | "INSERT INTO mv VALUES(%B,%B)", &orig, &dest |
| 880 | ); |
| 881 | }else{ |
| 882 | if( blob_eq(&dest, ".") ){ |
| @@ -886,11 +890,11 @@ | |
| 886 | } |
| 887 | for(i=2; i<g.argc-1; i++){ |
| 888 | Blob orig; |
| 889 | char *zOrig; |
| 890 | int nOrig; |
| 891 | file_tree_name(g.argv[i], &orig, 1); |
| 892 | zOrig = blob_str(&orig); |
| 893 | nOrig = blob_size(&orig); |
| 894 | db_prepare(&q, |
| 895 | "SELECT pathname FROM vfile" |
| 896 | " WHERE vid=%d" |
| 897 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -91,11 +91,11 @@ | |
| 91 | |
| 92 | if( cachedManifest == -1 ){ |
| 93 | Blob repo; |
| 94 | cachedManifest = db_get_boolean("manifest",0); |
| 95 | blob_zero(&repo); |
| 96 | if( file_tree_name(g.zRepositoryName, &repo, 0, 0) ){ |
| 97 | const char *zRepo = blob_str(&repo); |
| 98 | azRepo[0] = zRepo; |
| 99 | azRepo[1] = mprintf("%s-journal", zRepo); |
| 100 | azRepo[2] = mprintf("%s-wal", zRepo); |
| 101 | azRepo[3] = mprintf("%s-shm", zRepo); |
| @@ -201,11 +201,11 @@ | |
| 201 | const char *zReserved; /* Name of a reserved file */ |
| 202 | Blob repoName; /* Treename of the repository */ |
| 203 | Stmt loop; /* SQL to loop over all files to add */ |
| 204 | int (*xCmp)(const char*,const char*); |
| 205 | |
| 206 | if( !file_tree_name(g.zRepositoryName, &repoName, 0, 0) ){ |
| 207 | blob_zero(&repoName); |
| 208 | zRepo = ""; |
| 209 | }else{ |
| 210 | zRepo = blob_str(&repoName); |
| 211 | } |
| @@ -307,11 +307,11 @@ | |
| 307 | int isDir; |
| 308 | Blob fullName; |
| 309 | |
| 310 | /* file_tree_name() throws a fatal error if g.argv[i] is outside of the |
| 311 | ** checkout. */ |
| 312 | file_tree_name(g.argv[i], &fullName, 0, 1); |
| 313 | blob_reset(&fullName); |
| 314 | |
| 315 | file_canonical_name(g.argv[i], &fullName, 0); |
| 316 | zName = blob_str(&fullName); |
| 317 | isDir = file_wd_isdir(zName); |
| @@ -365,11 +365,11 @@ | |
| 365 | if( !tableCreated ){ |
| 366 | db_multi_exec("CREATE TEMP TABLE fremove(x TEXT PRIMARY KEY %s)", |
| 367 | filename_collation()); |
| 368 | tableCreated = 1; |
| 369 | } |
| 370 | file_tree_name(zOldName, &fullOldName, 1, 1); |
| 371 | db_multi_exec("INSERT INTO fremove VALUES('%q');", blob_str(&fullOldName)); |
| 372 | blob_reset(&fullOldName); |
| 373 | } |
| 374 | |
| 375 | /* |
| @@ -384,20 +384,22 @@ | |
| 384 | */ |
| 385 | static void process_files_to_remove( |
| 386 | int dryRunFlag /* Zero to actually operate on the file-system. */ |
| 387 | ){ |
| 388 | Stmt remove; |
| 389 | if( db_table_exists(db_name("temp"), "fremove") ){ |
| 390 | db_prepare(&remove, "SELECT x FROM fremove ORDER BY x;"); |
| 391 | while( db_step(&remove)==SQLITE_ROW ){ |
| 392 | const char *zOldName = db_column_text(&remove, 0); |
| 393 | if( !dryRunFlag ){ |
| 394 | file_delete(zOldName); |
| 395 | } |
| 396 | fossil_print("DELETED_FILE %s\n", zOldName); |
| 397 | } |
| 398 | db_finalize(&remove); |
| 399 | db_multi_exec("DROP TABLE fremove;"); |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | /* |
| 404 | ** COMMAND: rm |
| 405 | ** COMMAND: delete |
| @@ -464,11 +466,11 @@ | |
| 466 | filename_collation()); |
| 467 | for(i=2; i<g.argc; i++){ |
| 468 | Blob treeName; |
| 469 | char *zTreeName; |
| 470 | |
| 471 | file_tree_name(g.argv[i], &treeName, 0, 1); |
| 472 | zTreeName = blob_str(&treeName); |
| 473 | db_multi_exec( |
| 474 | "INSERT OR IGNORE INTO sfile" |
| 475 | " SELECT pathname FROM vfile" |
| 476 | " WHERE (pathname=%Q %s" |
| @@ -746,12 +748,12 @@ | |
| 748 | if( !tableCreated ){ |
| 749 | db_multi_exec("CREATE TEMP TABLE fmove(x TEXT PRIMARY KEY %s, y TEXT %s)", |
| 750 | filename_collation(), filename_collation()); |
| 751 | tableCreated = 1; |
| 752 | } |
| 753 | file_tree_name(zOldName, &fullOldName, 1, 1); |
| 754 | file_tree_name(zNewName, &fullNewName, 1, 1); |
| 755 | db_multi_exec("INSERT INTO fmove VALUES('%q','%q');", |
| 756 | blob_str(&fullOldName), blob_str(&fullNewName)); |
| 757 | blob_reset(&fullNewName); |
| 758 | blob_reset(&fullOldName); |
| 759 | } |
| @@ -768,26 +770,28 @@ | |
| 770 | */ |
| 771 | static void process_files_to_move( |
| 772 | int dryRunFlag /* Zero to actually operate on the file-system. */ |
| 773 | ){ |
| 774 | Stmt move; |
| 775 | if( db_table_exists(db_name("temp"), "fmove") ){ |
| 776 | db_prepare(&move, "SELECT x, y FROM fmove ORDER BY x;"); |
| 777 | while( db_step(&move)==SQLITE_ROW ){ |
| 778 | const char *zOldName = db_column_text(&move, 0); |
| 779 | const char *zNewName = db_column_text(&move, 1); |
| 780 | if( !dryRunFlag ){ |
| 781 | if( file_wd_islink(zOldName) ){ |
| 782 | symlink_copy(zOldName, zNewName); |
| 783 | }else{ |
| 784 | file_copy(zOldName, zNewName); |
| 785 | } |
| 786 | file_delete(zOldName); |
| 787 | } |
| 788 | fossil_print("MOVED_FILE %s\n", zOldName); |
| 789 | } |
| 790 | db_finalize(&move); |
| 791 | db_multi_exec("DROP TABLE fmove;"); |
| 792 | } |
| 793 | } |
| 794 | |
| 795 | /* |
| 796 | ** COMMAND: mv |
| 797 | ** COMMAND: rename* |
| @@ -860,11 +864,11 @@ | |
| 864 | moveFiles = db_get_boolean("mv-rm-files",0); |
| 865 | #else |
| 866 | moveFiles = FOSSIL_MV_RM_FILE; |
| 867 | #endif |
| 868 | } |
| 869 | file_tree_name(zDest, &dest, 0, 1); |
| 870 | db_multi_exec( |
| 871 | "UPDATE vfile SET origname=pathname WHERE origname IS NULL;" |
| 872 | ); |
| 873 | db_multi_exec( |
| 874 | "CREATE TEMP TABLE mv(f TEXT UNIQUE ON CONFLICT IGNORE, t TEXT);" |
| @@ -872,11 +876,11 @@ | |
| 876 | if( file_wd_isdir(zDest)!=1 ){ |
| 877 | Blob orig; |
| 878 | if( g.argc!=4 ){ |
| 879 | usage("OLDNAME NEWNAME"); |
| 880 | } |
| 881 | file_tree_name(g.argv[2], &orig, 0, 1); |
| 882 | db_multi_exec( |
| 883 | "INSERT INTO mv VALUES(%B,%B)", &orig, &dest |
| 884 | ); |
| 885 | }else{ |
| 886 | if( blob_eq(&dest, ".") ){ |
| @@ -886,11 +890,11 @@ | |
| 890 | } |
| 891 | for(i=2; i<g.argc-1; i++){ |
| 892 | Blob orig; |
| 893 | char *zOrig; |
| 894 | int nOrig; |
| 895 | file_tree_name(g.argv[i], &orig, 0, 1); |
| 896 | zOrig = blob_str(&orig); |
| 897 | nOrig = blob_size(&orig); |
| 898 | db_prepare(&q, |
| 899 | "SELECT pathname FROM vfile" |
| 900 | " WHERE vid=%d" |
| 901 |
+5
-5
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -46,11 +46,11 @@ | ||
| 46 | 46 | int i; |
| 47 | 47 | |
| 48 | 48 | blob_zero(&where); |
| 49 | 49 | for(i=2; i<g.argc; i++){ |
| 50 | 50 | Blob fname; |
| 51 | - file_tree_name(g.argv[i], &fname, 1); | |
| 51 | + file_tree_name(g.argv[i], &fname, 0, 1); | |
| 52 | 52 | zName = blob_str(&fname); |
| 53 | 53 | if( fossil_strcmp(zName, ".")==0 ){ |
| 54 | 54 | blob_reset(&where); |
| 55 | 55 | break; |
| 56 | 56 | } |
| @@ -296,11 +296,11 @@ | ||
| 296 | 296 | |
| 297 | 297 | /* Handle given file names */ |
| 298 | 298 | blob_zero(&where); |
| 299 | 299 | for(i=2; i<g.argc; i++){ |
| 300 | 300 | Blob fname; |
| 301 | - file_tree_name(g.argv[i], &fname, 1); | |
| 301 | + file_tree_name(g.argv[i], &fname, 0, 1); | |
| 302 | 302 | zName = blob_str(&fname); |
| 303 | 303 | if( fossil_strcmp(zName, ".")==0 ){ |
| 304 | 304 | blob_reset(&where); |
| 305 | 305 | break; |
| 306 | 306 | } |
| @@ -409,11 +409,11 @@ | ||
| 409 | 409 | } |
| 410 | 410 | verify_all_options(); |
| 411 | 411 | blob_zero(&where); |
| 412 | 412 | for(i=2; i<g.argc; i++){ |
| 413 | 413 | Blob fname; |
| 414 | - file_tree_name(g.argv[i], &fname, 1); | |
| 414 | + file_tree_name(g.argv[i], &fname, 0, 1); | |
| 415 | 415 | zName = blob_str(&fname); |
| 416 | 416 | if( fossil_strcmp(zName, ".")==0 ){ |
| 417 | 417 | blob_reset(&where); |
| 418 | 418 | break; |
| 419 | 419 | } |
| @@ -741,11 +741,11 @@ | ||
| 741 | 741 | "SELECT %Q || x FROM sfile" |
| 742 | 742 | " WHERE x NOT IN (%s)" |
| 743 | 743 | " ORDER BY 1", |
| 744 | 744 | g.zLocalRoot, fossil_all_reserved_names(0) |
| 745 | 745 | ); |
| 746 | - if( file_tree_name(g.zRepositoryName, &repo, 0) ){ | |
| 746 | + if( file_tree_name(g.zRepositoryName, &repo, 0, 0) ){ | |
| 747 | 747 | db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); |
| 748 | 748 | } |
| 749 | 749 | db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)"); |
| 750 | 750 | while( db_step(&q)==SQLITE_ROW ){ |
| 751 | 751 | const char *zName = db_column_text(&q, 0); |
| @@ -1037,11 +1037,11 @@ | ||
| 1037 | 1037 | |
| 1038 | 1038 | blob_zero(&fname); |
| 1039 | 1039 | bag_init(&toCommit); |
| 1040 | 1040 | for(ii=2; ii<g.argc; ii++){ |
| 1041 | 1041 | int cnt = 0; |
| 1042 | - file_tree_name(g.argv[ii], &fname, 1); | |
| 1042 | + file_tree_name(g.argv[ii], &fname, 0, 1); | |
| 1043 | 1043 | if( fossil_strcmp(blob_str(&fname),".")==0 ){ |
| 1044 | 1044 | bag_clear(&toCommit); |
| 1045 | 1045 | return result; |
| 1046 | 1046 | } |
| 1047 | 1047 | db_prepare(&q, |
| 1048 | 1048 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -46,11 +46,11 @@ | |
| 46 | int i; |
| 47 | |
| 48 | blob_zero(&where); |
| 49 | for(i=2; i<g.argc; i++){ |
| 50 | Blob fname; |
| 51 | file_tree_name(g.argv[i], &fname, 1); |
| 52 | zName = blob_str(&fname); |
| 53 | if( fossil_strcmp(zName, ".")==0 ){ |
| 54 | blob_reset(&where); |
| 55 | break; |
| 56 | } |
| @@ -296,11 +296,11 @@ | |
| 296 | |
| 297 | /* Handle given file names */ |
| 298 | blob_zero(&where); |
| 299 | for(i=2; i<g.argc; i++){ |
| 300 | Blob fname; |
| 301 | file_tree_name(g.argv[i], &fname, 1); |
| 302 | zName = blob_str(&fname); |
| 303 | if( fossil_strcmp(zName, ".")==0 ){ |
| 304 | blob_reset(&where); |
| 305 | break; |
| 306 | } |
| @@ -409,11 +409,11 @@ | |
| 409 | } |
| 410 | verify_all_options(); |
| 411 | blob_zero(&where); |
| 412 | for(i=2; i<g.argc; i++){ |
| 413 | Blob fname; |
| 414 | file_tree_name(g.argv[i], &fname, 1); |
| 415 | zName = blob_str(&fname); |
| 416 | if( fossil_strcmp(zName, ".")==0 ){ |
| 417 | blob_reset(&where); |
| 418 | break; |
| 419 | } |
| @@ -741,11 +741,11 @@ | |
| 741 | "SELECT %Q || x FROM sfile" |
| 742 | " WHERE x NOT IN (%s)" |
| 743 | " ORDER BY 1", |
| 744 | g.zLocalRoot, fossil_all_reserved_names(0) |
| 745 | ); |
| 746 | if( file_tree_name(g.zRepositoryName, &repo, 0) ){ |
| 747 | db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); |
| 748 | } |
| 749 | db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)"); |
| 750 | while( db_step(&q)==SQLITE_ROW ){ |
| 751 | const char *zName = db_column_text(&q, 0); |
| @@ -1037,11 +1037,11 @@ | |
| 1037 | |
| 1038 | blob_zero(&fname); |
| 1039 | bag_init(&toCommit); |
| 1040 | for(ii=2; ii<g.argc; ii++){ |
| 1041 | int cnt = 0; |
| 1042 | file_tree_name(g.argv[ii], &fname, 1); |
| 1043 | if( fossil_strcmp(blob_str(&fname),".")==0 ){ |
| 1044 | bag_clear(&toCommit); |
| 1045 | return result; |
| 1046 | } |
| 1047 | db_prepare(&q, |
| 1048 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -46,11 +46,11 @@ | |
| 46 | int i; |
| 47 | |
| 48 | blob_zero(&where); |
| 49 | for(i=2; i<g.argc; i++){ |
| 50 | Blob fname; |
| 51 | file_tree_name(g.argv[i], &fname, 0, 1); |
| 52 | zName = blob_str(&fname); |
| 53 | if( fossil_strcmp(zName, ".")==0 ){ |
| 54 | blob_reset(&where); |
| 55 | break; |
| 56 | } |
| @@ -296,11 +296,11 @@ | |
| 296 | |
| 297 | /* Handle given file names */ |
| 298 | blob_zero(&where); |
| 299 | for(i=2; i<g.argc; i++){ |
| 300 | Blob fname; |
| 301 | file_tree_name(g.argv[i], &fname, 0, 1); |
| 302 | zName = blob_str(&fname); |
| 303 | if( fossil_strcmp(zName, ".")==0 ){ |
| 304 | blob_reset(&where); |
| 305 | break; |
| 306 | } |
| @@ -409,11 +409,11 @@ | |
| 409 | } |
| 410 | verify_all_options(); |
| 411 | blob_zero(&where); |
| 412 | for(i=2; i<g.argc; i++){ |
| 413 | Blob fname; |
| 414 | file_tree_name(g.argv[i], &fname, 0, 1); |
| 415 | zName = blob_str(&fname); |
| 416 | if( fossil_strcmp(zName, ".")==0 ){ |
| 417 | blob_reset(&where); |
| 418 | break; |
| 419 | } |
| @@ -741,11 +741,11 @@ | |
| 741 | "SELECT %Q || x FROM sfile" |
| 742 | " WHERE x NOT IN (%s)" |
| 743 | " ORDER BY 1", |
| 744 | g.zLocalRoot, fossil_all_reserved_names(0) |
| 745 | ); |
| 746 | if( file_tree_name(g.zRepositoryName, &repo, 0, 0) ){ |
| 747 | db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo); |
| 748 | } |
| 749 | db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)"); |
| 750 | while( db_step(&q)==SQLITE_ROW ){ |
| 751 | const char *zName = db_column_text(&q, 0); |
| @@ -1037,11 +1037,11 @@ | |
| 1037 | |
| 1038 | blob_zero(&fname); |
| 1039 | bag_init(&toCommit); |
| 1040 | for(ii=2; ii<g.argc; ii++){ |
| 1041 | int cnt = 0; |
| 1042 | file_tree_name(g.argv[ii], &fname, 0, 1); |
| 1043 | if( fossil_strcmp(blob_str(&fname),".")==0 ){ |
| 1044 | bag_clear(&toCommit); |
| 1045 | return result; |
| 1046 | } |
| 1047 | db_prepare(&q, |
| 1048 |
M
src/db.c
+2
-1
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1258,11 +1258,12 @@ | ||
| 1258 | 1258 | ** Return the name of the database "localdb", "configdb", or "repository". |
| 1259 | 1259 | */ |
| 1260 | 1260 | const char *db_name(const char *zDb){ |
| 1261 | 1261 | assert( fossil_strcmp(zDb,"localdb")==0 |
| 1262 | 1262 | || fossil_strcmp(zDb,"configdb")==0 |
| 1263 | - || fossil_strcmp(zDb,"repository")==0 ); | |
| 1263 | + || fossil_strcmp(zDb,"repository")==0 | |
| 1264 | + || fossil_strcmp(zDb,"temp")==0 ); | |
| 1264 | 1265 | if( fossil_strcmp(zDb, g.zMainDbType)==0 ) zDb = "main"; |
| 1265 | 1266 | return zDb; |
| 1266 | 1267 | } |
| 1267 | 1268 | |
| 1268 | 1269 | /* |
| 1269 | 1270 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1258,11 +1258,12 @@ | |
| 1258 | ** Return the name of the database "localdb", "configdb", or "repository". |
| 1259 | */ |
| 1260 | const char *db_name(const char *zDb){ |
| 1261 | assert( fossil_strcmp(zDb,"localdb")==0 |
| 1262 | || fossil_strcmp(zDb,"configdb")==0 |
| 1263 | || fossil_strcmp(zDb,"repository")==0 ); |
| 1264 | if( fossil_strcmp(zDb, g.zMainDbType)==0 ) zDb = "main"; |
| 1265 | return zDb; |
| 1266 | } |
| 1267 | |
| 1268 | /* |
| 1269 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1258,11 +1258,12 @@ | |
| 1258 | ** Return the name of the database "localdb", "configdb", or "repository". |
| 1259 | */ |
| 1260 | const char *db_name(const char *zDb){ |
| 1261 | assert( fossil_strcmp(zDb,"localdb")==0 |
| 1262 | || fossil_strcmp(zDb,"configdb")==0 |
| 1263 | || fossil_strcmp(zDb,"repository")==0 |
| 1264 | || fossil_strcmp(zDb,"temp")==0 ); |
| 1265 | if( fossil_strcmp(zDb, g.zMainDbType)==0 ) zDb = "main"; |
| 1266 | return zDb; |
| 1267 | } |
| 1268 | |
| 1269 | /* |
| 1270 |
+1
-1
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -2457,11 +2457,11 @@ | ||
| 2457 | 2457 | verify_all_options(); |
| 2458 | 2458 | |
| 2459 | 2459 | if( g.argc<3 ) { |
| 2460 | 2460 | usage("FILENAME"); |
| 2461 | 2461 | } |
| 2462 | - file_tree_name(g.argv[2], &treename, 1); | |
| 2462 | + file_tree_name(g.argv[2], &treename, 0, 1); | |
| 2463 | 2463 | zFilename = blob_str(&treename); |
| 2464 | 2464 | fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename); |
| 2465 | 2465 | if( fnid==0 ){ |
| 2466 | 2466 | fossil_fatal("no such file: %s", zFilename); |
| 2467 | 2467 | } |
| 2468 | 2468 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -2457,11 +2457,11 @@ | |
| 2457 | verify_all_options(); |
| 2458 | |
| 2459 | if( g.argc<3 ) { |
| 2460 | usage("FILENAME"); |
| 2461 | } |
| 2462 | file_tree_name(g.argv[2], &treename, 1); |
| 2463 | zFilename = blob_str(&treename); |
| 2464 | fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename); |
| 2465 | if( fnid==0 ){ |
| 2466 | fossil_fatal("no such file: %s", zFilename); |
| 2467 | } |
| 2468 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -2457,11 +2457,11 @@ | |
| 2457 | verify_all_options(); |
| 2458 | |
| 2459 | if( g.argc<3 ) { |
| 2460 | usage("FILENAME"); |
| 2461 | } |
| 2462 | file_tree_name(g.argv[2], &treename, 0, 1); |
| 2463 | zFilename = blob_str(&treename); |
| 2464 | fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename); |
| 2465 | if( fnid==0 ){ |
| 2466 | fossil_fatal("no such file: %s", zFilename); |
| 2467 | } |
| 2468 |
+2
-2
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -298,11 +298,11 @@ | ||
| 298 | 298 | ){ |
| 299 | 299 | Blob fname; |
| 300 | 300 | Blob content; |
| 301 | 301 | int isLink; |
| 302 | 302 | int isBin; |
| 303 | - file_tree_name(zFileTreeName, &fname, 1); | |
| 303 | + file_tree_name(zFileTreeName, &fname, 0, 1); | |
| 304 | 304 | historical_version_of_file(zFrom, blob_str(&fname), &content, &isLink, 0, |
| 305 | 305 | fIncludeBinary ? 0 : &isBin, 0); |
| 306 | 306 | if( !isLink != !file_wd_islink(zFrom) ){ |
| 307 | 307 | fossil_print("%s",DIFF_CANNOT_COMPUTE_SYMLINK); |
| 308 | 308 | }else{ |
| @@ -454,11 +454,11 @@ | ||
| 454 | 454 | Blob fname; |
| 455 | 455 | Blob v1, v2; |
| 456 | 456 | int isLink1, isLink2; |
| 457 | 457 | int isBin1, isBin2; |
| 458 | 458 | if( diffFlags & DIFF_BRIEF ) return; |
| 459 | - file_tree_name(zFileTreeName, &fname, 1); | |
| 459 | + file_tree_name(zFileTreeName, &fname, 0, 1); | |
| 460 | 460 | zName = blob_str(&fname); |
| 461 | 461 | historical_version_of_file(zFrom, zName, &v1, &isLink1, 0, |
| 462 | 462 | fIncludeBinary ? 0 : &isBin1, 0); |
| 463 | 463 | historical_version_of_file(zTo, zName, &v2, &isLink2, 0, |
| 464 | 464 | fIncludeBinary ? 0 : &isBin2, 0); |
| 465 | 465 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -298,11 +298,11 @@ | |
| 298 | ){ |
| 299 | Blob fname; |
| 300 | Blob content; |
| 301 | int isLink; |
| 302 | int isBin; |
| 303 | file_tree_name(zFileTreeName, &fname, 1); |
| 304 | historical_version_of_file(zFrom, blob_str(&fname), &content, &isLink, 0, |
| 305 | fIncludeBinary ? 0 : &isBin, 0); |
| 306 | if( !isLink != !file_wd_islink(zFrom) ){ |
| 307 | fossil_print("%s",DIFF_CANNOT_COMPUTE_SYMLINK); |
| 308 | }else{ |
| @@ -454,11 +454,11 @@ | |
| 454 | Blob fname; |
| 455 | Blob v1, v2; |
| 456 | int isLink1, isLink2; |
| 457 | int isBin1, isBin2; |
| 458 | if( diffFlags & DIFF_BRIEF ) return; |
| 459 | file_tree_name(zFileTreeName, &fname, 1); |
| 460 | zName = blob_str(&fname); |
| 461 | historical_version_of_file(zFrom, zName, &v1, &isLink1, 0, |
| 462 | fIncludeBinary ? 0 : &isBin1, 0); |
| 463 | historical_version_of_file(zTo, zName, &v2, &isLink2, 0, |
| 464 | fIncludeBinary ? 0 : &isBin2, 0); |
| 465 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -298,11 +298,11 @@ | |
| 298 | ){ |
| 299 | Blob fname; |
| 300 | Blob content; |
| 301 | int isLink; |
| 302 | int isBin; |
| 303 | file_tree_name(zFileTreeName, &fname, 0, 1); |
| 304 | historical_version_of_file(zFrom, blob_str(&fname), &content, &isLink, 0, |
| 305 | fIncludeBinary ? 0 : &isBin, 0); |
| 306 | if( !isLink != !file_wd_islink(zFrom) ){ |
| 307 | fossil_print("%s",DIFF_CANNOT_COMPUTE_SYMLINK); |
| 308 | }else{ |
| @@ -454,11 +454,11 @@ | |
| 454 | Blob fname; |
| 455 | Blob v1, v2; |
| 456 | int isLink1, isLink2; |
| 457 | int isBin1, isBin2; |
| 458 | if( diffFlags & DIFF_BRIEF ) return; |
| 459 | file_tree_name(zFileTreeName, &fname, 0, 1); |
| 460 | zName = blob_str(&fname); |
| 461 | historical_version_of_file(zFrom, zName, &v1, &isLink1, 0, |
| 462 | fIncludeBinary ? 0 : &isBin1, 0); |
| 463 | historical_version_of_file(zTo, zName, &v2, &isLink2, 0, |
| 464 | fIncludeBinary ? 0 : &isBin2, 0); |
| 465 |
+53
-12
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -1029,18 +1029,25 @@ | ||
| 1029 | 1029 | blob_reset(&x); |
| 1030 | 1030 | } |
| 1031 | 1031 | } |
| 1032 | 1032 | |
| 1033 | 1033 | /* |
| 1034 | -** Compute a pathname for a file relative to the root of the local | |
| 1035 | -** tree. Return TRUE on success. On failure, print and error | |
| 1036 | -** message and quit if the errFatal flag is true. If errFatal is | |
| 1037 | -** false, then simply return 0. | |
| 1038 | -** | |
| 1039 | -** The root of the tree is defined by the g.zLocalRoot variable. | |
| 1034 | +** Compute a full path name for a file in the local tree. If | |
| 1035 | +** the absolute flag is non-zero, the computed path will be | |
| 1036 | +** absolute, starting with the root path of the local tree; | |
| 1037 | +** otherwise, it will be relative to the root of the local | |
| 1038 | +** tree. In both cases, the root of the local tree is defined | |
| 1039 | +** by the g.zLocalRoot variable. Return TRUE on success. On | |
| 1040 | +** failure, print and error message and quit if the errFatal | |
| 1041 | +** flag is true. If errFatal is false, then simply return 0. | |
| 1040 | 1042 | */ |
| 1041 | -int file_tree_name(const char *zOrigName, Blob *pOut, int errFatal){ | |
| 1043 | +int file_tree_name( | |
| 1044 | + const char *zOrigName, | |
| 1045 | + Blob *pOut, | |
| 1046 | + int absolute, | |
| 1047 | + int errFatal | |
| 1048 | +){ | |
| 1042 | 1049 | Blob localRoot; |
| 1043 | 1050 | int nLocalRoot; |
| 1044 | 1051 | char *zLocalRoot; |
| 1045 | 1052 | Blob full; |
| 1046 | 1053 | int nFull; |
| @@ -1047,12 +1054,31 @@ | ||
| 1047 | 1054 | char *zFull; |
| 1048 | 1055 | int (*xCmp)(const char*,const char*,int); |
| 1049 | 1056 | |
| 1050 | 1057 | blob_zero(pOut); |
| 1051 | 1058 | if( !g.localOpen ){ |
| 1052 | - blob_appendf(pOut, "%s", zOrigName); | |
| 1053 | - return 1; | |
| 1059 | + if( absolute && !file_is_absolute_path(zOrigName) ){ | |
| 1060 | + if( errFatal ){ | |
| 1061 | + fossil_fatal("relative to absolute needs open checkout tree: %s", | |
| 1062 | + zOrigName); | |
| 1063 | + } | |
| 1064 | + return 0; | |
| 1065 | + }else{ | |
| 1066 | + /* | |
| 1067 | + ** The original path may be relative or absolute; however, without | |
| 1068 | + ** an open checkout tree, the only things we can do at this point | |
| 1069 | + ** is return it verbatim or generate a fatal error. The caller is | |
| 1070 | + ** probably expecting a tree-relative path name will be returned; | |
| 1071 | + ** however, most places where this function is called already check | |
| 1072 | + ** if the local checkout tree is open, either directly or indirectly, | |
| 1073 | + ** which would make this situation impossible. Alternatively, they | |
| 1074 | + ** could check the returned path using the file_is_absolute_path() | |
| 1075 | + ** function. | |
| 1076 | + */ | |
| 1077 | + blob_appendf(pOut, "%s", zOrigName); | |
| 1078 | + return 1; | |
| 1079 | + } | |
| 1054 | 1080 | } |
| 1055 | 1081 | file_canonical_name(g.zLocalRoot, &localRoot, 1); |
| 1056 | 1082 | nLocalRoot = blob_size(&localRoot); |
| 1057 | 1083 | zLocalRoot = blob_buffer(&localRoot); |
| 1058 | 1084 | assert( nLocalRoot>0 && zLocalRoot[nLocalRoot-1]=='/' ); |
| @@ -1066,11 +1092,15 @@ | ||
| 1066 | 1092 | } |
| 1067 | 1093 | |
| 1068 | 1094 | /* Special case. zOrigName refers to g.zLocalRoot directory. */ |
| 1069 | 1095 | if( (nFull==nLocalRoot-1 && xCmp(zLocalRoot, zFull, nFull)==0) |
| 1070 | 1096 | || (nFull==1 && zFull[0]=='/' && nLocalRoot==1 && zLocalRoot[0]=='/') ){ |
| 1071 | - blob_append(pOut, ".", 1); | |
| 1097 | + if( absolute ){ | |
| 1098 | + blob_append(pOut, zLocalRoot, nLocalRoot); | |
| 1099 | + }else{ | |
| 1100 | + blob_append(pOut, ".", 1); | |
| 1101 | + } | |
| 1072 | 1102 | blob_reset(&localRoot); |
| 1073 | 1103 | blob_reset(&full); |
| 1074 | 1104 | return 1; |
| 1075 | 1105 | } |
| 1076 | 1106 | |
| @@ -1080,11 +1110,20 @@ | ||
| 1080 | 1110 | if( errFatal ){ |
| 1081 | 1111 | fossil_fatal("file outside of checkout tree: %s", zOrigName); |
| 1082 | 1112 | } |
| 1083 | 1113 | return 0; |
| 1084 | 1114 | } |
| 1085 | - blob_append(pOut, &zFull[nLocalRoot], nFull-nLocalRoot); | |
| 1115 | + if( absolute ){ | |
| 1116 | + if( !file_is_absolute_path(zOrigName) ){ | |
| 1117 | + blob_append(pOut, zLocalRoot, nLocalRoot); | |
| 1118 | + } | |
| 1119 | + blob_append(pOut, zOrigName, -1); | |
| 1120 | + blob_resize(pOut, file_simplify_name(blob_buffer(pOut), | |
| 1121 | + blob_size(pOut), 0)); | |
| 1122 | + }else{ | |
| 1123 | + blob_append(pOut, &zFull[nLocalRoot], nFull-nLocalRoot); | |
| 1124 | + } | |
| 1086 | 1125 | blob_reset(&localRoot); |
| 1087 | 1126 | blob_reset(&full); |
| 1088 | 1127 | return 1; |
| 1089 | 1128 | } |
| 1090 | 1129 | |
| @@ -1092,20 +1131,22 @@ | ||
| 1092 | 1131 | ** COMMAND: test-tree-name |
| 1093 | 1132 | ** |
| 1094 | 1133 | ** Test the operation of the tree name generator. |
| 1095 | 1134 | ** |
| 1096 | 1135 | ** Options: |
| 1136 | +** --absolute Return an absolute path instead of a relative one. | |
| 1097 | 1137 | ** --case-sensitive B Enable or disable case-sensitive filenames. B is |
| 1098 | 1138 | ** a boolean: "yes", "no", "true", "false", etc. |
| 1099 | 1139 | */ |
| 1100 | 1140 | void cmd_test_tree_name(void){ |
| 1101 | 1141 | int i; |
| 1102 | 1142 | Blob x; |
| 1143 | + int absoluteFlag = find_option("absolute",0,0)!=0; | |
| 1103 | 1144 | db_find_and_open_repository(0,0); |
| 1104 | 1145 | blob_zero(&x); |
| 1105 | 1146 | for(i=2; i<g.argc; i++){ |
| 1106 | - if( file_tree_name(g.argv[i], &x, 1) ){ | |
| 1147 | + if( file_tree_name(g.argv[i], &x, absoluteFlag, 1) ){ | |
| 1107 | 1148 | fossil_print("%s\n", blob_buffer(&x)); |
| 1108 | 1149 | blob_reset(&x); |
| 1109 | 1150 | } |
| 1110 | 1151 | } |
| 1111 | 1152 | } |
| 1112 | 1153 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -1029,18 +1029,25 @@ | |
| 1029 | blob_reset(&x); |
| 1030 | } |
| 1031 | } |
| 1032 | |
| 1033 | /* |
| 1034 | ** Compute a pathname for a file relative to the root of the local |
| 1035 | ** tree. Return TRUE on success. On failure, print and error |
| 1036 | ** message and quit if the errFatal flag is true. If errFatal is |
| 1037 | ** false, then simply return 0. |
| 1038 | ** |
| 1039 | ** The root of the tree is defined by the g.zLocalRoot variable. |
| 1040 | */ |
| 1041 | int file_tree_name(const char *zOrigName, Blob *pOut, int errFatal){ |
| 1042 | Blob localRoot; |
| 1043 | int nLocalRoot; |
| 1044 | char *zLocalRoot; |
| 1045 | Blob full; |
| 1046 | int nFull; |
| @@ -1047,12 +1054,31 @@ | |
| 1047 | char *zFull; |
| 1048 | int (*xCmp)(const char*,const char*,int); |
| 1049 | |
| 1050 | blob_zero(pOut); |
| 1051 | if( !g.localOpen ){ |
| 1052 | blob_appendf(pOut, "%s", zOrigName); |
| 1053 | return 1; |
| 1054 | } |
| 1055 | file_canonical_name(g.zLocalRoot, &localRoot, 1); |
| 1056 | nLocalRoot = blob_size(&localRoot); |
| 1057 | zLocalRoot = blob_buffer(&localRoot); |
| 1058 | assert( nLocalRoot>0 && zLocalRoot[nLocalRoot-1]=='/' ); |
| @@ -1066,11 +1092,15 @@ | |
| 1066 | } |
| 1067 | |
| 1068 | /* Special case. zOrigName refers to g.zLocalRoot directory. */ |
| 1069 | if( (nFull==nLocalRoot-1 && xCmp(zLocalRoot, zFull, nFull)==0) |
| 1070 | || (nFull==1 && zFull[0]=='/' && nLocalRoot==1 && zLocalRoot[0]=='/') ){ |
| 1071 | blob_append(pOut, ".", 1); |
| 1072 | blob_reset(&localRoot); |
| 1073 | blob_reset(&full); |
| 1074 | return 1; |
| 1075 | } |
| 1076 | |
| @@ -1080,11 +1110,20 @@ | |
| 1080 | if( errFatal ){ |
| 1081 | fossil_fatal("file outside of checkout tree: %s", zOrigName); |
| 1082 | } |
| 1083 | return 0; |
| 1084 | } |
| 1085 | blob_append(pOut, &zFull[nLocalRoot], nFull-nLocalRoot); |
| 1086 | blob_reset(&localRoot); |
| 1087 | blob_reset(&full); |
| 1088 | return 1; |
| 1089 | } |
| 1090 | |
| @@ -1092,20 +1131,22 @@ | |
| 1092 | ** COMMAND: test-tree-name |
| 1093 | ** |
| 1094 | ** Test the operation of the tree name generator. |
| 1095 | ** |
| 1096 | ** Options: |
| 1097 | ** --case-sensitive B Enable or disable case-sensitive filenames. B is |
| 1098 | ** a boolean: "yes", "no", "true", "false", etc. |
| 1099 | */ |
| 1100 | void cmd_test_tree_name(void){ |
| 1101 | int i; |
| 1102 | Blob x; |
| 1103 | db_find_and_open_repository(0,0); |
| 1104 | blob_zero(&x); |
| 1105 | for(i=2; i<g.argc; i++){ |
| 1106 | if( file_tree_name(g.argv[i], &x, 1) ){ |
| 1107 | fossil_print("%s\n", blob_buffer(&x)); |
| 1108 | blob_reset(&x); |
| 1109 | } |
| 1110 | } |
| 1111 | } |
| 1112 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -1029,18 +1029,25 @@ | |
| 1029 | blob_reset(&x); |
| 1030 | } |
| 1031 | } |
| 1032 | |
| 1033 | /* |
| 1034 | ** Compute a full path name for a file in the local tree. If |
| 1035 | ** the absolute flag is non-zero, the computed path will be |
| 1036 | ** absolute, starting with the root path of the local tree; |
| 1037 | ** otherwise, it will be relative to the root of the local |
| 1038 | ** tree. In both cases, the root of the local tree is defined |
| 1039 | ** by the g.zLocalRoot variable. Return TRUE on success. On |
| 1040 | ** failure, print and error message and quit if the errFatal |
| 1041 | ** flag is true. If errFatal is false, then simply return 0. |
| 1042 | */ |
| 1043 | int file_tree_name( |
| 1044 | const char *zOrigName, |
| 1045 | Blob *pOut, |
| 1046 | int absolute, |
| 1047 | int errFatal |
| 1048 | ){ |
| 1049 | Blob localRoot; |
| 1050 | int nLocalRoot; |
| 1051 | char *zLocalRoot; |
| 1052 | Blob full; |
| 1053 | int nFull; |
| @@ -1047,12 +1054,31 @@ | |
| 1054 | char *zFull; |
| 1055 | int (*xCmp)(const char*,const char*,int); |
| 1056 | |
| 1057 | blob_zero(pOut); |
| 1058 | if( !g.localOpen ){ |
| 1059 | if( absolute && !file_is_absolute_path(zOrigName) ){ |
| 1060 | if( errFatal ){ |
| 1061 | fossil_fatal("relative to absolute needs open checkout tree: %s", |
| 1062 | zOrigName); |
| 1063 | } |
| 1064 | return 0; |
| 1065 | }else{ |
| 1066 | /* |
| 1067 | ** The original path may be relative or absolute; however, without |
| 1068 | ** an open checkout tree, the only things we can do at this point |
| 1069 | ** is return it verbatim or generate a fatal error. The caller is |
| 1070 | ** probably expecting a tree-relative path name will be returned; |
| 1071 | ** however, most places where this function is called already check |
| 1072 | ** if the local checkout tree is open, either directly or indirectly, |
| 1073 | ** which would make this situation impossible. Alternatively, they |
| 1074 | ** could check the returned path using the file_is_absolute_path() |
| 1075 | ** function. |
| 1076 | */ |
| 1077 | blob_appendf(pOut, "%s", zOrigName); |
| 1078 | return 1; |
| 1079 | } |
| 1080 | } |
| 1081 | file_canonical_name(g.zLocalRoot, &localRoot, 1); |
| 1082 | nLocalRoot = blob_size(&localRoot); |
| 1083 | zLocalRoot = blob_buffer(&localRoot); |
| 1084 | assert( nLocalRoot>0 && zLocalRoot[nLocalRoot-1]=='/' ); |
| @@ -1066,11 +1092,15 @@ | |
| 1092 | } |
| 1093 | |
| 1094 | /* Special case. zOrigName refers to g.zLocalRoot directory. */ |
| 1095 | if( (nFull==nLocalRoot-1 && xCmp(zLocalRoot, zFull, nFull)==0) |
| 1096 | || (nFull==1 && zFull[0]=='/' && nLocalRoot==1 && zLocalRoot[0]=='/') ){ |
| 1097 | if( absolute ){ |
| 1098 | blob_append(pOut, zLocalRoot, nLocalRoot); |
| 1099 | }else{ |
| 1100 | blob_append(pOut, ".", 1); |
| 1101 | } |
| 1102 | blob_reset(&localRoot); |
| 1103 | blob_reset(&full); |
| 1104 | return 1; |
| 1105 | } |
| 1106 | |
| @@ -1080,11 +1110,20 @@ | |
| 1110 | if( errFatal ){ |
| 1111 | fossil_fatal("file outside of checkout tree: %s", zOrigName); |
| 1112 | } |
| 1113 | return 0; |
| 1114 | } |
| 1115 | if( absolute ){ |
| 1116 | if( !file_is_absolute_path(zOrigName) ){ |
| 1117 | blob_append(pOut, zLocalRoot, nLocalRoot); |
| 1118 | } |
| 1119 | blob_append(pOut, zOrigName, -1); |
| 1120 | blob_resize(pOut, file_simplify_name(blob_buffer(pOut), |
| 1121 | blob_size(pOut), 0)); |
| 1122 | }else{ |
| 1123 | blob_append(pOut, &zFull[nLocalRoot], nFull-nLocalRoot); |
| 1124 | } |
| 1125 | blob_reset(&localRoot); |
| 1126 | blob_reset(&full); |
| 1127 | return 1; |
| 1128 | } |
| 1129 | |
| @@ -1092,20 +1131,22 @@ | |
| 1131 | ** COMMAND: test-tree-name |
| 1132 | ** |
| 1133 | ** Test the operation of the tree name generator. |
| 1134 | ** |
| 1135 | ** Options: |
| 1136 | ** --absolute Return an absolute path instead of a relative one. |
| 1137 | ** --case-sensitive B Enable or disable case-sensitive filenames. B is |
| 1138 | ** a boolean: "yes", "no", "true", "false", etc. |
| 1139 | */ |
| 1140 | void cmd_test_tree_name(void){ |
| 1141 | int i; |
| 1142 | Blob x; |
| 1143 | int absoluteFlag = find_option("absolute",0,0)!=0; |
| 1144 | db_find_and_open_repository(0,0); |
| 1145 | blob_zero(&x); |
| 1146 | for(i=2; i<g.argc; i++){ |
| 1147 | if( file_tree_name(g.argv[i], &x, absoluteFlag, 1) ){ |
| 1148 | fossil_print("%s\n", blob_buffer(&x)); |
| 1149 | blob_reset(&x); |
| 1150 | } |
| 1151 | } |
| 1152 | } |
| 1153 |
+4
-4
| --- src/finfo.c | ||
| +++ src/finfo.c | ||
| @@ -73,11 +73,11 @@ | ||
| 73 | 73 | vid = db_lget_int("checkout", 0); |
| 74 | 74 | if( vid==0 ){ |
| 75 | 75 | fossil_fatal("no checkout to finfo files in"); |
| 76 | 76 | } |
| 77 | 77 | vfile_check_signature(vid, CKSIG_ENOTFILE); |
| 78 | - file_tree_name(g.argv[2], &fname, 1); | |
| 78 | + file_tree_name(g.argv[2], &fname, 0, 1); | |
| 79 | 79 | db_prepare(&q, |
| 80 | 80 | "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)" |
| 81 | 81 | " FROM vfile WHERE vfile.pathname=%B %s", |
| 82 | 82 | &fname, filename_collation()); |
| 83 | 83 | blob_zero(&line); |
| @@ -122,11 +122,11 @@ | ||
| 122 | 122 | const char *zRevision = find_option("revision", "r", 1); |
| 123 | 123 | |
| 124 | 124 | /* We should be done with options.. */ |
| 125 | 125 | verify_all_options(); |
| 126 | 126 | |
| 127 | - file_tree_name(g.argv[2], &fname, 1); | |
| 127 | + file_tree_name(g.argv[2], &fname, 0, 1); | |
| 128 | 128 | if( zRevision ){ |
| 129 | 129 | historical_version_of_file(zRevision, blob_str(&fname), &record, 0,0,0,0); |
| 130 | 130 | }else{ |
| 131 | 131 | int rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B %s", |
| 132 | 132 | &fname, filename_collation()); |
| @@ -174,11 +174,11 @@ | ||
| 174 | 174 | verify_all_options(); |
| 175 | 175 | |
| 176 | 176 | if( g.argc!=3 ){ |
| 177 | 177 | usage("?-l|--log? ?-b|--brief? FILENAME"); |
| 178 | 178 | } |
| 179 | - file_tree_name(g.argv[2], &fname, 1); | |
| 179 | + file_tree_name(g.argv[2], &fname, 0, 1); | |
| 180 | 180 | rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B %s", |
| 181 | 181 | &fname, filename_collation()); |
| 182 | 182 | if( rid==0 ){ |
| 183 | 183 | fossil_fatal("no history for file: %b", &fname); |
| 184 | 184 | } |
| @@ -259,11 +259,11 @@ | ||
| 259 | 259 | |
| 260 | 260 | /* We should be done with options.. */ |
| 261 | 261 | verify_all_options(); |
| 262 | 262 | |
| 263 | 263 | for(i=2; i<g.argc; i++){ |
| 264 | - file_tree_name(g.argv[i], &fname, 1); | |
| 264 | + file_tree_name(g.argv[i], &fname, 0, 1); | |
| 265 | 265 | blob_zero(&content); |
| 266 | 266 | rc = historical_version_of_file(zRev, blob_str(&fname), &content, 0,0,0,2); |
| 267 | 267 | if( rc==2 ){ |
| 268 | 268 | fossil_fatal("no such file: %s", g.argv[i]); |
| 269 | 269 | } |
| 270 | 270 |
| --- src/finfo.c | |
| +++ src/finfo.c | |
| @@ -73,11 +73,11 @@ | |
| 73 | vid = db_lget_int("checkout", 0); |
| 74 | if( vid==0 ){ |
| 75 | fossil_fatal("no checkout to finfo files in"); |
| 76 | } |
| 77 | vfile_check_signature(vid, CKSIG_ENOTFILE); |
| 78 | file_tree_name(g.argv[2], &fname, 1); |
| 79 | db_prepare(&q, |
| 80 | "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)" |
| 81 | " FROM vfile WHERE vfile.pathname=%B %s", |
| 82 | &fname, filename_collation()); |
| 83 | blob_zero(&line); |
| @@ -122,11 +122,11 @@ | |
| 122 | const char *zRevision = find_option("revision", "r", 1); |
| 123 | |
| 124 | /* We should be done with options.. */ |
| 125 | verify_all_options(); |
| 126 | |
| 127 | file_tree_name(g.argv[2], &fname, 1); |
| 128 | if( zRevision ){ |
| 129 | historical_version_of_file(zRevision, blob_str(&fname), &record, 0,0,0,0); |
| 130 | }else{ |
| 131 | int rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B %s", |
| 132 | &fname, filename_collation()); |
| @@ -174,11 +174,11 @@ | |
| 174 | verify_all_options(); |
| 175 | |
| 176 | if( g.argc!=3 ){ |
| 177 | usage("?-l|--log? ?-b|--brief? FILENAME"); |
| 178 | } |
| 179 | file_tree_name(g.argv[2], &fname, 1); |
| 180 | rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B %s", |
| 181 | &fname, filename_collation()); |
| 182 | if( rid==0 ){ |
| 183 | fossil_fatal("no history for file: %b", &fname); |
| 184 | } |
| @@ -259,11 +259,11 @@ | |
| 259 | |
| 260 | /* We should be done with options.. */ |
| 261 | verify_all_options(); |
| 262 | |
| 263 | for(i=2; i<g.argc; i++){ |
| 264 | file_tree_name(g.argv[i], &fname, 1); |
| 265 | blob_zero(&content); |
| 266 | rc = historical_version_of_file(zRev, blob_str(&fname), &content, 0,0,0,2); |
| 267 | if( rc==2 ){ |
| 268 | fossil_fatal("no such file: %s", g.argv[i]); |
| 269 | } |
| 270 |
| --- src/finfo.c | |
| +++ src/finfo.c | |
| @@ -73,11 +73,11 @@ | |
| 73 | vid = db_lget_int("checkout", 0); |
| 74 | if( vid==0 ){ |
| 75 | fossil_fatal("no checkout to finfo files in"); |
| 76 | } |
| 77 | vfile_check_signature(vid, CKSIG_ENOTFILE); |
| 78 | file_tree_name(g.argv[2], &fname, 0, 1); |
| 79 | db_prepare(&q, |
| 80 | "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)" |
| 81 | " FROM vfile WHERE vfile.pathname=%B %s", |
| 82 | &fname, filename_collation()); |
| 83 | blob_zero(&line); |
| @@ -122,11 +122,11 @@ | |
| 122 | const char *zRevision = find_option("revision", "r", 1); |
| 123 | |
| 124 | /* We should be done with options.. */ |
| 125 | verify_all_options(); |
| 126 | |
| 127 | file_tree_name(g.argv[2], &fname, 0, 1); |
| 128 | if( zRevision ){ |
| 129 | historical_version_of_file(zRevision, blob_str(&fname), &record, 0,0,0,0); |
| 130 | }else{ |
| 131 | int rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B %s", |
| 132 | &fname, filename_collation()); |
| @@ -174,11 +174,11 @@ | |
| 174 | verify_all_options(); |
| 175 | |
| 176 | if( g.argc!=3 ){ |
| 177 | usage("?-l|--log? ?-b|--brief? FILENAME"); |
| 178 | } |
| 179 | file_tree_name(g.argv[2], &fname, 0, 1); |
| 180 | rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B %s", |
| 181 | &fname, filename_collation()); |
| 182 | if( rid==0 ){ |
| 183 | fossil_fatal("no history for file: %b", &fname); |
| 184 | } |
| @@ -259,11 +259,11 @@ | |
| 259 | |
| 260 | /* We should be done with options.. */ |
| 261 | verify_all_options(); |
| 262 | |
| 263 | for(i=2; i<g.argc; i++){ |
| 264 | file_tree_name(g.argv[i], &fname, 0, 1); |
| 265 | blob_zero(&content); |
| 266 | rc = historical_version_of_file(zRev, blob_str(&fname), &content, 0,0,0,2); |
| 267 | if( rc==2 ){ |
| 268 | fossil_fatal("no such file: %s", g.argv[i]); |
| 269 | } |
| 270 |
+1
-1
| --- src/stash.c | ||
| +++ src/stash.c | ||
| @@ -58,11 +58,11 @@ | ||
| 58 | 58 | Blob sql; /* Query statement text */ |
| 59 | 59 | Stmt q; /* Query against the vfile table */ |
| 60 | 60 | Stmt ins; /* Insert statement */ |
| 61 | 61 | |
| 62 | 62 | zFile = mprintf("%/", zFName); |
| 63 | - file_tree_name(zFile, &fname, 1); | |
| 63 | + file_tree_name(zFile, &fname, 0, 1); | |
| 64 | 64 | zTreename = blob_str(&fname); |
| 65 | 65 | blob_zero(&sql); |
| 66 | 66 | blob_append_sql(&sql, |
| 67 | 67 | "SELECT deleted, isexe, islink, mrid, pathname, coalesce(origname,pathname)" |
| 68 | 68 | " FROM vfile" |
| 69 | 69 |
| --- src/stash.c | |
| +++ src/stash.c | |
| @@ -58,11 +58,11 @@ | |
| 58 | Blob sql; /* Query statement text */ |
| 59 | Stmt q; /* Query against the vfile table */ |
| 60 | Stmt ins; /* Insert statement */ |
| 61 | |
| 62 | zFile = mprintf("%/", zFName); |
| 63 | file_tree_name(zFile, &fname, 1); |
| 64 | zTreename = blob_str(&fname); |
| 65 | blob_zero(&sql); |
| 66 | blob_append_sql(&sql, |
| 67 | "SELECT deleted, isexe, islink, mrid, pathname, coalesce(origname,pathname)" |
| 68 | " FROM vfile" |
| 69 |
| --- src/stash.c | |
| +++ src/stash.c | |
| @@ -58,11 +58,11 @@ | |
| 58 | Blob sql; /* Query statement text */ |
| 59 | Stmt q; /* Query against the vfile table */ |
| 60 | Stmt ins; /* Insert statement */ |
| 61 | |
| 62 | zFile = mprintf("%/", zFName); |
| 63 | file_tree_name(zFile, &fname, 0, 1); |
| 64 | zTreename = blob_str(&fname); |
| 65 | blob_zero(&sql); |
| 66 | blob_append_sql(&sql, |
| 67 | "SELECT deleted, isexe, islink, mrid, pathname, coalesce(origname,pathname)" |
| 68 | " FROM vfile" |
| 69 |
+1
-1
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -2085,11 +2085,11 @@ | ||
| 2085 | 2085 | if( zType==0 ){ |
| 2086 | 2086 | /* When zFilePattern is specified and type is not specified, only show |
| 2087 | 2087 | * file check-ins */ |
| 2088 | 2088 | zType="ci"; |
| 2089 | 2089 | } |
| 2090 | - file_tree_name(zFilePattern, &treeName, 1); | |
| 2090 | + file_tree_name(zFilePattern, &treeName, 0, 1); | |
| 2091 | 2091 | if( fossil_strcmp(blob_str(&treeName), ".")==0 ){ |
| 2092 | 2092 | /* When zTreeName refers to g.zLocalRoot, it's like not specifying |
| 2093 | 2093 | * zFilePattern. */ |
| 2094 | 2094 | zFilePattern = 0; |
| 2095 | 2095 | } |
| 2096 | 2096 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -2085,11 +2085,11 @@ | |
| 2085 | if( zType==0 ){ |
| 2086 | /* When zFilePattern is specified and type is not specified, only show |
| 2087 | * file check-ins */ |
| 2088 | zType="ci"; |
| 2089 | } |
| 2090 | file_tree_name(zFilePattern, &treeName, 1); |
| 2091 | if( fossil_strcmp(blob_str(&treeName), ".")==0 ){ |
| 2092 | /* When zTreeName refers to g.zLocalRoot, it's like not specifying |
| 2093 | * zFilePattern. */ |
| 2094 | zFilePattern = 0; |
| 2095 | } |
| 2096 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -2085,11 +2085,11 @@ | |
| 2085 | if( zType==0 ){ |
| 2086 | /* When zFilePattern is specified and type is not specified, only show |
| 2087 | * file check-ins */ |
| 2088 | zType="ci"; |
| 2089 | } |
| 2090 | file_tree_name(zFilePattern, &treeName, 0, 1); |
| 2091 | if( fossil_strcmp(blob_str(&treeName), ".")==0 ){ |
| 2092 | /* When zTreeName refers to g.zLocalRoot, it's like not specifying |
| 2093 | * zFilePattern. */ |
| 2094 | zFilePattern = 0; |
| 2095 | } |
| 2096 |
+1
-1
| --- src/undo.c | ||
| +++ src/undo.c | ||
| @@ -437,11 +437,11 @@ | ||
| 437 | 437 | fossil_fatal("nothing to %s", zCmd); |
| 438 | 438 | } |
| 439 | 439 | for(i=2; i<g.argc; i++){ |
| 440 | 440 | const char *zFile = g.argv[i]; |
| 441 | 441 | Blob path; |
| 442 | - file_tree_name(zFile, &path, 1); | |
| 442 | + file_tree_name(zFile, &path, 0, 1); | |
| 443 | 443 | undo_one(blob_str(&path), isRedo); |
| 444 | 444 | blob_reset(&path); |
| 445 | 445 | } |
| 446 | 446 | } |
| 447 | 447 | vid2 = db_lget_int("checkout", 0); |
| 448 | 448 |
| --- src/undo.c | |
| +++ src/undo.c | |
| @@ -437,11 +437,11 @@ | |
| 437 | fossil_fatal("nothing to %s", zCmd); |
| 438 | } |
| 439 | for(i=2; i<g.argc; i++){ |
| 440 | const char *zFile = g.argv[i]; |
| 441 | Blob path; |
| 442 | file_tree_name(zFile, &path, 1); |
| 443 | undo_one(blob_str(&path), isRedo); |
| 444 | blob_reset(&path); |
| 445 | } |
| 446 | } |
| 447 | vid2 = db_lget_int("checkout", 0); |
| 448 |
| --- src/undo.c | |
| +++ src/undo.c | |
| @@ -437,11 +437,11 @@ | |
| 437 | fossil_fatal("nothing to %s", zCmd); |
| 438 | } |
| 439 | for(i=2; i<g.argc; i++){ |
| 440 | const char *zFile = g.argv[i]; |
| 441 | Blob path; |
| 442 | file_tree_name(zFile, &path, 0, 1); |
| 443 | undo_one(blob_str(&path), isRedo); |
| 444 | blob_reset(&path); |
| 445 | } |
| 446 | } |
| 447 | vid2 = db_lget_int("checkout", 0); |
| 448 |
+2
-2
| --- src/update.c | ||
| +++ src/update.c | ||
| @@ -352,11 +352,11 @@ | ||
| 352 | 352 | |
| 353 | 353 | blob_zero(&sql); |
| 354 | 354 | blob_append(&sql, "DELETE FROM fv WHERE ", -1); |
| 355 | 355 | zSep = ""; |
| 356 | 356 | for(i=3; i<g.argc; i++){ |
| 357 | - file_tree_name(g.argv[i], &treename, 1); | |
| 357 | + file_tree_name(g.argv[i], &treename, 0, 1); | |
| 358 | 358 | if( file_wd_isdir(g.argv[i])==1 ){ |
| 359 | 359 | if( blob_size(&treename) != 1 || blob_str(&treename)[0] != '.' ){ |
| 360 | 360 | blob_append_sql(&sql, "%sfn NOT GLOB '%q/*' ", |
| 361 | 361 | zSep /*safe-for-%s*/, blob_str(&treename)); |
| 362 | 362 | }else{ |
| @@ -738,11 +738,11 @@ | ||
| 738 | 738 | |
| 739 | 739 | if( g.argc>2 ){ |
| 740 | 740 | for(i=2; i<g.argc; i++){ |
| 741 | 741 | Blob fname; |
| 742 | 742 | zFile = mprintf("%/", g.argv[i]); |
| 743 | - file_tree_name(zFile, &fname, 1); | |
| 743 | + file_tree_name(zFile, &fname, 0, 1); | |
| 744 | 744 | db_multi_exec( |
| 745 | 745 | "REPLACE INTO torevert VALUES(%B);" |
| 746 | 746 | "INSERT OR IGNORE INTO torevert" |
| 747 | 747 | " SELECT pathname" |
| 748 | 748 | " FROM vfile" |
| 749 | 749 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -352,11 +352,11 @@ | |
| 352 | |
| 353 | blob_zero(&sql); |
| 354 | blob_append(&sql, "DELETE FROM fv WHERE ", -1); |
| 355 | zSep = ""; |
| 356 | for(i=3; i<g.argc; i++){ |
| 357 | file_tree_name(g.argv[i], &treename, 1); |
| 358 | if( file_wd_isdir(g.argv[i])==1 ){ |
| 359 | if( blob_size(&treename) != 1 || blob_str(&treename)[0] != '.' ){ |
| 360 | blob_append_sql(&sql, "%sfn NOT GLOB '%q/*' ", |
| 361 | zSep /*safe-for-%s*/, blob_str(&treename)); |
| 362 | }else{ |
| @@ -738,11 +738,11 @@ | |
| 738 | |
| 739 | if( g.argc>2 ){ |
| 740 | for(i=2; i<g.argc; i++){ |
| 741 | Blob fname; |
| 742 | zFile = mprintf("%/", g.argv[i]); |
| 743 | file_tree_name(zFile, &fname, 1); |
| 744 | db_multi_exec( |
| 745 | "REPLACE INTO torevert VALUES(%B);" |
| 746 | "INSERT OR IGNORE INTO torevert" |
| 747 | " SELECT pathname" |
| 748 | " FROM vfile" |
| 749 |
| --- src/update.c | |
| +++ src/update.c | |
| @@ -352,11 +352,11 @@ | |
| 352 | |
| 353 | blob_zero(&sql); |
| 354 | blob_append(&sql, "DELETE FROM fv WHERE ", -1); |
| 355 | zSep = ""; |
| 356 | for(i=3; i<g.argc; i++){ |
| 357 | file_tree_name(g.argv[i], &treename, 0, 1); |
| 358 | if( file_wd_isdir(g.argv[i])==1 ){ |
| 359 | if( blob_size(&treename) != 1 || blob_str(&treename)[0] != '.' ){ |
| 360 | blob_append_sql(&sql, "%sfn NOT GLOB '%q/*' ", |
| 361 | zSep /*safe-for-%s*/, blob_str(&treename)); |
| 362 | }else{ |
| @@ -738,11 +738,11 @@ | |
| 738 | |
| 739 | if( g.argc>2 ){ |
| 740 | for(i=2; i<g.argc; i++){ |
| 741 | Blob fname; |
| 742 | zFile = mprintf("%/", g.argv[i]); |
| 743 | file_tree_name(zFile, &fname, 0, 1); |
| 744 | db_multi_exec( |
| 745 | "REPLACE INTO torevert VALUES(%B);" |
| 746 | "INSERT OR IGNORE INTO torevert" |
| 747 | " SELECT pathname" |
| 748 | " FROM vfile" |
| 749 |
+31
| --- test/file1.test | ||
| +++ test/file1.test | ||
| @@ -33,10 +33,28 @@ | ||
| 33 | 33 | fossil test-relative-name --chdir $subdir $path |
| 34 | 34 | test relative-name-$testname.$i {$::RESULT==$result} |
| 35 | 35 | incr i |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | + | |
| 39 | +proc relative-tree-name {testname args} { | |
| 40 | + set i 1 | |
| 41 | + foreach {subdir path result} $args { | |
| 42 | + fossil test-tree-name --chdir $subdir $path | |
| 43 | + test relative-tree-name-$testname.$i {$::RESULT==$result} | |
| 44 | + incr i | |
| 45 | + } | |
| 46 | +} | |
| 47 | + | |
| 48 | +proc absolute-tree-name {testname args} { | |
| 49 | + set i 1 | |
| 50 | + foreach {subdir path result} $args { | |
| 51 | + fossil test-tree-name --chdir $subdir --absolute $path | |
| 52 | + test absolute-tree-name-$testname.$i {$::RESULT==$result} | |
| 53 | + incr i | |
| 54 | + } | |
| 55 | +} | |
| 38 | 56 | |
| 39 | 57 | simplify-name 100 . . .// . .. .. ..///// .. |
| 40 | 58 | simplify-name 101 {} {} / / ///////// / ././././ . |
| 41 | 59 | simplify-name 102 x x /x /x ///x //x |
| 42 | 60 | simplify-name 103 a/b a/b /a/b /a/b a///b a/b ///a///b///// //a/b |
| @@ -55,8 +73,21 @@ | ||
| 55 | 73 | file mkdir test1/test2 |
| 56 | 74 | |
| 57 | 75 | relative-name 100 . . . test1 [pwd] .. test1 [pwd]/ .. test1 [pwd]/test ../test |
| 58 | 76 | relative-name 101 test1/test2 [pwd] ../.. test1/test2 [pwd]/ ../.. test1/test2 [pwd]/test ../../test |
| 59 | 77 | relative-name 102 test1 [pwd]/test ../test . [pwd]/file1 ./file1 . [pwd]/file1/file2 ./file1/file2 |
| 78 | +relative-name 103 . [pwd] . | |
| 79 | + | |
| 80 | +relative-tree-name 100 . . file1 test1 [pwd] file1 test1 [pwd]/ file1 test1 [pwd]/test file1/test | |
| 81 | +relative-tree-name 101 test1/test2 [pwd] file1 test1/test2 [pwd]/ file1 test1/test2 [pwd]/test file1/test | |
| 82 | +relative-tree-name 102 test1 [pwd]/test file1/test . [pwd]/file1 file1/file1 . [pwd]/file1/file2 file1/file1/file2 | |
| 83 | +relative-tree-name 103 . [pwd] file1 | |
| 84 | + | |
| 85 | +set dirname [file normalize [file dirname [pwd]]] | |
| 86 | + | |
| 87 | +absolute-tree-name 100 . . $dirname test1 [pwd] [pwd] test1 [pwd]/ $dirname/file1 test1 [pwd]/test $dirname/file1/test | |
| 88 | +absolute-tree-name 101 test1/test2 [pwd] $dirname/file1 test1/test2 [pwd]/ $dirname/file1 test1/test2 [pwd]/test $dirname/file1/test | |
| 89 | +absolute-tree-name 102 test1 [pwd]/test $dirname/file1/test . [pwd]/file1 $dirname/file1/file1 . [pwd]/file1/file2 $dirname/file1/file1/file2 | |
| 90 | +absolute-tree-name 103 . [pwd] $dirname/file1 | |
| 60 | 91 | |
| 61 | 92 | catch {file delete test1/test2} |
| 62 | 93 | catch {file delete test1} |
| 63 | 94 |
| --- test/file1.test | |
| +++ test/file1.test | |
| @@ -33,10 +33,28 @@ | |
| 33 | fossil test-relative-name --chdir $subdir $path |
| 34 | test relative-name-$testname.$i {$::RESULT==$result} |
| 35 | incr i |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | simplify-name 100 . . .// . .. .. ..///// .. |
| 40 | simplify-name 101 {} {} / / ///////// / ././././ . |
| 41 | simplify-name 102 x x /x /x ///x //x |
| 42 | simplify-name 103 a/b a/b /a/b /a/b a///b a/b ///a///b///// //a/b |
| @@ -55,8 +73,21 @@ | |
| 55 | file mkdir test1/test2 |
| 56 | |
| 57 | relative-name 100 . . . test1 [pwd] .. test1 [pwd]/ .. test1 [pwd]/test ../test |
| 58 | relative-name 101 test1/test2 [pwd] ../.. test1/test2 [pwd]/ ../.. test1/test2 [pwd]/test ../../test |
| 59 | relative-name 102 test1 [pwd]/test ../test . [pwd]/file1 ./file1 . [pwd]/file1/file2 ./file1/file2 |
| 60 | |
| 61 | catch {file delete test1/test2} |
| 62 | catch {file delete test1} |
| 63 |
| --- test/file1.test | |
| +++ test/file1.test | |
| @@ -33,10 +33,28 @@ | |
| 33 | fossil test-relative-name --chdir $subdir $path |
| 34 | test relative-name-$testname.$i {$::RESULT==$result} |
| 35 | incr i |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | proc relative-tree-name {testname args} { |
| 40 | set i 1 |
| 41 | foreach {subdir path result} $args { |
| 42 | fossil test-tree-name --chdir $subdir $path |
| 43 | test relative-tree-name-$testname.$i {$::RESULT==$result} |
| 44 | incr i |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | proc absolute-tree-name {testname args} { |
| 49 | set i 1 |
| 50 | foreach {subdir path result} $args { |
| 51 | fossil test-tree-name --chdir $subdir --absolute $path |
| 52 | test absolute-tree-name-$testname.$i {$::RESULT==$result} |
| 53 | incr i |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | simplify-name 100 . . .// . .. .. ..///// .. |
| 58 | simplify-name 101 {} {} / / ///////// / ././././ . |
| 59 | simplify-name 102 x x /x /x ///x //x |
| 60 | simplify-name 103 a/b a/b /a/b /a/b a///b a/b ///a///b///// //a/b |
| @@ -55,8 +73,21 @@ | |
| 73 | file mkdir test1/test2 |
| 74 | |
| 75 | relative-name 100 . . . test1 [pwd] .. test1 [pwd]/ .. test1 [pwd]/test ../test |
| 76 | relative-name 101 test1/test2 [pwd] ../.. test1/test2 [pwd]/ ../.. test1/test2 [pwd]/test ../../test |
| 77 | relative-name 102 test1 [pwd]/test ../test . [pwd]/file1 ./file1 . [pwd]/file1/file2 ./file1/file2 |
| 78 | relative-name 103 . [pwd] . |
| 79 | |
| 80 | relative-tree-name 100 . . file1 test1 [pwd] file1 test1 [pwd]/ file1 test1 [pwd]/test file1/test |
| 81 | relative-tree-name 101 test1/test2 [pwd] file1 test1/test2 [pwd]/ file1 test1/test2 [pwd]/test file1/test |
| 82 | relative-tree-name 102 test1 [pwd]/test file1/test . [pwd]/file1 file1/file1 . [pwd]/file1/file2 file1/file1/file2 |
| 83 | relative-tree-name 103 . [pwd] file1 |
| 84 | |
| 85 | set dirname [file normalize [file dirname [pwd]]] |
| 86 | |
| 87 | absolute-tree-name 100 . . $dirname test1 [pwd] [pwd] test1 [pwd]/ $dirname/file1 test1 [pwd]/test $dirname/file1/test |
| 88 | absolute-tree-name 101 test1/test2 [pwd] $dirname/file1 test1/test2 [pwd]/ $dirname/file1 test1/test2 [pwd]/test $dirname/file1/test |
| 89 | absolute-tree-name 102 test1 [pwd]/test $dirname/file1/test . [pwd]/file1 $dirname/file1/file1 . [pwd]/file1/file2 $dirname/file1/file1/file2 |
| 90 | absolute-tree-name 103 . [pwd] $dirname/file1 |
| 91 | |
| 92 | catch {file delete test1/test2} |
| 93 | catch {file delete test1} |
| 94 |
+5
-5
| --- test/merge6.test | ||
| +++ test/merge6.test | ||
| @@ -23,26 +23,26 @@ | ||
| 23 | 23 | #################################################################### |
| 24 | 24 | |
| 25 | 25 | repo_init |
| 26 | 26 | fossil ls |
| 27 | 27 | |
| 28 | -test merge_multi-0 {[string map [list \r\n \n] [string trim $RESULT]] eq {}} | |
| 28 | +test merge_multi-0 {[normalize_result] eq {}} | |
| 29 | 29 | |
| 30 | 30 | write_file f1 "f1 line" |
| 31 | 31 | fossil add f1 |
| 32 | 32 | fossil commit -m "base file" |
| 33 | 33 | fossil ls |
| 34 | 34 | |
| 35 | -test merge_multi-1 {[string map [list \r\n \n] [string trim $RESULT]] eq {f1}} | |
| 35 | +test merge_multi-1 {[normalize_result] eq {f1}} | |
| 36 | 36 | |
| 37 | 37 | fossil update trunk |
| 38 | 38 | write_file f2 "f2 line" |
| 39 | 39 | fossil add f2 |
| 40 | 40 | fossil commit -m "branch for file f2" -b branch_for_f2 |
| 41 | 41 | fossil ls |
| 42 | 42 | |
| 43 | -test merge_multi-2 {[string map [list \r\n \n] [string trim $RESULT]] eq {f1 | |
| 43 | +test merge_multi-2 {[normalize_result] eq {f1 | |
| 44 | 44 | f2}} |
| 45 | 45 | |
| 46 | 46 | fossil update trunk |
| 47 | 47 | write_file f3 "f3 line" |
| 48 | 48 | write_file f4 "f4 line" |
| @@ -49,19 +49,19 @@ | ||
| 49 | 49 | fossil add f3 |
| 50 | 50 | fossil add f4 |
| 51 | 51 | fossil commit -m "branch for files f3 and f4" -b branch_for_f3_f4 |
| 52 | 52 | fossil ls |
| 53 | 53 | |
| 54 | -test merge_multi-3 {[string map [list \r\n \n] [string trim $RESULT]] eq {f1 | |
| 54 | +test merge_multi-3 {[normalize_result] eq {f1 | |
| 55 | 55 | f3 |
| 56 | 56 | f4}} |
| 57 | 57 | |
| 58 | 58 | fossil update trunk |
| 59 | 59 | fossil merge branch_for_f2 |
| 60 | 60 | fossil merge branch_for_f3_f4 |
| 61 | 61 | fossil commit -m "new trunk files f2, f3, and f4 via merge" |
| 62 | 62 | fossil ls |
| 63 | 63 | |
| 64 | -test merge_multi-4 {[string map [list \r\n \n] [string trim $RESULT]] eq {f1 | |
| 64 | +test merge_multi-4 {[normalize_result] eq {f1 | |
| 65 | 65 | f2 |
| 66 | 66 | f3 |
| 67 | 67 | f4}} |
| 68 | 68 |
| --- test/merge6.test | |
| +++ test/merge6.test | |
| @@ -23,26 +23,26 @@ | |
| 23 | #################################################################### |
| 24 | |
| 25 | repo_init |
| 26 | fossil ls |
| 27 | |
| 28 | test merge_multi-0 {[string map [list \r\n \n] [string trim $RESULT]] eq {}} |
| 29 | |
| 30 | write_file f1 "f1 line" |
| 31 | fossil add f1 |
| 32 | fossil commit -m "base file" |
| 33 | fossil ls |
| 34 | |
| 35 | test merge_multi-1 {[string map [list \r\n \n] [string trim $RESULT]] eq {f1}} |
| 36 | |
| 37 | fossil update trunk |
| 38 | write_file f2 "f2 line" |
| 39 | fossil add f2 |
| 40 | fossil commit -m "branch for file f2" -b branch_for_f2 |
| 41 | fossil ls |
| 42 | |
| 43 | test merge_multi-2 {[string map [list \r\n \n] [string trim $RESULT]] eq {f1 |
| 44 | f2}} |
| 45 | |
| 46 | fossil update trunk |
| 47 | write_file f3 "f3 line" |
| 48 | write_file f4 "f4 line" |
| @@ -49,19 +49,19 @@ | |
| 49 | fossil add f3 |
| 50 | fossil add f4 |
| 51 | fossil commit -m "branch for files f3 and f4" -b branch_for_f3_f4 |
| 52 | fossil ls |
| 53 | |
| 54 | test merge_multi-3 {[string map [list \r\n \n] [string trim $RESULT]] eq {f1 |
| 55 | f3 |
| 56 | f4}} |
| 57 | |
| 58 | fossil update trunk |
| 59 | fossil merge branch_for_f2 |
| 60 | fossil merge branch_for_f3_f4 |
| 61 | fossil commit -m "new trunk files f2, f3, and f4 via merge" |
| 62 | fossil ls |
| 63 | |
| 64 | test merge_multi-4 {[string map [list \r\n \n] [string trim $RESULT]] eq {f1 |
| 65 | f2 |
| 66 | f3 |
| 67 | f4}} |
| 68 |
| --- test/merge6.test | |
| +++ test/merge6.test | |
| @@ -23,26 +23,26 @@ | |
| 23 | #################################################################### |
| 24 | |
| 25 | repo_init |
| 26 | fossil ls |
| 27 | |
| 28 | test merge_multi-0 {[normalize_result] eq {}} |
| 29 | |
| 30 | write_file f1 "f1 line" |
| 31 | fossil add f1 |
| 32 | fossil commit -m "base file" |
| 33 | fossil ls |
| 34 | |
| 35 | test merge_multi-1 {[normalize_result] eq {f1}} |
| 36 | |
| 37 | fossil update trunk |
| 38 | write_file f2 "f2 line" |
| 39 | fossil add f2 |
| 40 | fossil commit -m "branch for file f2" -b branch_for_f2 |
| 41 | fossil ls |
| 42 | |
| 43 | test merge_multi-2 {[normalize_result] eq {f1 |
| 44 | f2}} |
| 45 | |
| 46 | fossil update trunk |
| 47 | write_file f3 "f3 line" |
| 48 | write_file f4 "f4 line" |
| @@ -49,19 +49,19 @@ | |
| 49 | fossil add f3 |
| 50 | fossil add f4 |
| 51 | fossil commit -m "branch for files f3 and f4" -b branch_for_f3_f4 |
| 52 | fossil ls |
| 53 | |
| 54 | test merge_multi-3 {[normalize_result] eq {f1 |
| 55 | f3 |
| 56 | f4}} |
| 57 | |
| 58 | fossil update trunk |
| 59 | fossil merge branch_for_f2 |
| 60 | fossil merge branch_for_f3_f4 |
| 61 | fossil commit -m "new trunk files f2, f3, and f4 via merge" |
| 62 | fossil ls |
| 63 | |
| 64 | test merge_multi-4 {[normalize_result] eq {f1 |
| 65 | f2 |
| 66 | f3 |
| 67 | f4}} |
| 68 |
+1
-1
| --- test/merge_renames.test | ||
| +++ test/merge_renames.test | ||
| @@ -197,11 +197,11 @@ | ||
| 197 | 197 | fossil merge trunk |
| 198 | 198 | fossil commit -m "trunk merged, should have 3 files" |
| 199 | 199 | |
| 200 | 200 | fossil ls |
| 201 | 201 | |
| 202 | -test merge_renames-5 {[string map [list \r\n \n] [string trim $RESULT]] eq {f1 | |
| 202 | +test merge_renames-5 {[normalize_result] eq {f1 | |
| 203 | 203 | f2 |
| 204 | 204 | f3}} |
| 205 | 205 | |
| 206 | 206 | ###################################### |
| 207 | 207 | # |
| 208 | 208 | |
| 209 | 209 | ADDED test/mv-rm.test |
| --- test/merge_renames.test | |
| +++ test/merge_renames.test | |
| @@ -197,11 +197,11 @@ | |
| 197 | fossil merge trunk |
| 198 | fossil commit -m "trunk merged, should have 3 files" |
| 199 | |
| 200 | fossil ls |
| 201 | |
| 202 | test merge_renames-5 {[string map [list \r\n \n] [string trim $RESULT]] eq {f1 |
| 203 | f2 |
| 204 | f3}} |
| 205 | |
| 206 | ###################################### |
| 207 | # |
| 208 | |
| 209 | DDED test/mv-rm.test |
| --- test/merge_renames.test | |
| +++ test/merge_renames.test | |
| @@ -197,11 +197,11 @@ | |
| 197 | fossil merge trunk |
| 198 | fossil commit -m "trunk merged, should have 3 files" |
| 199 | |
| 200 | fossil ls |
| 201 | |
| 202 | test merge_renames-5 {[normalize_result] eq {f1 |
| 203 | f2 |
| 204 | f3}} |
| 205 | |
| 206 | ###################################### |
| 207 | # |
| 208 | |
| 209 | DDED test/mv-rm.test |
+82
| --- a/test/mv-rm.test | ||
| +++ b/test/mv-rm.test | ||
| @@ -0,0 +1,82 @@ | ||
| 1 | +# | |
| 2 | + | |
| 3 | +test_cleanup | |
| 4 | +REVERT f1\nDELETE subdir1/f1REVERT f2\nDELETE subdir2/f2# | |
| 5 | + | |
| 6 | +test_cleanup | |
| 7 | +REVERT f4\nDELETE subdir4/REVERT f5\nREVERT f6\nDELETE subdir6/# | |
| 8 | + | |
| 9 | +test_cleanREVERT f8\nDELETE subdir8/DELETE subdir1/f1\nREVERT fDELETE subdir2/f2\nDELETE subdir3/f3\nREVERT f3DELETE subdir4/f4\nDELETE 5/f5\nREVERT f5DELETE subdir6/f6\nREVERT f6# | |
| 10 | + | |
| 11 | +test_cleanup | |
| 12 | +REVERT f1\nDELETE subdir1/f1REVERT f2\nDELETE subdir2/f2# | |
| 13 | + | |
| 14 | +test_cleanup | |
| 15 | +REVERT f4\nDELETE subdir4/REVERT f5\nREVERT f6\nDELETE subdir6/# | |
| 16 | + | |
| 17 | +test_cleanREVERT f8\nDELETE subdir8/nDELETE scatch {eputs res=$h {exec $::fossilexe info} res | |
| 18 | +if {![regexp {use --repository} $res]} { | |
| 19 | + puts stderr "Cannot run this test within an open checkout" | |
| 20 | + return | |
| 21 | +}p | |
| 22 | +repo_initrepo_init: subdir1/f1\nREVERTED: f:ED:res]} { | |
| 23 | + puts stderr "Cannot run this test within an open checkout" | |
| 24 | + return | |
| 25 | +}p | |
| 26 | +repo_initrepo_init:ED: f3: subdir4/f4\nREVERTED: f4: subdir5/f5\nREVERTED: f5: subdir6/f6\nREVERTED: f6: subdir7/f7\nREVERTED: f7: subdir8/f8ED: f8ED: subdirB/f9\nREVERTED:ED:ED:ED: subdirB/f9\nREVERTED:ED:ED: f413REVERT f4\nDE# | |
| 27 | + | |
| 28 | +test_cleanup | |
| 29 | +REVERT f1\nDELETE subdir1/f1REVERT f2\nDELETE subdir2/f2# | |
| 30 | + | |
| 31 | +test_cleanup | |
| 32 | +REVERT f4\nDELETE subdir4/REVERT f5\nREVERT f6\nDELETE subdir6/# | |
| 33 | + | |
| 34 | +test_cleanREVERT f8\nDELETE subdir8/DELETE subdir1/f1\nREVERT fDELETE subdir2/f2\nDELETE subdir3/f3\nREVERT f3DELETE subdir4/f4\nDELETE 5/f5\nREVERT write_file f12 "f12 f5DELERT f6# | |
| 35 | + | |
| 36 | +test_cleanup | |
| 37 | +REVERT ED: subdirB/ f12ubdirB/f9\nREVERTED:ED:ubdirB/f9\nREVERTED:ED:6REVERT f4\nDE#8] f6\nDELETE subdir6/# | |
| 38 | + | |
| 39 | +test_cleanREVERT f8\nDELETE subdir8/DELETE subdir1/f1\nREVERT fDELETE subdir2/f2\nDELETE subdir3/f3\nREV# | |
| 40 | + | |
| 41 | +tes f8R@UG,14A0B7;# | |
| 42 | + | |
| 43 | +test_cleanT f1\nDELETE subdir1/f1R Move File to Newp@23l,v: | |
| 44 | + | |
| 45 | +fossil mv --hard f12 d2/f13 | |
| 46 | +test mv-file-newup | |
| 47 | +REVERT f4\nDELETE subdir4/REVERT f5\nREVERT f6\nDELETE subdir6/# | |
| 48 | + | |
| 49 | +test_cleanREVER# | |
| 50 | + | |
| 51 | +test_cleanup12" | |
| 52 | +} | |
| 53 | + | |
| 54 | +test mv-file-new-directory-2 {[file size d2/f13] == 3} | |
| 55 | +test mv-file-new-directory-3file-new-directoryd2/f13\nREVERTED: f12${undoMsg}" | |
| 56 | +} | |
| 57 | + | |
| 58 | +test mv-file-new-directory-5 {[file size f12] == 3} | |
| 59 | +test mv-file-new-directory-6 {[read_file f12] eq "f12"# | |
| 60 | +# Test 18: Move Directory to New# | |
| 61 | + | |
| 62 | +fossil mv --hard subdirC subdirD | |
| 63 | +test mv-file-new-directory-7up | |
| 64 | +REVERT f4\nDELETE subdi# | |
| 65 | + | |
| 66 | +test_cleanup | |
| 67 | +REVEETE 5/" | |
| 68 | +} | |
| 69 | + | |
| 70 | +test mv-file-new-directory-8 {[file size subdirD/f10] == 3} | |
| 71 | +test mv-file-new-directory-9 {[read_file subdirD/f10] eq "f10"} | |
| 72 | +test mv-file-new-directory-10 {[file size subdirD/f11] == 3} | |
| 73 | +test mv-file-new-directory-11 {[reafile-new-directory-12up | |
| 74 | +REVERT # | |
| 75 | + | |
| 76 | +test_cleanup | |
| 77 | +REVERTtest mv-file-new-directory-13 {[file size subdirC/f10] == 3} | |
| 78 | +test mv-file-new-directory-14 {[read_file subdirC/f10] eq "f10"} | |
| 79 | +test mv-file-new-directory-15 {[file size subdirC/f11] == 3} | |
| 80 | +test mv-file-new-directory-16 {[read_file subdirC/f11] eq "f11"} | |
| 81 | + | |
| 82 | +cd $rootDir |
| --- a/test/mv-rm.test | |
| +++ b/test/mv-rm.test | |
| @@ -0,0 +1,82 @@ | |
| --- a/test/mv-rm.test | |
| +++ b/test/mv-rm.test | |
| @@ -0,0 +1,82 @@ | |
| 1 | # |
| 2 | |
| 3 | test_cleanup |
| 4 | REVERT f1\nDELETE subdir1/f1REVERT f2\nDELETE subdir2/f2# |
| 5 | |
| 6 | test_cleanup |
| 7 | REVERT f4\nDELETE subdir4/REVERT f5\nREVERT f6\nDELETE subdir6/# |
| 8 | |
| 9 | test_cleanREVERT f8\nDELETE subdir8/DELETE subdir1/f1\nREVERT fDELETE subdir2/f2\nDELETE subdir3/f3\nREVERT f3DELETE subdir4/f4\nDELETE 5/f5\nREVERT f5DELETE subdir6/f6\nREVERT f6# |
| 10 | |
| 11 | test_cleanup |
| 12 | REVERT f1\nDELETE subdir1/f1REVERT f2\nDELETE subdir2/f2# |
| 13 | |
| 14 | test_cleanup |
| 15 | REVERT f4\nDELETE subdir4/REVERT f5\nREVERT f6\nDELETE subdir6/# |
| 16 | |
| 17 | test_cleanREVERT f8\nDELETE subdir8/nDELETE scatch {eputs res=$h {exec $::fossilexe info} res |
| 18 | if {![regexp {use --repository} $res]} { |
| 19 | puts stderr "Cannot run this test within an open checkout" |
| 20 | return |
| 21 | }p |
| 22 | repo_initrepo_init: subdir1/f1\nREVERTED: f:ED:res]} { |
| 23 | puts stderr "Cannot run this test within an open checkout" |
| 24 | return |
| 25 | }p |
| 26 | repo_initrepo_init:ED: f3: subdir4/f4\nREVERTED: f4: subdir5/f5\nREVERTED: f5: subdir6/f6\nREVERTED: f6: subdir7/f7\nREVERTED: f7: subdir8/f8ED: f8ED: subdirB/f9\nREVERTED:ED:ED:ED: subdirB/f9\nREVERTED:ED:ED: f413REVERT f4\nDE# |
| 27 | |
| 28 | test_cleanup |
| 29 | REVERT f1\nDELETE subdir1/f1REVERT f2\nDELETE subdir2/f2# |
| 30 | |
| 31 | test_cleanup |
| 32 | REVERT f4\nDELETE subdir4/REVERT f5\nREVERT f6\nDELETE subdir6/# |
| 33 | |
| 34 | test_cleanREVERT f8\nDELETE subdir8/DELETE subdir1/f1\nREVERT fDELETE subdir2/f2\nDELETE subdir3/f3\nREVERT f3DELETE subdir4/f4\nDELETE 5/f5\nREVERT write_file f12 "f12 f5DELERT f6# |
| 35 | |
| 36 | test_cleanup |
| 37 | REVERT ED: subdirB/ f12ubdirB/f9\nREVERTED:ED:ubdirB/f9\nREVERTED:ED:6REVERT f4\nDE#8] f6\nDELETE subdir6/# |
| 38 | |
| 39 | test_cleanREVERT f8\nDELETE subdir8/DELETE subdir1/f1\nREVERT fDELETE subdir2/f2\nDELETE subdir3/f3\nREV# |
| 40 | |
| 41 | tes f8R@UG,14A0B7;# |
| 42 | |
| 43 | test_cleanT f1\nDELETE subdir1/f1R Move File to Newp@23l,v: |
| 44 | |
| 45 | fossil mv --hard f12 d2/f13 |
| 46 | test mv-file-newup |
| 47 | REVERT f4\nDELETE subdir4/REVERT f5\nREVERT f6\nDELETE subdir6/# |
| 48 | |
| 49 | test_cleanREVER# |
| 50 | |
| 51 | test_cleanup12" |
| 52 | } |
| 53 | |
| 54 | test mv-file-new-directory-2 {[file size d2/f13] == 3} |
| 55 | test mv-file-new-directory-3file-new-directoryd2/f13\nREVERTED: f12${undoMsg}" |
| 56 | } |
| 57 | |
| 58 | test mv-file-new-directory-5 {[file size f12] == 3} |
| 59 | test mv-file-new-directory-6 {[read_file f12] eq "f12"# |
| 60 | # Test 18: Move Directory to New# |
| 61 | |
| 62 | fossil mv --hard subdirC subdirD |
| 63 | test mv-file-new-directory-7up |
| 64 | REVERT f4\nDELETE subdi# |
| 65 | |
| 66 | test_cleanup |
| 67 | REVEETE 5/" |
| 68 | } |
| 69 | |
| 70 | test mv-file-new-directory-8 {[file size subdirD/f10] == 3} |
| 71 | test mv-file-new-directory-9 {[read_file subdirD/f10] eq "f10"} |
| 72 | test mv-file-new-directory-10 {[file size subdirD/f11] == 3} |
| 73 | test mv-file-new-directory-11 {[reafile-new-directory-12up |
| 74 | REVERT # |
| 75 | |
| 76 | test_cleanup |
| 77 | REVERTtest mv-file-new-directory-13 {[file size subdirC/f10] == 3} |
| 78 | test mv-file-new-directory-14 {[read_file subdirC/f10] eq "f10"} |
| 79 | test mv-file-new-directory-15 {[file size subdirC/f11] == 3} |
| 80 | test mv-file-new-directory-16 {[read_file subdirC/f11] eq "f11"} |
| 81 | |
| 82 | cd $rootDir |
+2
-4
| --- test/th1-tcl.test | ||
| +++ test/th1-tcl.test | ||
| @@ -54,20 +54,18 @@ | ||
| 54 | 54 | \d+ |
| 55 | 55 | two words |
| 56 | 56 | 4 |
| 57 | 57 | \d+ |
| 58 | 58 | one_word |
| 59 | -three words now | |
| 60 | -$} [string map [list \r\n \n] $RESULT]]} | |
| 59 | +three words now$} [normalize_result]]} | |
| 61 | 60 | |
| 62 | 61 | ############################################################################### |
| 63 | 62 | |
| 64 | 63 | fossil test-th-render --open-config \ |
| 65 | 64 | [file nativename [file join $dir th1-tcl2.txt]] |
| 66 | 65 | |
| 67 | -test th1-tcl-2 {[regexp -- {^\d+ | |
| 68 | -$} [string map [list \r\n \n] $RESULT]]} | |
| 66 | +test th1-tcl-2 {[regexp -- {^\d+$} [normalize_result]]} | |
| 69 | 67 | |
| 70 | 68 | ############################################################################### |
| 71 | 69 | |
| 72 | 70 | fossil test-th-render --open-config \ |
| 73 | 71 | [file nativename [file join $dir th1-tcl3.txt]] |
| 74 | 72 |
| --- test/th1-tcl.test | |
| +++ test/th1-tcl.test | |
| @@ -54,20 +54,18 @@ | |
| 54 | \d+ |
| 55 | two words |
| 56 | 4 |
| 57 | \d+ |
| 58 | one_word |
| 59 | three words now |
| 60 | $} [string map [list \r\n \n] $RESULT]]} |
| 61 | |
| 62 | ############################################################################### |
| 63 | |
| 64 | fossil test-th-render --open-config \ |
| 65 | [file nativename [file join $dir th1-tcl2.txt]] |
| 66 | |
| 67 | test th1-tcl-2 {[regexp -- {^\d+ |
| 68 | $} [string map [list \r\n \n] $RESULT]]} |
| 69 | |
| 70 | ############################################################################### |
| 71 | |
| 72 | fossil test-th-render --open-config \ |
| 73 | [file nativename [file join $dir th1-tcl3.txt]] |
| 74 |
| --- test/th1-tcl.test | |
| +++ test/th1-tcl.test | |
| @@ -54,20 +54,18 @@ | |
| 54 | \d+ |
| 55 | two words |
| 56 | 4 |
| 57 | \d+ |
| 58 | one_word |
| 59 | three words now$} [normalize_result]]} |
| 60 | |
| 61 | ############################################################################### |
| 62 | |
| 63 | fossil test-th-render --open-config \ |
| 64 | [file nativename [file join $dir th1-tcl2.txt]] |
| 65 | |
| 66 | test th1-tcl-2 {[regexp -- {^\d+$} [normalize_result]]} |
| 67 | |
| 68 | ############################################################################### |
| 69 | |
| 70 | fossil test-th-render --open-config \ |
| 71 | [file nativename [file join $dir th1-tcl3.txt]] |
| 72 |
+4
-4
| --- test/th1.test | ||
| +++ test/th1.test | ||
| @@ -591,17 +591,17 @@ | ||
| 591 | 591 | |
| 592 | 592 | ############################################################################### |
| 593 | 593 | |
| 594 | 594 | fossil test-th-eval --th-trace "trace {}" |
| 595 | 595 | if {$th1Hooks} { |
| 596 | - test th1-trace-2 {[string map [list \r\n \n] [string trim $RESULT]] eq \ | |
| 596 | + test th1-trace-2 {[normalize_result] eq \ | |
| 597 | 597 | {------------------ BEGIN TRACE LOG ------------------ |
| 598 | 598 | th1-init 0x0 => 0x0<br /> |
| 599 | 599 | |
| 600 | 600 | ------------------- END TRACE LOG -------------------}} |
| 601 | 601 | } else { |
| 602 | - test th1-trace-2 {[string map [list \r\n \n] [string trim $RESULT]] eq \ | |
| 602 | + test th1-trace-2 {[normalize_result] eq \ | |
| 603 | 603 | {------------------ BEGIN TRACE LOG ------------------ |
| 604 | 604 | th1-init 0x0 => 0x0<br /> |
| 605 | 605 | th1-setup {} => TH_OK<br /> |
| 606 | 606 | |
| 607 | 607 | ------------------- END TRACE LOG -------------------}} |
| @@ -614,17 +614,17 @@ | ||
| 614 | 614 | |
| 615 | 615 | ############################################################################### |
| 616 | 616 | |
| 617 | 617 | fossil test-th-eval --th-trace "trace {this is a trace message.}" |
| 618 | 618 | if {$th1Hooks} { |
| 619 | - test th1-trace-4 {[string map [list \r\n \n] [string trim $RESULT]] eq \ | |
| 619 | + test th1-trace-4 {[normalize_result] eq \ | |
| 620 | 620 | {------------------ BEGIN TRACE LOG ------------------ |
| 621 | 621 | th1-init 0x0 => 0x0<br /> |
| 622 | 622 | this is a trace message. |
| 623 | 623 | ------------------- END TRACE LOG -------------------}} |
| 624 | 624 | } else { |
| 625 | - test th1-trace-4 {[string map [list \r\n \n] [string trim $RESULT]] eq \ | |
| 625 | + test th1-trace-4 {[normalize_result] eq \ | |
| 626 | 626 | {------------------ BEGIN TRACE LOG ------------------ |
| 627 | 627 | th1-init 0x0 => 0x0<br /> |
| 628 | 628 | th1-setup {} => TH_OK<br /> |
| 629 | 629 | this is a trace message. |
| 630 | 630 | ------------------- END TRACE LOG -------------------}} |
| 631 | 631 |
| --- test/th1.test | |
| +++ test/th1.test | |
| @@ -591,17 +591,17 @@ | |
| 591 | |
| 592 | ############################################################################### |
| 593 | |
| 594 | fossil test-th-eval --th-trace "trace {}" |
| 595 | if {$th1Hooks} { |
| 596 | test th1-trace-2 {[string map [list \r\n \n] [string trim $RESULT]] eq \ |
| 597 | {------------------ BEGIN TRACE LOG ------------------ |
| 598 | th1-init 0x0 => 0x0<br /> |
| 599 | |
| 600 | ------------------- END TRACE LOG -------------------}} |
| 601 | } else { |
| 602 | test th1-trace-2 {[string map [list \r\n \n] [string trim $RESULT]] eq \ |
| 603 | {------------------ BEGIN TRACE LOG ------------------ |
| 604 | th1-init 0x0 => 0x0<br /> |
| 605 | th1-setup {} => TH_OK<br /> |
| 606 | |
| 607 | ------------------- END TRACE LOG -------------------}} |
| @@ -614,17 +614,17 @@ | |
| 614 | |
| 615 | ############################################################################### |
| 616 | |
| 617 | fossil test-th-eval --th-trace "trace {this is a trace message.}" |
| 618 | if {$th1Hooks} { |
| 619 | test th1-trace-4 {[string map [list \r\n \n] [string trim $RESULT]] eq \ |
| 620 | {------------------ BEGIN TRACE LOG ------------------ |
| 621 | th1-init 0x0 => 0x0<br /> |
| 622 | this is a trace message. |
| 623 | ------------------- END TRACE LOG -------------------}} |
| 624 | } else { |
| 625 | test th1-trace-4 {[string map [list \r\n \n] [string trim $RESULT]] eq \ |
| 626 | {------------------ BEGIN TRACE LOG ------------------ |
| 627 | th1-init 0x0 => 0x0<br /> |
| 628 | th1-setup {} => TH_OK<br /> |
| 629 | this is a trace message. |
| 630 | ------------------- END TRACE LOG -------------------}} |
| 631 |
| --- test/th1.test | |
| +++ test/th1.test | |
| @@ -591,17 +591,17 @@ | |
| 591 | |
| 592 | ############################################################################### |
| 593 | |
| 594 | fossil test-th-eval --th-trace "trace {}" |
| 595 | if {$th1Hooks} { |
| 596 | test th1-trace-2 {[normalize_result] eq \ |
| 597 | {------------------ BEGIN TRACE LOG ------------------ |
| 598 | th1-init 0x0 => 0x0<br /> |
| 599 | |
| 600 | ------------------- END TRACE LOG -------------------}} |
| 601 | } else { |
| 602 | test th1-trace-2 {[normalize_result] eq \ |
| 603 | {------------------ BEGIN TRACE LOG ------------------ |
| 604 | th1-init 0x0 => 0x0<br /> |
| 605 | th1-setup {} => TH_OK<br /> |
| 606 | |
| 607 | ------------------- END TRACE LOG -------------------}} |
| @@ -614,17 +614,17 @@ | |
| 614 | |
| 615 | ############################################################################### |
| 616 | |
| 617 | fossil test-th-eval --th-trace "trace {this is a trace message.}" |
| 618 | if {$th1Hooks} { |
| 619 | test th1-trace-4 {[normalize_result] eq \ |
| 620 | {------------------ BEGIN TRACE LOG ------------------ |
| 621 | th1-init 0x0 => 0x0<br /> |
| 622 | this is a trace message. |
| 623 | ------------------- END TRACE LOG -------------------}} |
| 624 | } else { |
| 625 | test th1-trace-4 {[normalize_result] eq \ |
| 626 | {------------------ BEGIN TRACE LOG ------------------ |
| 627 | th1-init 0x0 => 0x0<br /> |
| 628 | th1-setup {} => TH_OK<br /> |
| 629 | this is a trace message. |
| 630 | ------------------- END TRACE LOG -------------------}} |
| 631 |