Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | When calling gdiff (or stash gdiff) command between 2 versions, use the
filename to prefix the temporary random filename so once inside the external
diff program we know what file is being compared.
(pending-review) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | gdiff-tmpfilename-prefix |
Files: | files | file ages | folders |
SHA1: |
856ca01b1309db47e688173291d10563 |
User & Date: | mgagnon 2016-12-21 17:50:04.488 |
Context
2016-12-23
| ||
23:42 | When doing a gdiff between two versions, use the files being diffed as a basis for the temporary filenames that are constructed. ... (check-in: 051d0aba user: drh tags: trunk) | |
2016-12-21
| ||
17:50 |
When calling gdiff (or stash gdiff) command between 2 versions, use the
filename to prefix the temporary random filename so once inside the external
diff program we know what file is being compared.
(pending-review) ... (Closed-Leaf check-in: 856ca01b user: mgagnon tags: gdiff-tmpfilename-prefix) | |
2016-12-19
| ||
07:04 | Enhance TH1 'redirect' command to support for HTTP redirects with a status code of 307. ... (check-in: bee6dbde user: mistachkin tags: trunk) | |
Changes
Changes to src/diffcmd.c.
︙ | ︙ | |||
301 302 303 304 305 306 307 | diff_print_filenames(zName, zName, diffFlags); fossil_print("%s\n", blob_str(&out)); /* Release memory resources */ blob_reset(&out); }else{ Blob cmd; | | | > > | > > > > > > | | | | | | | | > > > > > | 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | diff_print_filenames(zName, zName, diffFlags); fossil_print("%s\n", blob_str(&out)); /* Release memory resources */ blob_reset(&out); }else{ Blob cmd; Blob temp1; Blob temp2; Blob prefix1; Blob prefix2; if( !fIncludeBinary ){ if( isBin1 || isBin2 ){ fossil_print("%s",DIFF_CANNOT_COMPUTE_BINARY); return; } if( zBinGlob ){ Glob *pBinary = glob_create(zBinGlob); if( glob_match(pBinary, zName) ){ fossil_print("%s",DIFF_CANNOT_COMPUTE_BINARY); glob_free(pBinary); return; } glob_free(pBinary); } } /* Construct a prefix for the temporary file names */ blob_zero(&prefix1); blob_zero(&prefix2); blob_appendf(&prefix1, "%s-v1", zName); blob_appendf(&prefix2, "%s-v2", zName); /* Construct a temporary file names */ file_tempname(&temp1, blob_str(&prefix1)); file_tempname(&temp2, blob_str(&prefix2)); blob_write_to_file(pFile1, blob_str(&temp1)); blob_write_to_file(pFile2, blob_str(&temp2)); /* Construct the external diff command */ blob_zero(&cmd); blob_appendf(&cmd, "%s ", zDiffCmd); shell_escape(&cmd, blob_str(&temp1)); blob_append(&cmd, " ", 1); shell_escape(&cmd, blob_str(&temp2)); /* Run the external diff command */ fossil_system(blob_str(&cmd)); /* Delete the temporary file and clean up memory used */ file_delete(blob_str(&temp1)); file_delete(blob_str(&temp2)); blob_reset(&prefix1); blob_reset(&prefix2); blob_reset(&temp1); blob_reset(&temp2); blob_reset(&cmd); } } /* ** Run a diff between the version zFrom and files on disk. zFrom might ** be NULL which means to simply show the difference between the edited |
︙ | ︙ |
Changes to src/file.c.
︙ | ︙ | |||
1249 1250 1251 1252 1253 1254 1255 | blob_set(pPath, &zUri[i]); }else{ blob_set(pPath, "/"); } } /* | | | | > < < < < < < < > < < | | | | > | | 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 | blob_set(pPath, &zUri[i]); }else{ blob_set(pPath, "/"); } } /* ** Construct a random temporary filename into pBuf starting with zPrefix. */ void file_tempname(Blob *pBuf, const char *zPrefix){ #if defined(_WIN32) const char *azDirs[] = { 0, /* GetTempPath */ 0, /* TEMP */ 0, /* TMP */ ".", }; #else static const char *const azDirs[] = { "/var/tmp", "/usr/tmp", "/tmp", "/temp", ".", }; #endif static const unsigned char zChars[] = "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789"; unsigned int i; const char *zDir = "."; int cnt = 0; char zRand[16]; #if defined(_WIN32) wchar_t zTmpPath[MAX_PATH]; if( GetTempPathW(MAX_PATH, zTmpPath) ){ azDirs[0] = fossil_path_to_utf8(zTmpPath); } azDirs[1] = fossil_getenv("TEMP"); azDirs[2] = fossil_getenv("TMP"); #endif for(i=0; i<count(azDirs); i++){ if( azDirs[i]==0 ) continue; if( !file_isdir(azDirs[i]) ) continue; zDir = azDirs[i]; break; } do{ blob_zero(pBuf); if( cnt++>20 ) fossil_panic("cannot generate a temporary filename"); sqlite3_randomness(15, zRand); for(i=0; i<15; i++){ zRand[i] = (char)zChars[ ((unsigned char)zRand[i])%(sizeof(zChars)-1) ]; } zRand[15] = 0; blob_appendf(pBuf, "%s/%s.%s", zDir, zPrefix ? zPrefix : "", zRand); }while( file_size(blob_str(pBuf))>=0 ); #if defined(_WIN32) fossil_path_free((char *)azDirs[0]); fossil_path_free((char *)azDirs[1]); fossil_path_free((char *)azDirs[2]); #endif } |
︙ | ︙ |
Changes to src/merge.c.
︙ | ︙ | |||
735 736 737 738 739 740 741 | char *zFullOldPath, *zFullNewPath; zFullOldPath = db_text(0,"SELECT tmpfn FROM tmprn WHERE fn=%Q", zOldName); if( !zFullOldPath ){ zFullOldPath = mprintf("%s%s", g.zLocalRoot, zOldName); } zFullNewPath = mprintf("%s%s", g.zLocalRoot, zNewName); if( file_wd_size(zFullNewPath)>=0 ){ | | | | | | > | 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 | char *zFullOldPath, *zFullNewPath; zFullOldPath = db_text(0,"SELECT tmpfn FROM tmprn WHERE fn=%Q", zOldName); if( !zFullOldPath ){ zFullOldPath = mprintf("%s%s", g.zLocalRoot, zOldName); } zFullNewPath = mprintf("%s%s", g.zLocalRoot, zNewName); if( file_wd_size(zFullNewPath)>=0 ){ Blob tmpPath; file_tempname(&tmpPath, ""); db_multi_exec("INSERT INTO tmprn(fn,tmpfn) VALUES(%Q,%Q)", zNewName, blob_str(&tmpPath)); if( file_wd_islink(zFullNewPath) ){ symlink_copy(zFullNewPath, blob_str(&tmpPath)); }else{ file_copy(zFullNewPath, blob_str(&tmpPath)); } blob_reset(&tmpPath); } if( file_wd_islink(zFullOldPath) ){ symlink_copy(zFullOldPath, zFullNewPath); }else{ file_copy(zFullOldPath, zFullNewPath); } file_wd_setexe(zFullNewPath, isExe); |
︙ | ︙ |