Fossil SCM

Do not run the graphical merging tool nor leave merge-droppings after a dry-run merge. Also improve the merge summary message at the end of a merge.

drh 2012-11-05 21:10 trunk
Commit cd2c0e4cb503b0031ba5e17f0b46abeccf15509b
+12 -9
--- src/merge.c
+++ src/merge.c
@@ -457,11 +457,12 @@
457457
content_get(ridm, &m);
458458
if( isBinary ){
459459
rc = -1;
460460
blob_zero(&r);
461461
}else{
462
- rc = merge_3way(&p, zFullPath, &m, &r);
462
+ unsigned mergeFlags = nochangeFlag ? MERGE_DRYRUN : 0;
463
+ rc = merge_3way(&p, zFullPath, &m, &r, mergeFlags);
463464
}
464465
if( rc>=0 ){
465466
if( !nochangeFlag ){
466467
blob_write_to_file(&r, zFullPath);
467468
file_wd_setexe(zFullPath, isExe);
@@ -549,18 +550,20 @@
549550
db_finalize(&q);
550551
551552
552553
/* Report on conflicts
553554
*/
554
- if( !nochangeFlag ){
555
- if( nConflict ){
556
- fossil_print("WARNING: %d merge conflicts", nConflict);
557
- }
558
- if( nOverwrite ){
559
- fossil_warning("WARNING: %d unmanaged files were overwritten",
560
- nOverwrite);
561
- }
555
+ if( nConflict ){
556
+ fossil_warning("WARNING: %d merge conflicts", nConflict);
557
+ }
558
+ if( nOverwrite ){
559
+ fossil_warning("WARNING: %d unmanaged files were overwritten",
560
+ nOverwrite);
561
+ }
562
+ if( nochangeFlag ){
563
+ fossil_warning("REMINDER: this was a dry run -"
564
+ " no file were actually changed.");
562565
}
563566
564567
/*
565568
** Clean up the mid and pid VFILE entries. Then commit the changes.
566569
*/
567570
--- src/merge.c
+++ src/merge.c
@@ -457,11 +457,12 @@
457 content_get(ridm, &m);
458 if( isBinary ){
459 rc = -1;
460 blob_zero(&r);
461 }else{
462 rc = merge_3way(&p, zFullPath, &m, &r);
 
463 }
464 if( rc>=0 ){
465 if( !nochangeFlag ){
466 blob_write_to_file(&r, zFullPath);
467 file_wd_setexe(zFullPath, isExe);
@@ -549,18 +550,20 @@
549 db_finalize(&q);
550
551
552 /* Report on conflicts
553 */
554 if( !nochangeFlag ){
555 if( nConflict ){
556 fossil_print("WARNING: %d merge conflicts", nConflict);
557 }
558 if( nOverwrite ){
559 fossil_warning("WARNING: %d unmanaged files were overwritten",
560 nOverwrite);
561 }
 
 
562 }
563
564 /*
565 ** Clean up the mid and pid VFILE entries. Then commit the changes.
566 */
567
--- src/merge.c
+++ src/merge.c
@@ -457,11 +457,12 @@
457 content_get(ridm, &m);
458 if( isBinary ){
459 rc = -1;
460 blob_zero(&r);
461 }else{
462 unsigned mergeFlags = nochangeFlag ? MERGE_DRYRUN : 0;
463 rc = merge_3way(&p, zFullPath, &m, &r, mergeFlags);
464 }
465 if( rc>=0 ){
466 if( !nochangeFlag ){
467 blob_write_to_file(&r, zFullPath);
468 file_wd_setexe(zFullPath, isExe);
@@ -549,18 +550,20 @@
550 db_finalize(&q);
551
552
553 /* Report on conflicts
554 */
555 if( nConflict ){
556 fossil_warning("WARNING: %d merge conflicts", nConflict);
557 }
558 if( nOverwrite ){
559 fossil_warning("WARNING: %d unmanaged files were overwritten",
560 nOverwrite);
561 }
562 if( nochangeFlag ){
563 fossil_warning("REMINDER: this was a dry run -"
564 " no file were actually changed.");
565 }
566
567 /*
568 ** Clean up the mid and pid VFILE entries. Then commit the changes.
569 */
570
+12 -4
--- src/merge3.c
+++ src/merge3.c
@@ -406,10 +406,17 @@
406406
}
407407
}
408408
return blob_str(&x);
409409
}
410410
411
+#if INTERFACE
412
+/*
413
+** Flags to the 3-way merger
414
+*/
415
+#define MERGE_DRYRUN 0x0001
416
+#endif
417
+
411418
412419
/*
413420
** This routine is a wrapper around blob_merge() with the following
414421
** enhancements:
415422
**
@@ -428,29 +435,30 @@
428435
*/
429436
int merge_3way(
430437
Blob *pPivot, /* Common ancestor (older) */
431438
const char *zV1, /* Name of file for version merging into (mine) */
432439
Blob *pV2, /* Version merging from (yours) */
433
- Blob *pOut /* Output written here */
440
+ Blob *pOut, /* Output written here */
441
+ unsigned mergeFlags /* Flags that control operation */
434442
){
435443
Blob v1; /* Content of zV1 */
436444
int rc; /* Return code of subroutines and this routine */
437445
char *zPivot; /* Name of the pivot file */
438446
char *zOrig; /* Name of the original content file */
439447
char *zOther; /* Name of the merge file */
440448
441449
blob_read_from_file(&v1, zV1);
442450
rc = blob_merge(pPivot, &v1, pV2, pOut);
443
- if( rc!=0 ){
451
+ if( rc!=0 && (mergeFlags & MERGE_DRYRUN)==0 ){
444452
zPivot = file_newname(zV1, "baseline", 1);
445453
blob_write_to_file(pPivot, zPivot);
446454
zOrig = file_newname(zV1, "original", 1);
447455
blob_write_to_file(&v1, zOrig);
448456
zOther = file_newname(zV1, "merge", 1);
449457
blob_write_to_file(pV2, zOther);
450458
}
451
- if( rc>0 ){
459
+ if( rc>0 && (mergeFlags & MERGE_DRYRUN)==0 ){
452460
const char *zGMerge; /* Name of the gmerge command */
453461
454462
zGMerge = db_get("gmerge-command", 0);
455463
if( zGMerge && zGMerge[0] ){
456464
char *zOut; /* Temporary output file */
@@ -474,13 +482,13 @@
474482
}
475483
fossil_free(zCmd);
476484
fossil_free(zOut);
477485
}
478486
}
479
- if( rc!=0 ){
487
+ if( rc!=0 && (mergeFlags & MERGE_DRYRUN)==0 ){
480488
fossil_free(zPivot);
481489
fossil_free(zOrig);
482490
fossil_free(zOther);
483491
}
484492
blob_reset(&v1);
485493
return rc;
486494
}
487495
--- src/merge3.c
+++ src/merge3.c
@@ -406,10 +406,17 @@
406 }
407 }
408 return blob_str(&x);
409 }
410
 
 
 
 
 
 
 
411
412 /*
413 ** This routine is a wrapper around blob_merge() with the following
414 ** enhancements:
415 **
@@ -428,29 +435,30 @@
428 */
429 int merge_3way(
430 Blob *pPivot, /* Common ancestor (older) */
431 const char *zV1, /* Name of file for version merging into (mine) */
432 Blob *pV2, /* Version merging from (yours) */
433 Blob *pOut /* Output written here */
 
434 ){
435 Blob v1; /* Content of zV1 */
436 int rc; /* Return code of subroutines and this routine */
437 char *zPivot; /* Name of the pivot file */
438 char *zOrig; /* Name of the original content file */
439 char *zOther; /* Name of the merge file */
440
441 blob_read_from_file(&v1, zV1);
442 rc = blob_merge(pPivot, &v1, pV2, pOut);
443 if( rc!=0 ){
444 zPivot = file_newname(zV1, "baseline", 1);
445 blob_write_to_file(pPivot, zPivot);
446 zOrig = file_newname(zV1, "original", 1);
447 blob_write_to_file(&v1, zOrig);
448 zOther = file_newname(zV1, "merge", 1);
449 blob_write_to_file(pV2, zOther);
450 }
451 if( rc>0 ){
452 const char *zGMerge; /* Name of the gmerge command */
453
454 zGMerge = db_get("gmerge-command", 0);
455 if( zGMerge && zGMerge[0] ){
456 char *zOut; /* Temporary output file */
@@ -474,13 +482,13 @@
474 }
475 fossil_free(zCmd);
476 fossil_free(zOut);
477 }
478 }
479 if( rc!=0 ){
480 fossil_free(zPivot);
481 fossil_free(zOrig);
482 fossil_free(zOther);
483 }
484 blob_reset(&v1);
485 return rc;
486 }
487
--- src/merge3.c
+++ src/merge3.c
@@ -406,10 +406,17 @@
406 }
407 }
408 return blob_str(&x);
409 }
410
411 #if INTERFACE
412 /*
413 ** Flags to the 3-way merger
414 */
415 #define MERGE_DRYRUN 0x0001
416 #endif
417
418
419 /*
420 ** This routine is a wrapper around blob_merge() with the following
421 ** enhancements:
422 **
@@ -428,29 +435,30 @@
435 */
436 int merge_3way(
437 Blob *pPivot, /* Common ancestor (older) */
438 const char *zV1, /* Name of file for version merging into (mine) */
439 Blob *pV2, /* Version merging from (yours) */
440 Blob *pOut, /* Output written here */
441 unsigned mergeFlags /* Flags that control operation */
442 ){
443 Blob v1; /* Content of zV1 */
444 int rc; /* Return code of subroutines and this routine */
445 char *zPivot; /* Name of the pivot file */
446 char *zOrig; /* Name of the original content file */
447 char *zOther; /* Name of the merge file */
448
449 blob_read_from_file(&v1, zV1);
450 rc = blob_merge(pPivot, &v1, pV2, pOut);
451 if( rc!=0 && (mergeFlags & MERGE_DRYRUN)==0 ){
452 zPivot = file_newname(zV1, "baseline", 1);
453 blob_write_to_file(pPivot, zPivot);
454 zOrig = file_newname(zV1, "original", 1);
455 blob_write_to_file(&v1, zOrig);
456 zOther = file_newname(zV1, "merge", 1);
457 blob_write_to_file(pV2, zOther);
458 }
459 if( rc>0 && (mergeFlags & MERGE_DRYRUN)==0 ){
460 const char *zGMerge; /* Name of the gmerge command */
461
462 zGMerge = db_get("gmerge-command", 0);
463 if( zGMerge && zGMerge[0] ){
464 char *zOut; /* Temporary output file */
@@ -474,13 +482,13 @@
482 }
483 fossil_free(zCmd);
484 fossil_free(zOut);
485 }
486 }
487 if( rc!=0 && (mergeFlags & MERGE_DRYRUN)==0 ){
488 fossil_free(zPivot);
489 fossil_free(zOrig);
490 fossil_free(zOther);
491 }
492 blob_reset(&v1);
493 return rc;
494 }
495
+1 -1
--- src/stash.c
+++ src/stash.c
@@ -253,11 +253,11 @@
253253
if( isLink || isNewLink ){
254254
rc = -1;
255255
blob_zero(&b); /* because we reset it later */
256256
fossil_print("***** Cannot merge symlink %s\n", zNew);
257257
}else{
258
- rc = merge_3way(&a, zOPath, &b, &out);
258
+ rc = merge_3way(&a, zOPath, &b, &out, 0);
259259
blob_write_to_file(&out, zNPath);
260260
blob_reset(&out);
261261
file_wd_setexe(zNPath, isExec);
262262
}
263263
if( rc ){
264264
--- src/stash.c
+++ src/stash.c
@@ -253,11 +253,11 @@
253 if( isLink || isNewLink ){
254 rc = -1;
255 blob_zero(&b); /* because we reset it later */
256 fossil_print("***** Cannot merge symlink %s\n", zNew);
257 }else{
258 rc = merge_3way(&a, zOPath, &b, &out);
259 blob_write_to_file(&out, zNPath);
260 blob_reset(&out);
261 file_wd_setexe(zNPath, isExec);
262 }
263 if( rc ){
264
--- src/stash.c
+++ src/stash.c
@@ -253,11 +253,11 @@
253 if( isLink || isNewLink ){
254 rc = -1;
255 blob_zero(&b); /* because we reset it later */
256 fossil_print("***** Cannot merge symlink %s\n", zNew);
257 }else{
258 rc = merge_3way(&a, zOPath, &b, &out, 0);
259 blob_write_to_file(&out, zNPath);
260 blob_reset(&out);
261 file_wd_setexe(zNPath, isExec);
262 }
263 if( rc ){
264
+1 -1
--- src/undo.c
+++ src/undo.c
@@ -322,11 +322,11 @@
322322
** Complete the undo process is one is currently in process.
323323
*/
324324
void undo_finish(void){
325325
if( undoActive ){
326326
if( undoNeedRollback ){
327
- fossil_print("\"fossil undo\" is available to undo changes"
327
+ fossil_print(" \"fossil undo\" is available to undo changes"
328328
" to the working checkout.\n");
329329
}
330330
undoActive = 0;
331331
undoNeedRollback = 0;
332332
}
333333
--- src/undo.c
+++ src/undo.c
@@ -322,11 +322,11 @@
322 ** Complete the undo process is one is currently in process.
323 */
324 void undo_finish(void){
325 if( undoActive ){
326 if( undoNeedRollback ){
327 fossil_print("\"fossil undo\" is available to undo changes"
328 " to the working checkout.\n");
329 }
330 undoActive = 0;
331 undoNeedRollback = 0;
332 }
333
--- src/undo.c
+++ src/undo.c
@@ -322,11 +322,11 @@
322 ** Complete the undo process is one is currently in process.
323 */
324 void undo_finish(void){
325 if( undoActive ){
326 if( undoNeedRollback ){
327 fossil_print(" \"fossil undo\" is available to undo changes"
328 " to the working checkout.\n");
329 }
330 undoActive = 0;
331 undoNeedRollback = 0;
332 }
333
+2 -1
--- src/update.c
+++ src/update.c
@@ -423,14 +423,15 @@
423423
}
424424
if( islinkv || islinkt /* || file_wd_islink(zFullPath) */ ){
425425
fossil_print("***** Cannot merge symlink %s\n", zNewName);
426426
nConflict++;
427427
}else{
428
+ unsigned mergeFlags = nochangeFlag ? MERGE_DRYRUN : 0;
428429
undo_save(zName);
429430
content_get(ridt, &t);
430431
content_get(ridv, &v);
431
- rc = merge_3way(&v, zFullPath, &t, &r);
432
+ rc = merge_3way(&v, zFullPath, &t, &r, mergeFlags);
432433
if( rc>=0 ){
433434
if( !nochangeFlag ){
434435
blob_write_to_file(&r, zFullNewPath);
435436
file_wd_setexe(zFullNewPath, isexe);
436437
}
437438
--- src/update.c
+++ src/update.c
@@ -423,14 +423,15 @@
423 }
424 if( islinkv || islinkt /* || file_wd_islink(zFullPath) */ ){
425 fossil_print("***** Cannot merge symlink %s\n", zNewName);
426 nConflict++;
427 }else{
 
428 undo_save(zName);
429 content_get(ridt, &t);
430 content_get(ridv, &v);
431 rc = merge_3way(&v, zFullPath, &t, &r);
432 if( rc>=0 ){
433 if( !nochangeFlag ){
434 blob_write_to_file(&r, zFullNewPath);
435 file_wd_setexe(zFullNewPath, isexe);
436 }
437
--- src/update.c
+++ src/update.c
@@ -423,14 +423,15 @@
423 }
424 if( islinkv || islinkt /* || file_wd_islink(zFullPath) */ ){
425 fossil_print("***** Cannot merge symlink %s\n", zNewName);
426 nConflict++;
427 }else{
428 unsigned mergeFlags = nochangeFlag ? MERGE_DRYRUN : 0;
429 undo_save(zName);
430 content_get(ridt, &t);
431 content_get(ridv, &v);
432 rc = merge_3way(&v, zFullPath, &t, &r, mergeFlags);
433 if( rc>=0 ){
434 if( !nochangeFlag ){
435 blob_write_to_file(&r, zFullNewPath);
436 file_wd_setexe(zFullNewPath, isexe);
437 }
438

Keyboard Shortcuts

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