Differences between revisions 5 and 7 (spanning 2 versions)
Revision 5 as of 2008-06-02 15:07:43
Size: 2345
Editor: abuehl
Comment: notes / selecting internal merge with conflict markers in TortoiseHg
Revision 7 as of 2008-09-16 14:04:28
Size: 3373
Comment: Reworked and improved(?) description of merge configuration.
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
In February 2008, [:mpm:Matt Mackall] contributed a new [:Merge:merge] tool configuration feature. This feature is available in version 1.0 (see [:WhatsNew]).

=== Details ===
To describe a new merge tool, do something like the following in [:.hgrc]:
To define a merge tool, add something like the following in [:.hgrc]:
Line 8: Line 4:
 mymergetool.args=$local $other $base -o $output  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 variables {{{$local}}}, {{{$base}}}, {{{$other}}} and {{{$output}}} expanded.

For example:
{{{
 [merge-tools]
 mymergetool.priority = 100
 mymergetool.premerge = False
 mymergetool.args = $local $other $base -o $output
 myimgmerge =
 [merge-patterns]
 **.jpg = myimgmerge
 **.exe = internal:fail
Line 11: Line 26:
If you've got no other merge tools defined, Mercurial will run
"mymergetool" with the appropriate arguments. Further tool options
include:
Further tool options include:
Line 26: Line 38:
If you have multiple tools defined, Mercurial looks for the highest
priority one that will work, falling back to the old hgmerge for
backwards compatibility.

If that's not found, we'll use our internal simplemerge code, which is a
tool named 'internal:merge'. There are also three other internal tools:
local, other, and fail.

To bypass the priority scheme and set the default tool directly, simply
set [ui]merge as always.
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}}}.
Line 42: Line 47:
To complete the picture, we also now support choosing a merge tool based
on file pattern, like so:

{{{
[merge-patterns]
**.jpg = myimgmerge
**.exe = internal:fail
}}}

=== References ===
 * "[http://selenic.com/repo/hg/rev/5af5f0f9d724 merge: allow smarter tool configuration]" in [http://selenic.com/repo/hg/shortlog main Mercurial repository] (changesets starting with 5af5f0f9d724)
 * "[http://selenic.com/pipermail/mercurial/2008-February/016923.html New merge tool system in mainline]", posting by Matt Mackall, Feb 3, 2008, [http://selenic.com/pipermail/mercurial/ Mercurial mailing list]
Line 59: Line 51:

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

 * "[http://selenic.com/repo/hg/rev/5af5f0f9d724 merge: allow smarter tool configuration]" in [http://selenic.com/repo/hg/shortlog main Mercurial repository] (changesets starting with 5af5f0f9d724)
 * "[http://selenic.com/pipermail/mercurial/2008-February/016923.html New merge tool system in mainline]", posting by Matt Mackall, Feb 3, 2008, [http://selenic.com/pipermail/mercurial/ Mercurial mailing list]
Line 67: Line 64:

==== Overriding merge.ui configuration from the command line ====
See [:TipsAndTricks#mergemineortheir:How to keep "My" or "Their" files when doing merge] for an example on how you can override merge configuration on the command line.

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 variables $local, $base, $other and $output expanded.

For example:

 [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.

See also

Notes

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

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.

2. Overriding merge.ui configuration from the command line

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

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