| | @@ -1043,16 +1043,26 @@ |
| 1043 | 1043 | ){ |
| 1044 | 1044 | Manifest *pFrom, *pTo; |
| 1045 | 1045 | ManifestFile *pFromFile, *pToFile; |
| 1046 | 1046 | int asNewFlag = (pCfg->diffFlags & (DIFF_VERBOSE|DIFF_NUMSTAT))!=0 ? 1 : 0; |
| 1047 | 1047 | |
| 1048 | | - pFrom = manifest_get_by_name(zFrom, 0); |
| 1048 | + if( pCfg->diffFlags & DIFF_FROM_CKOUT ){ |
| 1049 | + fossil_fatal("The --from-ckout option is not yet implemented"); |
| 1050 | + }else{ |
| 1051 | + pFrom = manifest_get_by_name(zFrom, 0); |
| 1052 | + } |
| 1049 | 1053 | manifest_file_rewind(pFrom); |
| 1050 | 1054 | pFromFile = manifest_file_next(pFrom,0); |
| 1051 | | - pTo = manifest_get_by_name(zTo, 0); |
| 1055 | + |
| 1056 | + if( pCfg->diffFlags & DIFF_TO_CKOUT ){ |
| 1057 | + fossil_fatal("The --to-ckout option is not yet implemented"); |
| 1058 | + }else{ |
| 1059 | + pTo = manifest_get_by_name(zTo, 0); |
| 1060 | + } |
| 1052 | 1061 | manifest_file_rewind(pTo); |
| 1053 | 1062 | pToFile = manifest_file_next(pTo,0); |
| 1063 | + |
| 1054 | 1064 | if( (pCfg->diffFlags & DIFF_SHOW_VERS)!=0 ){ |
| 1055 | 1065 | diff_print_versions(zFrom, zTo, pCfg); |
| 1056 | 1066 | } |
| 1057 | 1067 | while( pFromFile || pToFile ){ |
| 1058 | 1068 | int cmp; |
| | @@ -1274,10 +1284,11 @@ |
| 1274 | 1284 | ** --dark Use dark mode for the Tcl/Tk-based GUI and HTML |
| 1275 | 1285 | ** --diff-binary BOOL Include binary files with external commands |
| 1276 | 1286 | ** --exec-abs-paths Force absolute path names on external commands |
| 1277 | 1287 | ** --exec-rel-paths Force relative path names on external commands |
| 1278 | 1288 | ** -r|--from VERSION Select VERSION as source for the diff |
| 1289 | +** --from-ckout PATH Path to foreign checkout to use as source |
| 1279 | 1290 | ** -w|--ignore-all-space Ignore white space when comparing lines |
| 1280 | 1291 | ** -i|--internal Use internal diff logic |
| 1281 | 1292 | ** --invert Invert the diff |
| 1282 | 1293 | ** --json Output formatted as JSON |
| 1283 | 1294 | ** -n|--linenum Show line numbers |
| | @@ -1287,10 +1298,11 @@ |
| 1287 | 1298 | ** --strip-trailing-cr Strip trailing CR |
| 1288 | 1299 | ** --tcl Tcl-formatted output used internally by --tk |
| 1289 | 1300 | ** --tclsh PATH Tcl/Tk shell used for --tk (default: "tclsh") |
| 1290 | 1301 | ** --tk Launch a Tcl/Tk GUI for display |
| 1291 | 1302 | ** --to VERSION Select VERSION as target for the diff |
| 1303 | +** --to-ckout PATH Path to foreign checkout to use as target |
| 1292 | 1304 | ** --undo Diff against the "undo" buffer |
| 1293 | 1305 | ** --unified Unified diff |
| 1294 | 1306 | ** -v|--verbose Output complete text of added or deleted files |
| 1295 | 1307 | ** -h|--versions Show compared versions in the diff header |
| 1296 | 1308 | ** --webpage Format output as a stand-alone HTML webpage |
| | @@ -1299,10 +1311,12 @@ |
| 1299 | 1311 | */ |
| 1300 | 1312 | void diff_cmd(void){ |
| 1301 | 1313 | int isGDiff; /* True for gdiff. False for normal diff */ |
| 1302 | 1314 | const char *zFrom; /* Source version number */ |
| 1303 | 1315 | const char *zTo; /* Target version number */ |
| 1316 | + const char *zFromCkout; /* Foreign check-out for the from side */ |
| 1317 | + const char *zToCkout; /* Foreign check-out for the to side */ |
| 1304 | 1318 | const char *zCheckin; /* Check-in version number */ |
| 1305 | 1319 | const char *zBranch; /* Branch to diff */ |
| 1306 | 1320 | int againstUndo = 0; /* Diff against files in the undo buffer */ |
| 1307 | 1321 | FileDirList *pFileDir = 0; /* Restrict the diff to these files */ |
| 1308 | 1322 | DiffConfig DCfg; /* Diff configuration object */ |
| | @@ -1310,18 +1324,36 @@ |
| 1310 | 1324 | if( find_option("tk",0,0)!=0 || has_option("tclsh") ){ |
| 1311 | 1325 | diff_tk("diff", 2); |
| 1312 | 1326 | return; |
| 1313 | 1327 | } |
| 1314 | 1328 | isGDiff = g.argv[1][0]=='g'; |
| 1329 | + diff_options(&DCfg, isGDiff, 0); |
| 1315 | 1330 | zFrom = find_option("from", "r", 1); |
| 1316 | 1331 | zTo = find_option("to", 0, 1); |
| 1332 | + zFromCkout = find_option("from-ckout", 0, 1); |
| 1333 | + zToCkout = find_option("to-ckout", 0, 1); |
| 1317 | 1334 | zCheckin = find_option("checkin", "ci", 1); |
| 1318 | 1335 | zBranch = find_option("branch", 0, 1); |
| 1319 | 1336 | againstUndo = find_option("undo",0,0)!=0; |
| 1337 | + if( zFromCkout ){ |
| 1338 | + if( zFrom || zCheckin || zBranch || againstUndo ){ |
| 1339 | + fossil_fatal("cannot use --from-ckout with --from, --checkin, --branch," |
| 1340 | + " or --undo"); |
| 1341 | + } |
| 1342 | + DCfg.diffFlags |= DIFF_FROM_CKOUT; |
| 1343 | + zFrom = zFromCkout; |
| 1344 | + } |
| 1345 | + if( zToCkout ){ |
| 1346 | + if( zTo || zBranch || againstUndo ){ |
| 1347 | + fossil_fatal("cannot use --from-ckout with --to, --branch or --undo"); |
| 1348 | + } |
| 1349 | + DCfg.diffFlags |= DIFF_TO_CKOUT; |
| 1350 | + zTo = zToCkout; |
| 1351 | + } |
| 1320 | 1352 | if( againstUndo && ( zFrom!=0 || zTo!=0 || zCheckin!=0 || zBranch!=0) ){ |
| 1321 | 1353 | fossil_fatal("cannot use --undo together with --from, --to, --checkin," |
| 1322 | | - " or --branch"); |
| 1354 | + " --branch, --from-ckout, or --to-ckout"); |
| 1323 | 1355 | } |
| 1324 | 1356 | if( zBranch ){ |
| 1325 | 1357 | if( zTo || zFrom || zCheckin ){ |
| 1326 | 1358 | fossil_fatal("cannot use --from, --to, or --checkin with --branch"); |
| 1327 | 1359 | } |
| | @@ -1329,11 +1361,10 @@ |
| 1329 | 1361 | zFrom = mprintf("root:%s", zBranch); |
| 1330 | 1362 | } |
| 1331 | 1363 | if( zCheckin!=0 && ( zFrom!=0 || zTo!=0 ) ){ |
| 1332 | 1364 | fossil_fatal("cannot use --checkin together with --from or --to"); |
| 1333 | 1365 | } |
| 1334 | | - diff_options(&DCfg, isGDiff, 0); |
| 1335 | 1366 | determine_exec_relative_option(1); |
| 1336 | 1367 | if( 0==zCheckin ){ |
| 1337 | 1368 | if( zTo==0 || againstUndo ){ |
| 1338 | 1369 | db_must_be_within_tree(); |
| 1339 | 1370 | }else if( zFrom==0 ){ |
| 1340 | 1371 | |