exit codes when writing / not writing merged files

Support for our DiffMerge utility.

Moderator: SourceGear

Post Reply
dflinkmann
Posts: 1
Joined: Tue Feb 05, 2008 7:40 am
Location: Dortmund, Germany
Contact:

exit codes when writing / not writing merged files

Post by dflinkmann » Tue Feb 05, 2008 8:35 am

Hi,

I really like DiffMerge and I would like to use it with the Mercurial system.

It can already be integrated into mercurial as you can see here:
http://www.selenic.com/mercurial/wiki/i ... rgeProgram

However it doesn't send exit codes when quiting DiffMerge, so mercurial can't recognise if its sucessfully saved.

Any plans to add exit codes ?

Cheers,

Daniel

jeffhostetler
Posts: 534
Joined: Tue Jun 05, 2007 11:37 am
Location: SourceGear
Contact:

i'll log a feature request for this.

Post by jeffhostetler » Tue Feb 05, 2008 10:20 am

I'll log a request for this.

I didn't add it originally because DiffMerge can have multiple
windows open and can be used as a more or less stand-alone
tool. Having the exit code mean you did or did not write the
file makes sense in this context, but not so much in the general
case.

In the Mercurial script, It might be easier to use the
--result=<result_pathname> argument and have DiffMerge
write the merge result into a new file (instead of overwriting
one of the inputs). And then check for the existence of this
file in the script.

A word of warning though, because File|Save does not cause
the program to exit, both methods have the problem that you
could do a save and then edit some more and quit without saving
and the calling script would think that your last save was really
what you wanted. which may or may not be true.

jeff

Parcho
Posts: 3
Joined: Tue Jun 17, 2008 3:47 pm

Re: exit codes when writing / not writing merged files

Post by Parcho » Wed Aug 06, 2008 3:01 pm

Bump!
+1 for this feature request.
I had a weird problem with my integration of SourceGear DiffMerge with Team Foundation today (my merge result got nerfed) and I am only guessing at this stage but I that the exit codes might have been the reason for the problem. Since different toolsets might use interpret exit codes differently, it might also be good if the exit codes are command-line configurable. (/exitsuccess=0 /exitabort=2 etc.)

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Re: exit codes when writing / not writing merged files

Post by lbauer » Thu Aug 07, 2008 8:19 am

I've added your "vote" to the feature request.

12990
Linda Bauer
SourceGear
Technical Support Manager

jeffhostetler
Posts: 534
Joined: Tue Jun 05, 2007 11:37 am
Location: SourceGear
Contact:

Re: exit codes when writing / not writing merged files

Post by jeffhostetler » Thu Aug 07, 2008 8:26 am

yeah, i'll add your vote for this. perhaps it would make sense to optionally have
an exit dialog that asks what the exit status should be....

jeff

jeffhostetler
Posts: 534
Joined: Tue Jun 05, 2007 11:37 am
Location: SourceGear
Contact:

Re: exit codes when writing / not writing merged files

Post by jeffhostetler » Thu Apr 09, 2009 9:57 am

SourceGear DiffMerge 3.3.0 is now available and addresses this problem.
When the /result=file option is used, DiffMerge will exit with an exit status
to indicate the result of the merge. There's a section in the new manual that
explains the various status codes.

Full details can be found at http://www.sourcegear.com/diffmerge/index.html.

jeff hostetler

Chaos2k
Posts: 2
Joined: Wed May 06, 2009 9:59 am

Re: exit codes when writing / not writing merged files

Post by Chaos2k » Wed May 06, 2009 10:04 am

Hi,

I cant figure out how to correctly use the current version of DiffMerge with Mercurial.
It seems my mercurial.ini (hgrc) isnt correct in order to correctly accept/reject merge results from diffmerge.
Could you maybe provide a sample showing how to do so?

jeffhostetler
Posts: 534
Joined: Tue Jun 05, 2007 11:37 am
Location: SourceGear
Contact:

Re: exit codes when writing / not writing merged files

