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.
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
.
$hg opendiff
(to see the output in FileMerge
); $hg diff
will still show you the output on the command line –
Gaffer ~/.hgrc
–
Gaffer opendiff-w
executable with chmod a+x opendiff-w
–
Tungusic [extensions] extdiff =
have no value in the ~/.hgrc? –
Germayne [extensions] extdiff =
is to load the extension, as far as I understand. –
Nievelt sudo
, so you're able to save changes inside /usr/local/bin
(saved me) –
Breakneck 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.
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.
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.
Hope this helps.
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
FileMerge[51550:30f] Couldn't create connection for root
–
Abolition © 2022 - 2024 — McMap. All rights reserved.
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 executechmod +x opendiff-w
– Catton