Configuring Mercurial - FileMerge for Apple Mac OS X

11,548

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.

Share:
11,548

Related videos on Youtube

Frank V
Author by

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, 2020

Comments

  • Frank V
    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
    Frank V almost 15 years
    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
  • Vaibhav Bajpai
    Vaibhav Bajpai about 13 years
    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 line
  • Vaibhav Bajpai
    Vaibhav Bajpai about 13 years
    For others: ... and you need to enable extdiff extension in ~/.hgrc
  • jammon
    jammon almost 13 years
    I tried it as well, I got: FileMerge[51550:30f] Couldn't create connection for root
  • elliotrock
    elliotrock almost 8 years
    For others. Make the opendiff-w executable with chmod a+x opendiff-w
  • partizanos
    partizanos over 6 years
    Why does [extensions] extdiff = have no value in the ~/.hgrc?
  • Roberto
    Roberto over 6 years
    [extensions] extdiff = is to load the extension, as far as I understand.
  • Nicolas Miari
    Nicolas Miari about 3 years
    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)