…it seems that the attachment did not survive the list unscathed, so here is a copy:
Index: src/db.c ================================================================== --- src/db.c +++ src/db.c @@ -2238,10 +2238,11 @@ { "localauth", 0, 0, 0, 0, "off" }, { "main-branch", 0, 40, 0, 0, "trunk" }, { "manifest", 0, 0, 1, 0, "off" }, { "max-loadavg", 0, 25, 0, 0, "0.0" }, { "max-upload", 0, 25, 0, 0, "250000" }, + { "merge-command", 0, 40, 0, 0, "" }, { "mtime-changes", 0, 0, 0, 0, "on" }, { "pgp-command", 0, 40, 0, 0, "gpg --clearsign -o " }, { "proxy", 0, 32, 0, 0, "off" }, { "relative-paths", 0, 0, 0, 0, "on" }, { "repo-cksum", 0, 0, 0, 0, "on" }, Index: src/merge3.c ================================================================== --- src/merge3.c +++ src/merge3.c @@ -442,13 +442,13 @@ /* ** This routine is a wrapper around blob_merge() with the following ** enhancements: ** ** (1) If the merge-command is defined, then use the external merging -** program specified instead of the built-in blob-merge to do the -** merging. Panic if the external merger fails. -** ** Not currently implemented ** +** tool specified instead of the built-in blob-merge to do the +** merging. If the merge tool fails, leave the auxiliary files +** and let the user do the merge manually. ** ** (2) If gmerge-command is defined and there are merge conflicts in ** blob_merge() then invoke the external graphical merger to resolve ** the conflicts. ** @@ -463,13 +463,40 @@ Blob *pOut, /* Output written here */ unsigned mergeFlags /* Flags that control operation */ ){ Blob v1; /* Content of zV1 */ int rc; /* Return code of subroutines and this routine */ + int blobMerge; /* Whether we do the internal blob merge */ + const char *zMergeCommand; /* The name of the external merge command */ + /* read the original file */ blob_read_from_file(&v1, zV1); - rc = blob_merge(pPivot, &v1, pV2, pOut); + + /* choose between the internal blob-merge or the external merge-command */ + zMergeCommand = db_get("merge-command", 0); + if( zMergeCommand && zMergeCommand[0] && (mergeFlags & MERGE_DRYRUN)==0 ){ + /* we are using the external merge exclusively */ + blobMerge = 0; + } + else{ + /* we are using the internal blob merge + and falling back to the gmerge-command on conflict */ + blobMerge = 1; + zMergeCommand = db_get("gmerge-command", 0); + } + + /* do the blob merge if nessesary, otherwise ivoke the external merge tool. + This code should be probably rewritten in the long run, as it abuses + the return code of blob_merge() + */ + if( blobMerge ){ + rc = blob_merge(pPivot, &v1, pV2, pOut); + } + else{ + rc = 1; + } + if( rc!=0 && (mergeFlags & MERGE_DRYRUN)==0 ){ char *zPivot; /* Name of the pivot file */ char *zOrig; /* Name of the original content file */ char *zOther; /* Name of the merge file */ @@ -477,40 +504,45 @@ blob_write_to_file(pPivot, zPivot); zOrig = file_newname(zV1, "original", 1); blob_write_to_file(&v1, zOrig); zOther = file_newname(zV1, "merge", 1); blob_write_to_file(pV2, zOther); - if( rc>0 ){ - const char *zGMerge; /* Name of the gmerge command */ + + /* invoke the external merge tool, if defined */ + if( rc>0 && zMergeCommand && zMergeCommand[0] ){ + + char *zOut; /* Temporary output file */ + char *zCmd; /* Command to invoke */ + const char *azSubst[8]; /* Strings to be substituted */ - zGMerge = db_get("gmerge-command", 0); - if( zGMerge && zGMerge[0] ){ - char *zOut; /* Temporary output file */ - char *zCmd; /* Command to invoke */ - const char *azSubst[8]; /* Strings to be substituted */ + zOut = file_newname(zV1, "output", 1); + azSubst[0] = "%baseline"; azSubst[1] = zPivot; + azSubst[2] = "%original"; azSubst[3] = zOrig; + azSubst[4] = "%merge"; azSubst[5] = zOther; + azSubst[6] = "%output"; azSubst[7] = zOut; + zCmd = string_subst(zMergeCommand, 8, azSubst); + printf("%s\n", zCmd); fflush(stdout); + fossil_system(zCmd); + if( file_wd_size(zOut)>=0 ){ + blob_read_from_file(pOut, zOut); + file_delete(zPivot); + file_delete(zOrig); + file_delete(zOther); + file_delete(zOut); - zOut = file_newname(zV1, "output", 1); - azSubst[0] = "%baseline"; azSubst[1] = zPivot; - azSubst[2] = "%original"; azSubst[3] = zOrig; - azSubst[4] = "%merge"; azSubst[5] = zOther; - azSubst[6] = "%output"; azSubst[7] = zOut; - zCmd = string_subst(zGMerge, 8, azSubst); - printf("%s\n", zCmd); fflush(stdout); - fossil_system(zCmd); - if( file_wd_size(zOut)>=0 ){ - blob_read_from_file(pOut, zOut); - file_delete(zPivot); - file_delete(zOrig); - file_delete(zOther); - file_delete(zOut); - } - fossil_free(zCmd); - fossil_free(zOut); + rc = 0; /* Merge has been resolved, so report no conflicts */ + fossil_print("MERGE successful\n"); + } + else{ + fossil_print("MERGE failed, please merge manually\n"); } + fossil_free(zCmd); + fossil_free(zOut); } fossil_free(zPivot); fossil_free(zOrig); fossil_free(zOther); } + blob_reset(&v1); return rc; } > On 21 Nov 2014, at 17:08, Taras Zakharko <taras.zakha...@uzh.ch> wrote: > > Dear all, > > here is a patch for the merge-command setting (originally talked about here: > http://www.mail-archive.com/fossil-users@lists.fossil-scm.org/msg17956.html). > I hope that I have got all the style conventions right this time. > > Thanks, > > Taras > > <merge-command.diff> > > _______________________________________________ fossil-dev mailing list fossil-dev@lists.fossil-scm.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/fossil-dev