kdiff3 arguments order

Kelly O'Hair Kelly.Ohair at Sun.COM
Mon Dec 3 21:31:38 UTC 2007

Looking at hgmerge it's obvious nobody agreed on any common option parsing
rules for merge tools. :^(

Watch out for your PATH setting. The hgmerge script behave according to
whether it can find the various tools in your PATH, and it looks for many
different names for the same tool.

On Solaris...
The auto merge tools 'merge' and 'gdiff3' (or diff3) are looked for in PATH.
I usually place /opt/sfw/bin in my path, so when I run hgmerge, it finds
gdiff3, but if it can't find gdiff3 it looks for diff3, which will be /usr/bin/diff3
and the wrong diff3 on Solaris (it doesn't do merges).
Luckily, this wrong diff3 fails when it gets an unknown -m option, but the
hgmerge script also expects specific undocumented exit codes from diff3. :^(

So be careful with hgmerge.

By the way, if DISPLAY is not set, the GUI tools kdiff3, tkdiff, or meld
will not be run by hgmerge, but on the Mac FileMerge will run even if DISPLAY
is not set.


Brad Wetmore wrote:
> Yuri Nesterenko wrote:
>> Colleagues,
>> moderately useful dry-run finding:
>> using kdiff3 as a merge tool for mercurial, you better wrap it in the 
>> script
>> like this ("merge = ~/bin/kdiff3.sh" in my .hgrc):
>> #!/bin/bash
>> /opt/kde3/bin/kdiff3 -o $1 $2 $1 $3 
> I like kdiff3 too, but doesn't work under default Solaris.  Apparently 
> have to build/install KDE.  I currently use it only under Windows.
> Anyway, the default hgmerge script in the hg distribution does do this 
> automatically.
>     http://selenic.com/repo/hg-stable/file/f2f42262adbd/hgmerge
>     # try using kdiff3, which is fairly nice
>     if [ -n "$KDIFF3" ]; then
>         #
>         # Auto Merging is evil!!!  Brad
>         # $KDIFF3 --auto "$BASE" "$BACKUP" "$OTHER" -o "$LOCAL" \
>         #    || failure
>         #
>         $KDIFF3 "$BASE" "$BACKUP" "$OTHER" -o "$LOCAL" || failure
>         success
>     fi
> Having been a teamware user for years, I think automerging is evil, so I 
> don't use the default --auto option.
> Note:  the standard windows distributions don't include the hgmerge 
> /bin/sh shell script, probably because windows doesn't have a Bourne 
> shell by default.  I run MKS under Windows, so I copied/use the default 
> hgmerge from the mercurial source base.  You'll probably need to install 
> it as:  c:/Mercurial/hgmerge.sh  (or wherever you installed Mercurial), 
> otherwise, Mercurial may expect the hgmerge file to be a COMMAND.COM 
> (DOS) script.
> Brad

More information about the build-dev mailing list