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.

mistachkin 2015-05-29 17:14 trunk merge
Commit c56a387d47e5efde4a87d1e4a78b5430330caa0b
+40 -36
--- src/add.c
+++ src/add.c
@@ -91,11 +91,11 @@
9191
9292
if( cachedManifest == -1 ){
9393
Blob repo;
9494
cachedManifest = db_get_boolean("manifest",0);
9595
blob_zero(&repo);
96
- if( file_tree_name(g.zRepositoryName, &repo, 0) ){
96
+ if( file_tree_name(g.zRepositoryName, &repo, 0, 0) ){
9797
const char *zRepo = blob_str(&repo);
9898
azRepo[0] = zRepo;
9999
azRepo[1] = mprintf("%s-journal", zRepo);
100100
azRepo[2] = mprintf("%s-wal", zRepo);
101101
azRepo[3] = mprintf("%s-shm", zRepo);
@@ -201,11 +201,11 @@
201201
const char *zReserved; /* Name of a reserved file */
202202
Blob repoName; /* Treename of the repository */
203203
Stmt loop; /* SQL to loop over all files to add */
204204
int (*xCmp)(const char*,const char*);
205205
206
- if( !file_tree_name(g.zRepositoryName, &repoName, 0) ){
206
+ if( !file_tree_name(g.zRepositoryName, &repoName, 0, 0) ){
207207
blob_zero(&repoName);
208208
zRepo = "";
209209
}else{
210210
zRepo = blob_str(&repoName);
211211
}
@@ -307,11 +307,11 @@
307307
int isDir;
308308
Blob fullName;
309309
310310
/* file_tree_name() throws a fatal error if g.argv[i] is outside of the
311311
** checkout. */
312
- file_tree_name(g.argv[i], &fullName, 1);
312
+ file_tree_name(g.argv[i], &fullName, 0, 1);
313313
blob_reset(&fullName);
314314
315315
file_canonical_name(g.argv[i], &fullName, 0);
316316
zName = blob_str(&fullName);
317317
isDir = file_wd_isdir(zName);
@@ -365,11 +365,11 @@
365365
if( !tableCreated ){
366366
db_multi_exec("CREATE TEMP TABLE fremove(x TEXT PRIMARY KEY %s)",
367367
filename_collation());
368368
tableCreated = 1;
369369
}
370
- file_canonical_name(zOldName, &fullOldName, 0);
370
+ file_tree_name(zOldName, &fullOldName, 1, 1);
371371
db_multi_exec("INSERT INTO fremove VALUES('%q');", blob_str(&fullOldName));
372372
blob_reset(&fullOldName);
373373
}
374374
375375
/*
@@ -384,20 +384,22 @@
384384
*/
385385
static void process_files_to_remove(
386386
int dryRunFlag /* Zero to actually operate on the file-system. */
387387
){
388388
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
+ }
399401
}
400402
401403
/*
402404
** COMMAND: rm
403405
** COMMAND: delete
@@ -464,11 +466,11 @@
464466
filename_collation());
465467
for(i=2; i<g.argc; i++){
466468
Blob treeName;
467469
char *zTreeName;
468470
469
- file_tree_name(g.argv[i], &treeName, 1);
471
+ file_tree_name(g.argv[i], &treeName, 0, 1);
470472
zTreeName = blob_str(&treeName);
471473
db_multi_exec(
472474
"INSERT OR IGNORE INTO sfile"
473475
" SELECT pathname FROM vfile"
474476
" WHERE (pathname=%Q %s"
@@ -746,12 +748,12 @@
746748
if( !tableCreated ){
747749
db_multi_exec("CREATE TEMP TABLE fmove(x TEXT PRIMARY KEY %s, y TEXT %s)",
748750
filename_collation(), filename_collation());
749751
tableCreated = 1;
750752
}
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);
753755
db_multi_exec("INSERT INTO fmove VALUES('%q','%q');",
754756
blob_str(&fullOldName), blob_str(&fullNewName));
755757
blob_reset(&fullNewName);
756758
blob_reset(&fullOldName);
757759
}
@@ -768,26 +770,28 @@
768770
*/
769771
static void process_files_to_move(
770772
int dryRunFlag /* Zero to actually operate on the file-system. */
771773
){
772774
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
+ }
789793
}
790794
791795
/*
792796
** COMMAND: mv
793797
** COMMAND: rename*
@@ -860,11 +864,11 @@
860864
moveFiles = db_get_boolean("mv-rm-files",0);
861865
#else
862866
moveFiles = FOSSIL_MV_RM_FILE;
863867
#endif
864868
}
865
- file_tree_name(zDest, &dest, 1);
869
+ file_tree_name(zDest, &dest, 0, 1);
866870
db_multi_exec(
867871
"UPDATE vfile SET origname=pathname WHERE origname IS NULL;"
868872
);
869873
db_multi_exec(
870874
"CREATE TEMP TABLE mv(f TEXT UNIQUE ON CONFLICT IGNORE, t TEXT);"
@@ -872,11 +876,11 @@
872876
if( file_wd_isdir(zDest)!=1 ){
873877
Blob orig;
874878
if( g.argc!=4 ){
875879
usage("OLDNAME NEWNAME");
876880
}
877
- file_tree_name(g.argv[2], &orig, 1);
881
+ file_tree_name(g.argv[2], &orig, 0, 1);
878882
db_multi_exec(
879883
"INSERT INTO mv VALUES(%B,%B)", &orig, &dest
880884
);
881885
}else{
882886
if( blob_eq(&dest, ".") ){
@@ -886,11 +890,11 @@
886890
}
887891
for(i=2; i<g.argc-1; i++){
888892
Blob orig;
889893
char *zOrig;
890894
int nOrig;
891
- file_tree_name(g.argv[i], &orig, 1);
895
+ file_tree_name(g.argv[i], &orig, 0, 1);
892896
zOrig = blob_str(&orig);
893897
nOrig = blob_size(&orig);
894898
db_prepare(&q,
895899
"SELECT pathname FROM vfile"
896900
" WHERE vid=%d"
897901
--- 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 @@
4646
int i;
4747
4848
blob_zero(&where);
4949
for(i=2; i<g.argc; i++){
5050
Blob fname;
51
- file_tree_name(g.argv[i], &fname, 1);
51
+ file_tree_name(g.argv[i], &fname, 0, 1);
5252
zName = blob_str(&fname);
5353
if( fossil_strcmp(zName, ".")==0 ){
5454
blob_reset(&where);
5555
break;
5656
}
@@ -296,11 +296,11 @@
296296
297297
/* Handle given file names */
298298
blob_zero(&where);
299299
for(i=2; i<g.argc; i++){
300300
Blob fname;
301
- file_tree_name(g.argv[i], &fname, 1);
301
+ file_tree_name(g.argv[i], &fname, 0, 1);
302302
zName = blob_str(&fname);
303303
if( fossil_strcmp(zName, ".")==0 ){
304304
blob_reset(&where);
305305
break;
306306
}
@@ -409,11 +409,11 @@
409409
}
410410
verify_all_options();
411411
blob_zero(&where);
412412
for(i=2; i<g.argc; i++){
413413
Blob fname;
414
- file_tree_name(g.argv[i], &fname, 1);
414
+ file_tree_name(g.argv[i], &fname, 0, 1);
415415
zName = blob_str(&fname);
416416
if( fossil_strcmp(zName, ".")==0 ){
417417
blob_reset(&where);
418418
break;
419419
}
@@ -741,11 +741,11 @@
741741
"SELECT %Q || x FROM sfile"
742742
" WHERE x NOT IN (%s)"
743743
" ORDER BY 1",
744744
g.zLocalRoot, fossil_all_reserved_names(0)
745745
);
746
- if( file_tree_name(g.zRepositoryName, &repo, 0) ){
746
+ if( file_tree_name(g.zRepositoryName, &repo, 0, 0) ){
747747
db_multi_exec("DELETE FROM sfile WHERE x=%B", &repo);
748748
}
749749
db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
750750
while( db_step(&q)==SQLITE_ROW ){
751751
const char *zName = db_column_text(&q, 0);
@@ -1037,11 +1037,11 @@
10371037
10381038
blob_zero(&fname);
10391039
bag_init(&toCommit);
10401040
for(ii=2; ii<g.argc; ii++){
10411041
int cnt = 0;
1042
- file_tree_name(g.argv[ii], &fname, 1);
1042
+ file_tree_name(g.argv[ii], &fname, 0, 1);
10431043
if( fossil_strcmp(blob_str(&fname),".")==0 ){
10441044
bag_clear(&toCommit);
10451045
return result;
10461046
}
10471047
db_prepare(&q,
10481048
--- 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
+2 -1
--- src/db.c
+++ src/db.c
@@ -1258,11 +1258,12 @@
12581258
** Return the name of the database "localdb", "configdb", or "repository".
12591259
*/
12601260
const char *db_name(const char *zDb){
12611261
assert( fossil_strcmp(zDb,"localdb")==0
12621262
|| fossil_strcmp(zDb,"configdb")==0
1263
- || fossil_strcmp(zDb,"repository")==0 );
1263
+ || fossil_strcmp(zDb,"repository")==0
1264
+ || fossil_strcmp(zDb,"temp")==0 );
12641265
if( fossil_strcmp(zDb, g.zMainDbType)==0 ) zDb = "main";
12651266
return zDb;
12661267
}
12671268
12681269
/*
12691270
--- 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 @@
24572457
verify_all_options();
24582458
24592459
if( g.argc<3 ) {
24602460
usage("FILENAME");
24612461
}
2462
- file_tree_name(g.argv[2], &treename, 1);
2462
+ file_tree_name(g.argv[2], &treename, 0, 1);
24632463
zFilename = blob_str(&treename);
24642464
fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename);
24652465
if( fnid==0 ){
24662466
fossil_fatal("no such file: %s", zFilename);
24672467
}
24682468
--- 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 @@
298298
){
299299
Blob fname;
300300
Blob content;
301301
int isLink;
302302
int isBin;
303
- file_tree_name(zFileTreeName, &fname, 1);
303
+ file_tree_name(zFileTreeName, &fname, 0, 1);
304304
historical_version_of_file(zFrom, blob_str(&fname), &content, &isLink, 0,
305305
fIncludeBinary ? 0 : &isBin, 0);
306306
if( !isLink != !file_wd_islink(zFrom) ){
307307
fossil_print("%s",DIFF_CANNOT_COMPUTE_SYMLINK);
308308
}else{
@@ -454,11 +454,11 @@
454454
Blob fname;
455455
Blob v1, v2;
456456
int isLink1, isLink2;
457457
int isBin1, isBin2;
458458
if( diffFlags & DIFF_BRIEF ) return;
459
- file_tree_name(zFileTreeName, &fname, 1);
459
+ file_tree_name(zFileTreeName, &fname, 0, 1);
460460
zName = blob_str(&fname);
461461
historical_version_of_file(zFrom, zName, &v1, &isLink1, 0,
462462
fIncludeBinary ? 0 : &isBin1, 0);
463463
historical_version_of_file(zTo, zName, &v2, &isLink2, 0,
464464
fIncludeBinary ? 0 : &isBin2, 0);
465465
--- 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 @@
10291029
blob_reset(&x);
10301030
}
10311031
}
10321032
10331033
/*
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.
10401042
*/
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
+){
10421049
Blob localRoot;
10431050
int nLocalRoot;
10441051
char *zLocalRoot;
10451052
Blob full;
10461053
int nFull;
@@ -1047,12 +1054,31 @@
10471054
char *zFull;
10481055
int (*xCmp)(const char*,const char*,int);
10491056
10501057
blob_zero(pOut);
10511058
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
+ }
10541080
}
10551081
file_canonical_name(g.zLocalRoot, &localRoot, 1);
10561082
nLocalRoot = blob_size(&localRoot);
10571083
zLocalRoot = blob_buffer(&localRoot);
10581084
assert( nLocalRoot>0 && zLocalRoot[nLocalRoot-1]=='/' );
@@ -1066,11 +1092,15 @@
10661092
}
10671093
10681094
/* Special case. zOrigName refers to g.zLocalRoot directory. */
10691095
if( (nFull==nLocalRoot-1 && xCmp(zLocalRoot, zFull, nFull)==0)
10701096
|| (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
+ }
10721102
blob_reset(&localRoot);
10731103
blob_reset(&full);
10741104
return 1;
10751105
}
10761106
@@ -1080,11 +1110,20 @@
10801110
if( errFatal ){
10811111
fossil_fatal("file outside of checkout tree: %s", zOrigName);
10821112
}
10831113
return 0;
10841114
}
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
+ }
10861125
blob_reset(&localRoot);
10871126
blob_reset(&full);
10881127
return 1;
10891128
}
10901129
@@ -1092,20 +1131,22 @@
10921131
** COMMAND: test-tree-name
10931132
**
10941133
** Test the operation of the tree name generator.
10951134
**
10961135
** Options:
1136
+** --absolute Return an absolute path instead of a relative one.
10971137
** --case-sensitive B Enable or disable case-sensitive filenames. B is
10981138
** a boolean: "yes", "no", "true", "false", etc.
10991139
*/
11001140
void cmd_test_tree_name(void){
11011141
int i;
11021142
Blob x;
1143
+ int absoluteFlag = find_option("absolute",0,0)!=0;
11031144
db_find_and_open_repository(0,0);
11041145
blob_zero(&x);
11051146
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) ){
11071148
fossil_print("%s\n", blob_buffer(&x));
11081149
blob_reset(&x);
11091150
}
11101151
}
11111152
}
11121153
--- 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 @@
7373
vid = db_lget_int("checkout", 0);
7474
if( vid==0 ){
7575
fossil_fatal("no checkout to finfo files in");
7676
}
7777
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);
7979
db_prepare(&q,
8080
"SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)"
8181
" FROM vfile WHERE vfile.pathname=%B %s",
8282
&fname, filename_collation());
8383
blob_zero(&line);
@@ -122,11 +122,11 @@
122122
const char *zRevision = find_option("revision", "r", 1);
123123
124124
/* We should be done with options.. */
125125
verify_all_options();
126126
127
- file_tree_name(g.argv[2], &fname, 1);
127
+ file_tree_name(g.argv[2], &fname, 0, 1);
128128
if( zRevision ){
129129
historical_version_of_file(zRevision, blob_str(&fname), &record, 0,0,0,0);
130130
}else{
131131
int rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B %s",
132132
&fname, filename_collation());
@@ -174,11 +174,11 @@
174174
verify_all_options();
175175
176176
if( g.argc!=3 ){
177177
usage("?-l|--log? ?-b|--brief? FILENAME");
178178
}
179
- file_tree_name(g.argv[2], &fname, 1);
179
+ file_tree_name(g.argv[2], &fname, 0, 1);
180180
rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B %s",
181181
&fname, filename_collation());
182182
if( rid==0 ){
183183
fossil_fatal("no history for file: %b", &fname);
184184
}
@@ -259,11 +259,11 @@
259259
260260
/* We should be done with options.. */
261261
verify_all_options();
262262
263263
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);
265265
blob_zero(&content);
266266
rc = historical_version_of_file(zRev, blob_str(&fname), &content, 0,0,0,2);
267267
if( rc==2 ){
268268
fossil_fatal("no such file: %s", g.argv[i]);
269269
}
270270
--- 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 @@
5858
Blob sql; /* Query statement text */
5959
Stmt q; /* Query against the vfile table */
6060
Stmt ins; /* Insert statement */
6161
6262
zFile = mprintf("%/", zFName);
63
- file_tree_name(zFile, &fname, 1);
63
+ file_tree_name(zFile, &fname, 0, 1);
6464
zTreename = blob_str(&fname);
6565
blob_zero(&sql);
6666
blob_append_sql(&sql,
6767
"SELECT deleted, isexe, islink, mrid, pathname, coalesce(origname,pathname)"
6868
" FROM vfile"
6969
--- 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 @@
20852085
if( zType==0 ){
20862086
/* When zFilePattern is specified and type is not specified, only show
20872087
* file check-ins */
20882088
zType="ci";
20892089
}
2090
- file_tree_name(zFilePattern, &treeName, 1);
2090
+ file_tree_name(zFilePattern, &treeName, 0, 1);
20912091
if( fossil_strcmp(blob_str(&treeName), ".")==0 ){
20922092
/* When zTreeName refers to g.zLocalRoot, it's like not specifying
20932093
* zFilePattern. */
20942094
zFilePattern = 0;
20952095
}
20962096
--- 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 @@
437437
fossil_fatal("nothing to %s", zCmd);
438438
}
439439
for(i=2; i<g.argc; i++){
440440
const char *zFile = g.argv[i];
441441
Blob path;
442
- file_tree_name(zFile, &path, 1);
442
+ file_tree_name(zFile, &path, 0, 1);
443443
undo_one(blob_str(&path), isRedo);
444444
blob_reset(&path);
445445
}
446446
}
447447
vid2 = db_lget_int("checkout", 0);
448448
--- 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 @@
352352
353353
blob_zero(&sql);
354354
blob_append(&sql, "DELETE FROM fv WHERE ", -1);
355355
zSep = "";
356356
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);
358358
if( file_wd_isdir(g.argv[i])==1 ){
359359
if( blob_size(&treename) != 1 || blob_str(&treename)[0] != '.' ){
360360
blob_append_sql(&sql, "%sfn NOT GLOB '%q/*' ",
361361
zSep /*safe-for-%s*/, blob_str(&treename));
362362
}else{
@@ -738,11 +738,11 @@
738738
739739
if( g.argc>2 ){
740740
for(i=2; i<g.argc; i++){
741741
Blob fname;
742742
zFile = mprintf("%/", g.argv[i]);
743
- file_tree_name(zFile, &fname, 1);
743
+ file_tree_name(zFile, &fname, 0, 1);
744744
db_multi_exec(
745745
"REPLACE INTO torevert VALUES(%B);"
746746
"INSERT OR IGNORE INTO torevert"
747747
" SELECT pathname"
748748
" FROM vfile"
749749
--- 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
--- test/file1.test
+++ test/file1.test
@@ -33,10 +33,28 @@
3333
fossil test-relative-name --chdir $subdir $path
3434
test relative-name-$testname.$i {$::RESULT==$result}
3535
incr i
3636
}
3737
}
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
+}
3856
3957
simplify-name 100 . . .// . .. .. ..///// ..
4058
simplify-name 101 {} {} / / ///////// / ././././ .
4159
simplify-name 102 x x /x /x ///x //x
4260
simplify-name 103 a/b a/b /a/b /a/b a///b a/b ///a///b///// //a/b
@@ -55,8 +73,21 @@
5573
file mkdir test1/test2
5674
5775
relative-name 100 . . . test1 [pwd] .. test1 [pwd]/ .. test1 [pwd]/test ../test
5876
relative-name 101 test1/test2 [pwd] ../.. test1/test2 [pwd]/ ../.. test1/test2 [pwd]/test ../../test
5977
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
6091
6192
catch {file delete test1/test2}
6293
catch {file delete test1}
6394
--- 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
--- test/merge6.test
+++ test/merge6.test
@@ -23,26 +23,26 @@
2323
####################################################################
2424
2525
repo_init
2626
fossil ls
2727
28
-test merge_multi-0 {[string map [list \r\n \n] [string trim $RESULT]] eq {}}
28
+test merge_multi-0 {[normalize_result] eq {}}
2929
3030
write_file f1 "f1 line"
3131
fossil add f1
3232
fossil commit -m "base file"
3333
fossil ls
3434
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}}
3636
3737
fossil update trunk
3838
write_file f2 "f2 line"
3939
fossil add f2
4040
fossil commit -m "branch for file f2" -b branch_for_f2
4141
fossil ls
4242
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
4444
f2}}
4545
4646
fossil update trunk
4747
write_file f3 "f3 line"
4848
write_file f4 "f4 line"
@@ -49,19 +49,19 @@
4949
fossil add f3
5050
fossil add f4
5151
fossil commit -m "branch for files f3 and f4" -b branch_for_f3_f4
5252
fossil ls
5353
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
5555
f3
5656
f4}}
5757
5858
fossil update trunk
5959
fossil merge branch_for_f2
6060
fossil merge branch_for_f3_f4
6161
fossil commit -m "new trunk files f2, f3, and f4 via merge"
6262
fossil ls
6363
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
6565
f2
6666
f3
6767
f4}}
6868
--- 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
--- test/merge_renames.test
+++ test/merge_renames.test
@@ -197,11 +197,11 @@
197197
fossil merge trunk
198198
fossil commit -m "trunk merged, should have 3 files"
199199
200200
fossil ls
201201
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
203203
f2
204204
f3}}
205205
206206
######################################
207207
#
208208
209209
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
--- 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
--- test/th1-tcl.test
+++ test/th1-tcl.test
@@ -54,20 +54,18 @@
5454
\d+
5555
two words
5656
4
5757
\d+
5858
one_word
59
-three words now
60
-$} [string map [list \r\n \n] $RESULT]]}
59
+three words now$} [normalize_result]]}
6160
6261
###############################################################################
6362
6463
fossil test-th-render --open-config \
6564
[file nativename [file join $dir th1-tcl2.txt]]
6665
67
-test th1-tcl-2 {[regexp -- {^\d+
68
-$} [string map [list \r\n \n] $RESULT]]}
66
+test th1-tcl-2 {[regexp -- {^\d+$} [normalize_result]]}
6967
7068
###############################################################################
7169
7270
fossil test-th-render --open-config \
7371
[file nativename [file join $dir th1-tcl3.txt]]
7472
--- 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 @@
591591
592592
###############################################################################
593593
594594
fossil test-th-eval --th-trace "trace {}"
595595
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 \
597597
{------------------ BEGIN TRACE LOG ------------------
598598
th1-init 0x0 => 0x0<br />
599599
600600
------------------- END TRACE LOG -------------------}}
601601
} else {
602
- test th1-trace-2 {[string map [list \r\n \n] [string trim $RESULT]] eq \
602
+ test th1-trace-2 {[normalize_result] eq \
603603
{------------------ BEGIN TRACE LOG ------------------
604604
th1-init 0x0 => 0x0<br />
605605
th1-setup {} => TH_OK<br />
606606
607607
------------------- END TRACE LOG -------------------}}
@@ -614,17 +614,17 @@
614614
615615
###############################################################################
616616
617617
fossil test-th-eval --th-trace "trace {this is a trace message.}"
618618
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 \
620620
{------------------ BEGIN TRACE LOG ------------------
621621
th1-init 0x0 => 0x0<br />
622622
this is a trace message.
623623
------------------- END TRACE LOG -------------------}}
624624
} else {
625
- test th1-trace-4 {[string map [list \r\n \n] [string trim $RESULT]] eq \
625
+ test th1-trace-4 {[normalize_result] eq \
626626
{------------------ BEGIN TRACE LOG ------------------
627627
th1-init 0x0 => 0x0<br />
628628
th1-setup {} => TH_OK<br />
629629
this is a trace message.
630630
------------------- END TRACE LOG -------------------}}
631631
--- 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

Keyboard Shortcuts

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