How to use p4merge as the merge/diff tool for Mercurial?

12,833

Solution 1

This will work for merging:

Place this into your ~/.hgrc (or, optionally, your Mercurial.ini on Windows):

[merge-tools]
p4.priority = 100
p4.premerge = True  # change this to False if you're don't trust hg's internal merge
p4.executable = /Applications/p4merge.app/Contents/MacOS/p4merge
p4.gui = True
p4.args = $base $local $other $output

Requires Mercurial 1.0 or newer. Clearly you'll need to update the path to that executable to reflect where you'd got p4merge installed.


You can't change what hg diff uses; but you can use the extdiff extension to create new diff commands that use the display you want.

So hg pdiff could run p4 merge, etc.

Solution 2

I found Ry4an's answer to be a good solution, except for a minor problem, which left p4merge (under mac os) mixing up the command inputs. Do everything described in his answer and add the following line in the [merge-tools] section:

p4.args=$base $local $other $output

This line tells mercurial in which order p4merge takes its arguments.

Solution 3

I am using version 1.0.1 of TortoiseHg and p4merge works out of the box.

Just go to Global Settings -> TortoiseHg and select the following options:

  • Three-way Merge Tool: p4merge
  • Visual Diff Tool: p4merge

Screenshot

Solution 4

Maybe because I'm working on Windows, but the proposed solution didn't work for me. Instead, the following does work.

In your ~/.hgrc/ / Mercurial.ini, I applied the following changes:

Enabled "ExtDiff" extension:

[extensions]
hgext.extdiff =

Added P4 extdiff command:

[extdiff]
cmd.p4diff = p4merge

Configured it as the default visual diff tool:

[tortoisehg]
vdiff = p4diff
Share:
12,833
Jay Stramel
Author by

Jay Stramel

Updated on July 25, 2022

Comments

  • Jay Stramel
    Jay Stramel almost 2 years

    Does anyone know how to setup Mercurial to use p4merge as the merge/diff tool on OS X 10.5?