Fossil SCM

Change the name of the --tree option to --external-baseline.

drh 2024-12-14 20:40 diff-tree
Commit 356163b05d92044bfccd9b152b7224672a921df01fb45353a758b143a02fcc25
2 files changed +5 -1 +28 -27
+5 -1
--- src/diff.tcl
+++ src/diff.tcl
@@ -110,11 +110,15 @@
110110
111111
set fromIndex [lsearch -glob $fossilcmd *-from]
112112
set toIndex [lsearch -glob $fossilcmd *-to]
113113
set branchIndex [lsearch -glob $fossilcmd *-branch]
114114
set checkinIndex [lsearch -glob $fossilcmd *-checkin]
115
- set fA {base check-in}
115
+ if {[string match *?--external-baseline* $fossilcmd]} {
116
+ set fA {external baseline}
117
+ } else {
118
+ set fA {base check-in}
119
+ }
116120
set fB {current check-out}
117121
if {$fromIndex > -1} {set fA [lindex $fossilcmd $fromIndex+1]}
118122
if {$toIndex > -1} {set fB [lindex $fossilcmd $toIndex+1]}
119123
if {$branchIndex > -1} {set fA "branch point"; set fB "leaf of branch '[lindex $fossilcmd $branchIndex+1]'"}
120124
if {$checkinIndex > -1} {set fA "primary parent"; set fB [lindex $fossilcmd $checkinIndex+1]}
121125
--- src/diff.tcl
+++ src/diff.tcl
@@ -110,11 +110,15 @@
110
111 set fromIndex [lsearch -glob $fossilcmd *-from]
112 set toIndex [lsearch -glob $fossilcmd *-to]
113 set branchIndex [lsearch -glob $fossilcmd *-branch]
114 set checkinIndex [lsearch -glob $fossilcmd *-checkin]
115 set fA {base check-in}
 
 
 
 
116 set fB {current check-out}
117 if {$fromIndex > -1} {set fA [lindex $fossilcmd $fromIndex+1]}
118 if {$toIndex > -1} {set fB [lindex $fossilcmd $toIndex+1]}
119 if {$branchIndex > -1} {set fA "branch point"; set fB "leaf of branch '[lindex $fossilcmd $branchIndex+1]'"}
120 if {$checkinIndex > -1} {set fA "primary parent"; set fB [lindex $fossilcmd $checkinIndex+1]}
121
--- src/diff.tcl
+++ src/diff.tcl
@@ -110,11 +110,15 @@
110
111 set fromIndex [lsearch -glob $fossilcmd *-from]
112 set toIndex [lsearch -glob $fossilcmd *-to]
113 set branchIndex [lsearch -glob $fossilcmd *-branch]
114 set checkinIndex [lsearch -glob $fossilcmd *-checkin]
115 if {[string match *?--external-baseline* $fossilcmd]} {
116 set fA {external baseline}
117 } else {
118 set fA {base check-in}
119 }
120 set fB {current check-out}
121 if {$fromIndex > -1} {set fA [lindex $fossilcmd $fromIndex+1]}
122 if {$toIndex > -1} {set fB [lindex $fossilcmd $toIndex+1]}
123 if {$branchIndex > -1} {set fA "branch point"; set fB "leaf of branch '[lindex $fossilcmd $branchIndex+1]'"}
124 if {$checkinIndex > -1} {set fA "primary parent"; set fB [lindex $fossilcmd $checkinIndex+1]}
125
+28 -27
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -1095,51 +1095,52 @@
10951095
/*
10961096
** Compute the difference from an external tree of files to the current
10971097
** working checkout with its edits.
10981098
**
10991099
** To put it another way: Every managed file in the current working
1100
-** checkout is compared to the file with same under in zTree. The zTree
1101
-** files are on the left and the files in the current working directory
1102
-** are on the right.
1100
+** checkout is compared to the file with same under in zExternBase. The
1101
+** zExternBase files are on the left and the files in the current working
1102
+** directory are on the right.
11031103
*/
1104
-void diff_tree_to_checkout(
1105
- const char *zExternTree, /* Remote tree to use as the baseline */
1104
+void diff_externbase_to_checkout(
1105
+ const char *zExternBase, /* Remote tree to use as the baseline */
11061106
DiffConfig *pCfg, /* Diff settings */
11071107
FileDirList *pFileDir /* Only look at these files */
11081108
){
11091109
int vid;
11101110
Stmt q;
11111111
11121112
vid = db_lget_int("checkout",0);
1113
- if( file_isdir(zExternTree, ExtFILE)!=1 ){
1114
- fossil_fatal("\"%s\" is not a directory", zExternTree);
1113
+ if( file_isdir(zExternBase, ExtFILE)!=1 ){
1114
+ fossil_fatal("\"%s\" is not a directory", zExternBase);
11151115
}
11161116
db_prepare(&q,
11171117
"SELECT pathname FROM vfile WHERE vid=%d ORDER BY pathname",
11181118
vid
11191119
);
11201120
while( db_step(&q)==SQLITE_ROW ){
1121
- const char *zTreename = db_column_text(&q,0); /* Repo tree name of file */
1122
- char *zLhs; /* Full name of left-hand side file */
1123
- char *zRhs; /* Full name of right-hand side file */
1124
- Blob rhs; /* Full text of RHS */
1125
- Blob lhs; /* Full text of LHS */
1126
-
1127
- if( !file_dir_match(pFileDir, zTreename) ) continue;
1128
- zLhs = mprintf("%s/%s", zExternTree, zTreename);
1129
- zRhs = mprintf("%s%s", g.zLocalRoot, zTreename);
1121
+ const char *zFile; /* Name of file in the repository */
1122
+ char *zLhs; /* Full name of left-hand side file */
1123
+ char *zRhs; /* Full name of right-hand side file */
1124
+ Blob rhs; /* Full text of RHS */
1125
+ Blob lhs; /* Full text of LHS */
1126
+
1127
+ zFile = db_column_text(&q,0);
1128
+ if( !file_dir_match(pFileDir, zFile) ) continue;
1129
+ zLhs = mprintf("%s/%s", zExternBase, zFile);
1130
+ zRhs = mprintf("%s%s", g.zLocalRoot, zFile);
11301131
if( file_size(zLhs, ExtFILE)<0 ){
11311132
blob_zero(&lhs);
11321133
}else{
11331134
blob_read_from_file(&lhs, zLhs, ExtFILE);
11341135
}
11351136
blob_read_from_file(&rhs, zRhs, ExtFILE);
11361137
if( blob_size(&lhs)!=blob_size(&rhs)
11371138
|| memcmp(blob_buffer(&lhs), blob_buffer(&rhs), blob_size(&lhs))!=0
11381139
){
1139
- diff_print_index(zTreename, pCfg, 0);
1140
- diff_file_mem(&lhs, &rhs, zTreename, pCfg);
1140
+ diff_print_index(zFile, pCfg, 0);
1141
+ diff_file_mem(&lhs, &rhs, zFile, pCfg);
11411142
}
11421143
blob_reset(&lhs);
11431144
blob_reset(&rhs);
11441145
fossil_free(zLhs);
11451146
fossil_free(zRhs);
@@ -1327,12 +1328,12 @@
13271328
** --strip-trailing-cr Strip trailing CR
13281329
** --tcl Tcl-formatted output used internally by --tk
13291330
** --tclsh PATH Tcl/Tk shell used for --tk (default: "tclsh")
13301331
** --tk Launch a Tcl/Tk GUI for display
13311332
** --to VERSION Select VERSION as target for the diff
1332
-** --tree DIR Use files under DIR as the baseline
1333
-** --undo Diff against the "undo" buffer
1333
+** --external-baseline DIR Use files under DIR as the baseline
1334
+** --undo Use the undo buffer as the baseline
13341335
** --unified Unified diff
13351336
** -v|--verbose Output complete text of added or deleted files
13361337
** -h|--versions Show compared versions in the diff header
13371338
** --webpage Format output as a stand-alone HTML webpage
13381339
** -W|--width N Width of lines in side-by-side diff
@@ -1342,11 +1343,11 @@
13421343
int isGDiff; /* True for gdiff. False for normal diff */
13431344
const char *zFrom; /* Source version number */
13441345
const char *zTo; /* Target version number */
13451346
const char *zCheckin; /* Check-in version number */
13461347
const char *zBranch; /* Branch to diff */
1347
- const char *zTree; /* The --tree */
1348
+ const char *zExBase; /* The --external-baseline option */
13481349
int againstUndo = 0; /* Diff against files in the undo buffer */
13491350
FileDirList *pFileDir = 0; /* Restrict the diff to these files */
13501351
DiffConfig DCfg; /* Diff configuration object */
13511352
13521353
if( find_option("tk",0,0)!=0 || has_option("tclsh") ){
@@ -1356,15 +1357,15 @@
13561357
isGDiff = g.argv[1][0]=='g';
13571358
zFrom = find_option("from", "r", 1);
13581359
zTo = find_option("to", 0, 1);
13591360
zCheckin = find_option("checkin", "ci", 1);
13601361
zBranch = find_option("branch", 0, 1);
1361
- zTree = find_option("tree", 0, 1);
1362
+ zExBase = find_option("external-baseline", 0, 1);
13621363
againstUndo = find_option("undo",0,0)!=0;
1363
- if( zTree && (zFrom || zTo || zCheckin || zBranch || againstUndo) ){
1364
- fossil_fatal("cannot use --tree together with --from, --to, --checkin,"
1365
- " --branch, or --undo");
1364
+ if( zExBase && (zFrom || zTo || zCheckin || zBranch || againstUndo) ){
1365
+ fossil_fatal("cannot use --external-baseline together with any of"
1366
+ " --from, --to, --checkin, --branch, or --undo");
13661367
}
13671368
if( againstUndo && (zFrom!=0 || zTo!=0 || zCheckin!=0 || zBranch!=0) ){
13681369
fossil_fatal("cannot use --undo together with --from, --to, --checkin,"
13691370
" or --branch");
13701371
}
@@ -1421,12 +1422,12 @@
14211422
if( zFrom==0 ){
14221423
fossil_fatal("check-in %s has no parent", zTo);
14231424
}
14241425
}
14251426
diff_begin(&DCfg);
1426
- if( zTree ){
1427
- diff_tree_to_checkout(zTree, &DCfg, pFileDir);
1427
+ if( zExBase ){
1428
+ diff_externbase_to_checkout(zExBase, &DCfg, pFileDir);
14281429
}else if( againstUndo ){
14291430
if( db_lget_int("undo_available",0)==0 ){
14301431
fossil_print("No undo or redo is available\n");
14311432
return;
14321433
}
14331434
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -1095,51 +1095,52 @@
1095 /*
1096 ** Compute the difference from an external tree of files to the current
1097 ** working checkout with its edits.
1098 **
1099 ** To put it another way: Every managed file in the current working
1100 ** checkout is compared to the file with same under in zTree. The zTree
1101 ** files are on the left and the files in the current working directory
1102 ** are on the right.
1103 */
1104 void diff_tree_to_checkout(
1105 const char *zExternTree, /* Remote tree to use as the baseline */
1106 DiffConfig *pCfg, /* Diff settings */
1107 FileDirList *pFileDir /* Only look at these files */
1108 ){
1109 int vid;
1110 Stmt q;
1111
1112 vid = db_lget_int("checkout",0);
1113 if( file_isdir(zExternTree, ExtFILE)!=1 ){
1114 fossil_fatal("\"%s\" is not a directory", zExternTree);
1115 }
1116 db_prepare(&q,
1117 "SELECT pathname FROM vfile WHERE vid=%d ORDER BY pathname",
1118 vid
1119 );
1120 while( db_step(&q)==SQLITE_ROW ){
1121 const char *zTreename = db_column_text(&q,0); /* Repo tree name of file */
1122 char *zLhs; /* Full name of left-hand side file */
1123 char *zRhs; /* Full name of right-hand side file */
1124 Blob rhs; /* Full text of RHS */
1125 Blob lhs; /* Full text of LHS */
1126
1127 if( !file_dir_match(pFileDir, zTreename) ) continue;
1128 zLhs = mprintf("%s/%s", zExternTree, zTreename);
1129 zRhs = mprintf("%s%s", g.zLocalRoot, zTreename);
 
1130 if( file_size(zLhs, ExtFILE)<0 ){
1131 blob_zero(&lhs);
1132 }else{
1133 blob_read_from_file(&lhs, zLhs, ExtFILE);
1134 }
1135 blob_read_from_file(&rhs, zRhs, ExtFILE);
1136 if( blob_size(&lhs)!=blob_size(&rhs)
1137 || memcmp(blob_buffer(&lhs), blob_buffer(&rhs), blob_size(&lhs))!=0
1138 ){
1139 diff_print_index(zTreename, pCfg, 0);
1140 diff_file_mem(&lhs, &rhs, zTreename, pCfg);
1141 }
1142 blob_reset(&lhs);
1143 blob_reset(&rhs);
1144 fossil_free(zLhs);
1145 fossil_free(zRhs);
@@ -1327,12 +1328,12 @@
1327 ** --strip-trailing-cr Strip trailing CR
1328 ** --tcl Tcl-formatted output used internally by --tk
1329 ** --tclsh PATH Tcl/Tk shell used for --tk (default: "tclsh")
1330 ** --tk Launch a Tcl/Tk GUI for display
1331 ** --to VERSION Select VERSION as target for the diff
1332 ** --tree DIR Use files under DIR as the baseline
1333 ** --undo Diff against the "undo" buffer
1334 ** --unified Unified diff
1335 ** -v|--verbose Output complete text of added or deleted files
1336 ** -h|--versions Show compared versions in the diff header
1337 ** --webpage Format output as a stand-alone HTML webpage
1338 ** -W|--width N Width of lines in side-by-side diff
@@ -1342,11 +1343,11 @@
1342 int isGDiff; /* True for gdiff. False for normal diff */
1343 const char *zFrom; /* Source version number */
1344 const char *zTo; /* Target version number */
1345 const char *zCheckin; /* Check-in version number */
1346 const char *zBranch; /* Branch to diff */
1347 const char *zTree; /* The --tree */
1348 int againstUndo = 0; /* Diff against files in the undo buffer */
1349 FileDirList *pFileDir = 0; /* Restrict the diff to these files */
1350 DiffConfig DCfg; /* Diff configuration object */
1351
1352 if( find_option("tk",0,0)!=0 || has_option("tclsh") ){
@@ -1356,15 +1357,15 @@
1356 isGDiff = g.argv[1][0]=='g';
1357 zFrom = find_option("from", "r", 1);
1358 zTo = find_option("to", 0, 1);
1359 zCheckin = find_option("checkin", "ci", 1);
1360 zBranch = find_option("branch", 0, 1);
1361 zTree = find_option("tree", 0, 1);
1362 againstUndo = find_option("undo",0,0)!=0;
1363 if( zTree && (zFrom || zTo || zCheckin || zBranch || againstUndo) ){
1364 fossil_fatal("cannot use --tree together with --from, --to, --checkin,"
1365 " --branch, or --undo");
1366 }
1367 if( againstUndo && (zFrom!=0 || zTo!=0 || zCheckin!=0 || zBranch!=0) ){
1368 fossil_fatal("cannot use --undo together with --from, --to, --checkin,"
1369 " or --branch");
1370 }
@@ -1421,12 +1422,12 @@
1421 if( zFrom==0 ){
1422 fossil_fatal("check-in %s has no parent", zTo);
1423 }
1424 }
1425 diff_begin(&DCfg);
1426 if( zTree ){
1427 diff_tree_to_checkout(zTree, &DCfg, pFileDir);
1428 }else if( againstUndo ){
1429 if( db_lget_int("undo_available",0)==0 ){
1430 fossil_print("No undo or redo is available\n");
1431 return;
1432 }
1433
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -1095,51 +1095,52 @@
1095 /*
1096 ** Compute the difference from an external tree of files to the current
1097 ** working checkout with its edits.
1098 **
1099 ** To put it another way: Every managed file in the current working
1100 ** checkout is compared to the file with same under in zExternBase. The
1101 ** zExternBase files are on the left and the files in the current working
1102 ** directory are on the right.
1103 */
1104 void diff_externbase_to_checkout(
1105 const char *zExternBase, /* Remote tree to use as the baseline */
1106 DiffConfig *pCfg, /* Diff settings */
1107 FileDirList *pFileDir /* Only look at these files */
1108 ){
1109 int vid;
1110 Stmt q;
1111
1112 vid = db_lget_int("checkout",0);
1113 if( file_isdir(zExternBase, ExtFILE)!=1 ){
1114 fossil_fatal("\"%s\" is not a directory", zExternBase);
1115 }
1116 db_prepare(&q,
1117 "SELECT pathname FROM vfile WHERE vid=%d ORDER BY pathname",
1118 vid
1119 );
1120 while( db_step(&q)==SQLITE_ROW ){
1121 const char *zFile; /* Name of file in the repository */
1122 char *zLhs; /* Full name of left-hand side file */
1123 char *zRhs; /* Full name of right-hand side file */
1124 Blob rhs; /* Full text of RHS */
1125 Blob lhs; /* Full text of LHS */
1126
1127 zFile = db_column_text(&q,0);
1128 if( !file_dir_match(pFileDir, zFile) ) continue;
1129 zLhs = mprintf("%s/%s", zExternBase, zFile);
1130 zRhs = mprintf("%s%s", g.zLocalRoot, zFile);
1131 if( file_size(zLhs, ExtFILE)<0 ){
1132 blob_zero(&lhs);
1133 }else{
1134 blob_read_from_file(&lhs, zLhs, ExtFILE);
1135 }
1136 blob_read_from_file(&rhs, zRhs, ExtFILE);
1137 if( blob_size(&lhs)!=blob_size(&rhs)
1138 || memcmp(blob_buffer(&lhs), blob_buffer(&rhs), blob_size(&lhs))!=0
1139 ){
1140 diff_print_index(zFile, pCfg, 0);
1141 diff_file_mem(&lhs, &rhs, zFile, pCfg);
1142 }
1143 blob_reset(&lhs);
1144 blob_reset(&rhs);
1145 fossil_free(zLhs);
1146 fossil_free(zRhs);
@@ -1327,12 +1328,12 @@
1328 ** --strip-trailing-cr Strip trailing CR
1329 ** --tcl Tcl-formatted output used internally by --tk
1330 ** --tclsh PATH Tcl/Tk shell used for --tk (default: "tclsh")
1331 ** --tk Launch a Tcl/Tk GUI for display
1332 ** --to VERSION Select VERSION as target for the diff
1333 ** --external-baseline DIR Use files under DIR as the baseline
1334 ** --undo Use the undo buffer as the baseline
1335 ** --unified Unified diff
1336 ** -v|--verbose Output complete text of added or deleted files
1337 ** -h|--versions Show compared versions in the diff header
1338 ** --webpage Format output as a stand-alone HTML webpage
1339 ** -W|--width N Width of lines in side-by-side diff
@@ -1342,11 +1343,11 @@
1343 int isGDiff; /* True for gdiff. False for normal diff */
1344 const char *zFrom; /* Source version number */
1345 const char *zTo; /* Target version number */
1346 const char *zCheckin; /* Check-in version number */
1347 const char *zBranch; /* Branch to diff */
1348 const char *zExBase; /* The --external-baseline option */
1349 int againstUndo = 0; /* Diff against files in the undo buffer */
1350 FileDirList *pFileDir = 0; /* Restrict the diff to these files */
1351 DiffConfig DCfg; /* Diff configuration object */
1352
1353 if( find_option("tk",0,0)!=0 || has_option("tclsh") ){
@@ -1356,15 +1357,15 @@
1357 isGDiff = g.argv[1][0]=='g';
1358 zFrom = find_option("from", "r", 1);
1359 zTo = find_option("to", 0, 1);
1360 zCheckin = find_option("checkin", "ci", 1);
1361 zBranch = find_option("branch", 0, 1);
1362 zExBase = find_option("external-baseline", 0, 1);
1363 againstUndo = find_option("undo",0,0)!=0;
1364 if( zExBase && (zFrom || zTo || zCheckin || zBranch || againstUndo) ){
1365 fossil_fatal("cannot use --external-baseline together with any of"
1366 " --from, --to, --checkin, --branch, or --undo");
1367 }
1368 if( againstUndo && (zFrom!=0 || zTo!=0 || zCheckin!=0 || zBranch!=0) ){
1369 fossil_fatal("cannot use --undo together with --from, --to, --checkin,"
1370 " or --branch");
1371 }
@@ -1421,12 +1422,12 @@
1422 if( zFrom==0 ){
1423 fossil_fatal("check-in %s has no parent", zTo);
1424 }
1425 }
1426 diff_begin(&DCfg);
1427 if( zExBase ){
1428 diff_externbase_to_checkout(zExBase, &DCfg, pFileDir);
1429 }else if( againstUndo ){
1430 if( db_lget_int("undo_available",0)==0 ){
1431 fossil_print("No undo or redo is available\n");
1432 return;
1433 }
1434

Keyboard Shortcuts

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