Post by jeffhostetler » Wed May 06, 2009 10:34 am

I haven't tried it with HG yet, but let me take a look.

What platform are you on and what have you tried so far?

(If you want to paste in a copy of the relevant part of your
mercurial.ini / .hgrc file, I'll take a look at it too.)

jeff

Chaos2k
Posts: 2
Joined: Wed May 06, 2009 9:59 am

Re: exit codes when writing / not writing merged files

Post by Chaos2k » Wed May 06, 2009 2:49 pm

Im Running on Windows currently, however will also try to run it on Mac OS X soon.

jeffhostetler
Posts: 534
Joined: Tue Jun 05, 2007 11:37 am
Location: SourceGear
Contact:

Re: exit codes when writing / not writing merged files

Post by jeffhostetler » Thu May 07, 2009 6:58 am

I ran some quick tests on Windows with HG (version 1.2.1) and and DiffMerge (version 3.3.0)
and the following seems to work OK. The "hg merge" or "hg resolve" will launch DiffMerge
with the output properly routed to the $output file. When DiffMerge is given the /result=
argument, the exit status is correctly set and this is detected by hg.

I only ran a few tests (and I'm in no way an expert on HG), so you may want to experiment
a little before going into production....

I haven't had time to try it on the Mac yet, but it should be similar. Be sure to check out
the shell script that I put on the .DMG in the CommandLine folder. That should help.
(See the readme for details.)

Code: Select all

[extensions]
hgext.extdiff =

[extdiff]
cmd.diffmerge = c:\Program Files\SourceGear\DiffMerge\DiffMerge.exe

[merge-tools]
diffmerge.executable = c:\Program Files\SourceGear\DiffMerge\DiffMerge.exe
diffmerge.args = /result=$output  $base $local $other
diffmerge.binary = False
diffmerge.symlinks = False
diffmerge.gui = True
diffmerge.premerge = True
BTW, I also added a section for diffing 2 files using DiffMerge. In addition to "hg diff file"
you should be able to type "hg diffmerge file" and have DiffMerge show you the differences.

I'll log an action item to add this to the manual.

Let me know if you have questions or problems.

jeff hostetler

jeffhostetler
Posts: 534
Joined: Tue Jun 05, 2007 11:37 am
Location: SourceGear
Contact:

Re: exit codes when writing / not writing merged files

Post by jeffhostetler » Thu May 07, 2009 8:11 am

Oops, the line:

diffmerge.args = /result=$output $base $local $other

should read:

diffmerge.args = /result=$output $local $base $other

That is, the base/ancestor should be in the middle.

Sorry,
jeff

jeffhostetler
Posts: 534
Joined: Tue Jun 05, 2007 11:37 am
Location: SourceGear
Contact:

Re: exit codes when writing / not writing merged files

Post by jeffhostetler » Thu May 07, 2009 9:44 am

I just tried it on Linux (Fedora 10) and Mac OS (10.5.6). Basically, the same .ini/.hgrc commands do the trick.
(Changing the path the executables, of course.)

Code: Select all

[extensions]
hgext.extdiff =

[extdiff]
cmd.diffmerge = /usr/bin/diffmerge

[merge-tools]
diffmerge.executable = /usr/bin/diffmerge
diffmerge.args = --result=$output -t1="Local Version" -t2=$output -t3="Other Version" --caption=$output  $local $base $other
diffmerge.binary = False
diffmerge.symlinks = False
diffmerge.gui = True
diffmerge.premerge = True
To make it a little clearer, I added captions and panel titles. (You should be able to add these to the Windows version, too.)

On Mac OS, you'll want to install the diffmerge.sh shell script in /usr/bin or /usr/local/bin.

BTW, I did NOT add a merge= line to the [ui] section as describe in some of the docs; there was an issue with doing
that, but I don't remember all the details. I think HG wasn't picking up the .args line and thus not passing the /result
argument to DiffMerge so DiffMerge wasn't setting the exit status as expected.

Again, let me know if you have any problems or questions.

jeff hostetler

Post Reply