author | Martin Geisler <mg@lazybytes.net> |
Thu, 21 Oct 2010 21:34:30 +0200 | |
branch | stable |
changeset 12804 | e0e8b123b75e |
parent 12771 | c77f6276c9e7 |
child 12809 | e5922564ab01 |
permissions | -rw-r--r-- |
12771 | 1 |
To merge files Mercurial uses merge tools. |
2 |
||
3 |
A merge tool combines two different versions of a file into a merged |
|
4 |
file. Merge tools are given the two files and the greatest common |
|
5 |
ancestor of the two file versions, so they can determine the changes |
|
6 |
made on both branches. |
|
7 |
||
8 |
The merge tools are used both for :hg:`resolve` and :hg:`merge`. |
|
9 |
||
12804
e0e8b123b75e
merge-tools: fixed typos
Martin Geisler <mg@lazybytes.net>
parents:
12771
diff
changeset
|
10 |
Usually, the merge tool tries to automatically reconcile the files by |
e0e8b123b75e
merge-tools: fixed typos
Martin Geisler <mg@lazybytes.net>
parents:
12771
diff
changeset
|
11 |
combining all the non-overlapping changes that occurred separately in |
e0e8b123b75e
merge-tools: fixed typos
Martin Geisler <mg@lazybytes.net>
parents:
12771
diff
changeset
|
12 |
the two different |
12771 | 13 |
evolutions of the same initial base file. Furthermore, some |
14 |
interactive merge programs make it easier to manually resolve |
|
15 |
conflicting merges, either in a graphical way, or by inserting some |
|
16 |
conflict markers. Mercurial does not include any interactive merge |
|
17 |
programs but relies on external tools for that. External merge tools |
|
18 |
and their properties and usage is configured in merge-tools section - |
|
19 |
see hgrc(5). |
|
20 |
||
21 |
There are a some internal merge tools which can be used. The internal |
|
22 |
merge tools are: |
|
23 |
||
24 |
``internal:merge`` |
|
25 |
Uses the internal non-interactive merge tool for merging files. |
|
26 |
||
27 |
``internal:fail`` |
|
28 |
Rather than attempting to merge files that were modified on both |
|
29 |
branches, it marks these files as unresolved. Then the resolve |
|
30 |
command must be used to mark files resolved. |
|
31 |
||
32 |
``internal:local`` |
|
33 |
Uses the local version of files as the merged version. |
|
34 |
||
35 |
``internal:other`` |
|
36 |
Uses the remote version of files as the merged version. |
|
37 |
||
38 |
``internal:prompt`` |
|
39 |
Asks the user which of the local or the other version to keep as |
|
40 |
the merged version. |
|
41 |
||
42 |
``internal:dump`` |
|
43 |
Creates three versions of the files to merge, containing the |
|
44 |
contents of local, other and base. These files can then be used to |
|
12804
e0e8b123b75e
merge-tools: fixed typos
Martin Geisler <mg@lazybytes.net>
parents:
12771
diff
changeset
|
45 |
perform a merge manually. If the file to be merged is named |
e0e8b123b75e
merge-tools: fixed typos
Martin Geisler <mg@lazybytes.net>
parents:
12771
diff
changeset
|
46 |
``a.txt``, these files will accordingly be named ``a.txt.local``, |
12771 | 47 |
``a.txt.other`` and ``a.txt.base`` and they will be placed in the |
12804
e0e8b123b75e
merge-tools: fixed typos
Martin Geisler <mg@lazybytes.net>
parents:
12771
diff
changeset
|
48 |
same directory as ``a.txt``. |
12771 | 49 |
|
50 |
How Mercurial decides which merge program to use |
|
51 |
||
52 |
1. If the ``HGMERGE`` environment variable is present, it is used. If |
|
53 |
specified it must be either an executable path or the name of an |
|
54 |
application in your executable search path. |
|
55 |
||
56 |
2. If the filename of the file to be merged matches any of the |
|
57 |
patterns in the merge-patterns configuration section, then the |
|
58 |
corresponding merge tool is used, unless the file to be merged is a |
|
59 |
symlink. Here binary capabilities of the merge tool are not |
|
60 |
considered. |
|
61 |
||
62 |
3. If ui.merge is set, it is used. |
|
63 |
||
64 |
4. If any merge tools are present in the merge-tools configuration |
|
65 |
section, and any of the tools can be found on the system, the |
|
66 |
priority settings are used to determine which one to use. Binary, |
|
67 |
symlink and GUI capabilities do also have to match. |
|
68 |
||
69 |
5. If a program named ``hgmerge`` exists on the system, it is used. |
|
70 |
||
71 |
6. If the file to be merged is not binary and is not a symlink, then |
|
72 |
``internal:merge`` is used. |
|
73 |
||
74 |
7. The merge fails. |
|
75 |
||
76 |
.. note:: |
|
77 |
After selecting a merge program, Mercurial will by default attempt |
|
78 |
to merge the files using a simple merge algorithm first, to see if |
|
79 |
they can be merged without conflicts. Only if there are conflicting |
|
80 |
changes Mercurial will actually execute the merge program. Whether |
|
12804
e0e8b123b75e
merge-tools: fixed typos
Martin Geisler <mg@lazybytes.net>
parents:
12771
diff
changeset
|
81 |
to use the simple merge algorithm first can be controlled by the |
e0e8b123b75e
merge-tools: fixed typos
Martin Geisler <mg@lazybytes.net>
parents:
12771
diff
changeset
|
82 |
premerge setting of the merge tool. Premerge is enabled by default |
12771 | 83 |
unless the file is binary or symlink. |
84 |
||
85 |
See the merge-tools and ui sections of hgrc(5) for details on |
|
86 |
configuration of merge tools. |