Configuring Mercurial - FileMerge for Apple Mac OS X
Asked Answered
C

5

23

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.

Catton answered 20/8, 2009 at 5:29 Comment(0)
N
28

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:
$ vim /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

[extensions]
extdiff = 

Now you can use it as $hg opendiff.

Navicert answered 20/8, 2009 at 7:55 Comment(7)
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-wCatton
For others: Something that was not obvious to me: You now need to run $hg opendiff (to see the output in FileMerge); $hg diff will still show you the output on the command lineGaffer
For others: ... and you need to enable extdiff extension in ~/.hgrcGaffer
For others. Make the opendiff-w executable with chmod a+x opendiff-wTungusic
Why does [extensions] extdiff = have no value in the ~/.hgrc?Germayne
[extensions] extdiff = is to load the extension, as far as I understand.Nievelt
Pro tip: you might need to open opendiff-w in the editor using sudo, so you're able to save changes inside /usr/local/bin (saved me)Breakneck
G
2

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.

Giveaway answered 20/8, 2009 at 5:55 Comment(0)
S
1

None of the documentation linked worked for me without modifications; eventually what I ended up doing was a combination of the official instructions and "Using Vim as the filemerge program" from https://www.mercurial-scm.org/wiki/TipsAndTricks. I created the opendiff-w script described in this answer (though I named it hgvdiff), and put the following into my .hgrc:

[extdiff]
cmd.interdiff = hg-interdiff
cmd.opendiff = /usr/local/bin/hgvdiff

[merge-patterns]
** = filemerge

[merge-tools]
filemerge.executable = /usr/local/bin/hgvdiff
filemerge.args = $local $other -ancestor $base -merge $output
filemerge.checkchanged = true
filemerge.gui = true

[extensions]
extdiff =

This is moderately functional, though it sometimes performs the check for whether a file was changed prematurely, leading to a bunch of:

 output file wwwroot/zoomingo/website/protected/messages/en/z.php appears unchanged
was merge successful (yn)? n

when you close FileMerge.

Stenograph answered 19/3, 2013 at 0:33 Comment(0)
N
0

Here is how I fixed it:

Created /usr/local/bin/opendiff-w filled with:

#!/bin/sh
# opendiff returns immediately, without waiting for FileMerge to exit.
# Piping the output makes opendiff wait for FileMerge.
opendiff "$@" | cat

Then ran the command: sudo chmod +x /usr/local/bin/opendiff-w

Then edited ~/.hgrc with the following addition:

[extdiff]
cmd.interdiff = hg-interdiff
cmd.opendiff = opendiff-w

[merge-tools]
filemerge.executable = /usr/local/bin/opendiff-w
filemerge.args = $local $other -ancestor $base -merge $output

[extensions]
extdiff = 

Then I ran the following command to check wether it worked: hg opendiff

However, I got the following error:

exception raised trying to run FileMerge: launch path not accessible

In order to fix it I ran the following command:

sudo /usr/bin/xcode-select -switch /Applications/Xcode.app/Contents/Developer/

This should now work and open up FileMerge.

====================================================================

If you're using TorsoiseHg for Mac, the only thing you need to do now in order to work with FileMerge is to choose filemerge from the Detected merge/diff tools when the Resolve Conflict window appears and choose Tool Resolve.

enter image description here

Hope this helps.

Ngo answered 24/10, 2013 at 19:7 Comment(0)
S
-1

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
Sarchet answered 20/8, 2009 at 6:0 Comment(1)
I tried it as well, I got: FileMerge[51550:30f] Couldn't create connection for rootAbolition

© 2022 - 2024 — McMap. All rights reserved.