Differences between revisions 10 and 12 (spanning 2 versions)
Revision 10 as of 2010-10-17 23:08:11
Size: 4172
Editor: mpm
Comment:
Revision 12 as of 2012-05-08 16:01:38
Size: 4196
Editor: mpm
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
#pragma section-numbering 2 #pragma section-numbers 2

<<Include(A:style)>>
Line 80: Line 83:
CategoryAudit CategoryHowTo

{i} This page does not meet our wiki style guidelines. Please help improve this page by cleaning up its formatting.

Merge Tool Configuration

How to customize which merge tools Mercurial chooses.

To define a merge tool, add something like the following in .hgrc:

 [merge-tools]
 mymergetool.something = something

which will define mymergetool (the left hand side until the first dot). The option values defines the behaviour of the tool.

For each file changed in both parents Mercurial chooses a merge tool. The merge tool is chosen from the list of file pattern matches in the [merge-patterns] section followed by all tools sorted by decreasing priority order. The list is filtered for whether the executable (defaulting to mymergetool) can be found, whether it supports symlinks or binary files, and whether gui is available. To bypass the priority scheme and set the default tool directly, specify the merge tool in [ui] sections merge option. For backwards compatibility the tool hgmerge is implicitly added with lowest priority.

If the chosen merge tools premerge is True then an internal merge is attempted, and if it seems successful then the result it will silently be used without running the actual merge tool.

The merge tool is run with an argument list of args with the following variables expanded:

  • $output expands to the existing file which already contains the version from the first parent - and this is also where the result of the merge ends up / must end up

  • $local expands to file.orig which is created as a copy of file in the working directory version - it thus contains the unmerged version from the first parent

  • $base expands to /tmp/file~base.* which is created with the version from the common ancestor revision (see hg debugancestor)

  • $other expands to /tmp/file~other.* which is created with the version from the new second parent revision which the first parent is merged with

Example configuration:

 [merge-tools]
 mymergetool.priority = 100
 mymergetool.premerge = False
 mymergetool.args = $local $other $base -o $output
 myimgmerge =
 [merge-patterns]
 **.jpg = myimgmerge
 **.exe = internal:fail

Further tool options include:

 <tool>.args - the arguments to pass (defaults to $local $base $other)
 <tool>.executable - executable name or path (defaults to <tool>)
 <tool>.binary - supports binary files (False)
 <tool>.symlinks - supports symlinks (False)
 <tool>.gui - requires a GUI (False)
 <tool>.priority - priority of this tool (0)

..etc.

If no mergetool is found then the internal simplemerge tool internal:merge is used. There are also three other internal tools: internal:local, internal:other, and internal:fail.

Merge tool settings suitable for a global configuration file (and roughly equivalent to the ugly old hgmerge script) can be found in contrib/mergetools.hgrc. People building binary packages will want to use this.

0.1. See also

0.2. Notes

In February 2008, Matt Mackall contributed this new merge tool configuration feature. This feature is available in version 1.0 (see WhatsNew).

0.2.1. Choosing internal merge with conflict markers

To have the internal merge with the conflict markers for example in TortoiseHg set

[ui]
merge = internal:merge

in Mercurial.ini.

0.2.2. Overriding merge.ui configuration from the command line

See How to keep "My" or "Their" files when doing merge for an example on how you can override merge configuration on the command line.


CategoryHowTo

MergeToolConfiguration (last edited 2019-08-07 17:58:24 by GregTatum)