Configuring Mercurial - FileMerge for Apple Mac OS X
Solution 1
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
.
Solution 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.
Solution 3
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.
Related videos on Youtube
![Frank V](https://i.stack.imgur.com/nTnqA.jpg?s=256&g=1)
Frank V
Software Engineer, professionally - I work face-to-face with clients on a variety of software technologies (React, Node, .NET, PHP, MySQL, JavaScript, Python, etc). In addition, I have a particular affinity for open-source software. I study it to learn and make contributions when possible. I document my adventures at http://theOpenSourceU.org/ #SOreadytohelp
Updated on June 20, 2020Comments
-
Frank V about 4 years
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.
-
Frank V almost 15 yearsFor 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 executechmod +x opendiff-w
-
Vaibhav Bajpai about 13 yearsFor others: Something that was not obvious to me: You now need to run
$hg opendiff
(to see the output inFileMerge
);$hg diff
will still show you the output on the command line -
Vaibhav Bajpai about 13 yearsFor others: ... and you need to enable extdiff extension in
~/.hgrc
-
jammon almost 13 yearsI tried it as well, I got:
FileMerge[51550:30f] Couldn't create connection for root
-
elliotrock almost 8 yearsFor others. Make the
opendiff-w
executable withchmod a+x opendiff-w
-
partizanos over 6 yearsWhy does
[extensions] extdiff =
have no value in the ~/.hgrc? -
Roberto over 6 years
[extensions] extdiff =
is to load the extension, as far as I understand. -
Nicolas Miari about 3 yearsPro 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)