views:

1414

answers:

3

How do I configure Apple's FileMerge program to function as Mercurial's merge tool? I have my .hgrc file setup in my home directory and I simply want to configure FileMerge as the merge program.

A: 

Update: The Mercurial wiki has a page about FileMerge. Read that first.

I haven't tried to use FileMerge but a general overview might help. Most of what you want to know is described at the Mercurial wiki's MergeProgram page. The short version is your typical choices are:

Set the HGMERGE environment variable to point at the merge tool you want.

or, add the following to your .hgrc:

 [ui]
 merge = /path/to/toolname

 [merge-tools]
 toolname.args = $base $local $other

The key is that a merge tool needs to take three arguments: the base revision, your local changes, and the changes from the other branch. You use the first configuration to specify the tool, and the second to specify how it takes arguments.

quark
A: 

I haven't tried it, but I'm betting you need to point all the way to the FileMerge executable, not just the app bundle.

So:

[ui] merge = /Developer/Applications/Utilities/FileMerge.app/Contents/MacOS/FileMerge

Wade Williams
I tried this, it isn't that easy.
Frank V
+2  A: 

As described in the hg wiki, this has worked for me with various versions of hg:

  • Create a script somewhere in your $PATH, say in /usr/local/bin:
$ more /usr/local/bin/opendiff-w
#!/bin/sh
# opendiff returns immediately, without waiting for FileMerge to exit.
# Piping the output makes opendiff wait for FileMerge.
opendiff "$@" | cat
  • Add the following sections to your ~/.hgrc:
[extdiff]
cmd.interdiff = hg-interdiff
cmd.opendiff = opendiff-w

[merge-tools]
filemerge.executable = opendiff-w
filemerge.args = $local $other -ancestor $base -merge $output
Ned Deily
**For others**: `opendiff-w` is the script file which end up being referenced in the .hgrc file (this wasn't too obvious to me). The first code block is the contents. Also, changed the permissions to add execute `chmod +x opendiff-w`
Frank V