/usr/share/doc/monotone/html/Merge-Conflicts.html is in monotone-doc 1.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | <html lang="en">
<head>
<title>Merge Conflicts - monotone documentation</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="monotone documentation">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Advanced-Uses.html#Advanced-Uses" title="Advanced Uses">
<link rel="prev" href="Inodeprints.html#Inodeprints" title="Inodeprints">
<link rel="next" href="Workspace-Collisions.html#Workspace-Collisions" title="Workspace Collisions">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
<link rel="stylesheet" type="text/css" href="texinfo.css">
</head>
<body>
<div class="node">
<a name="Merge-Conflicts"></a>
<p>
Next: <a rel="next" accesskey="n" href="Workspace-Collisions.html#Workspace-Collisions">Workspace Collisions</a>,
Previous: <a rel="previous" accesskey="p" href="Inodeprints.html#Inodeprints">Inodeprints</a>,
Up: <a rel="up" accesskey="u" href="Advanced-Uses.html#Advanced-Uses">Advanced Uses</a>
<hr>
</div>
<h3 class="section">3.6 Merge Conflicts</h3>
<p>Several different types of conflicts may be encountered when merging
two revisions using the database merge commands <samp><span class="command">merge</span></samp>,
<samp><span class="command">explicit_merge</span></samp>, <samp><span class="command">propagate</span></samp> and
<samp><span class="command">merge_into_dir</span></samp> or when using the workspace merge commands
<samp><span class="command">update</span></samp>, <samp><span class="command">pluck</span></samp> and <samp><span class="command">merge_into_workspace</span></samp>.
<p>The <samp><span class="command">show_conflicts</span></samp> and <samp><span class="command">automate show_conflicts</span></samp>
commands can be used to list conflicts between database revisions
which would be encountered by the database merge commands.
Unfortunately, these commands can't yet list conflicts between a
database revision and the current workspace.
<p>In addition, the <samp><span class="command">conflicts</span></samp> set of commands can be used to
specify resolutions for some conflicts. The resolutions are stored in a
file, and given to the <samp><span class="command">merge</span></samp> command via the
<samp><span class="option">--resolve-conflicts-file=filename</span></samp> or
<samp><span class="option">--resolve-conflicts</span></samp> option; see <a href="Conflicts.html#Conflicts">Conflicts</a>.
<p>The <samp><span class="command">merge</span></samp> command normally will perform as many merges as
necessary to merge all current heads of a branch. However, when
<samp><span class="option">--resolve-conflicts-file</span></samp> is given, the conflicts and their
resolutions apply only to the first merge, so the subsequent merges
are not done; the <samp><span class="command">merge</span></samp> command must be repeated, possibly
with new conflicts and resolutions, to merge the remaining heads.
<p>For the special case of file content conflicts, a merge command
invoked without <samp><span class="option">--resolve-conflicts</span></samp> will attempt to start an
external interactive merge tool; the user must then resolve the conflicts
and terminate the merge tool, letting monotone continue with the
merge. This process is repeated for each file content conflict. See
<a href="File-Content-Conflict.html#File-Content-Conflict">File Content Conflict</a> below for more detail.
<p>For other conflicts, a merge command invoked without
<samp><span class="option">--resolve-conflicts</span></samp> will fail.
<p>If <samp><span class="command">conflicts</span></samp> supports resolving a particular conflict, that
is the simplest way to resolve it. Otherwise, resolving the different
types of conflicts is accomplished by checking out one of the
conflicting revisions, making changes as described below, committing
these changes as a new revision and then running the merge again using
this new revision as one of the merge parents. This process can be
repeated as necessary to get two revisions into a state where they
will merge cleanly.
<p>The possible conflict resolutions are discussed with each conflict in
the following sections.
<h4 class="subsection">3.6.1 Conflict Types</h4>
<p>Monotone versions files, directories, and file attributes explicitly,
and it tracks individual file and directory identity from birth to
death so that name changes throughout the full life-cycle can be
tracked exactly. Partly because of these qualities, monotone notices
several types of conflicts that other version control systems may not.
<p>The two most common conflicts are described first, then all other
possible conflicts.
<h4 class="subheading">File Content Conflict</h4>
<p><a name="File-Content-Conflict"></a>This type of conflict is generally the one encountered most commonly
and represents conflicting changes made to lines of text within two
versions of a single file.
<p>When a merge command encounters changes in a file in both heads
relative to the common ancestor, it first checks to see if the file
has a <code>mtn:manual_merge</code> attribute with value <code>true</code>. If
not, it uses an internal merge algorithm to detect whether the changes
are to the same lines of the file. If they are not, monotone will use
the result of the internal merge as the new file version.
<p><code>mtn:manual_merge</code> is set <code>true</code> when a file is
<samp><span class="command">add</span></samp>ed for all files for which the <code>binary_file</code> hook
returns true; see <a href="attr_005finit_005ffunctions.html#attr_005finit_005ffunctions">attr_init_functions</a>.
<p>If <code>mtn:manual_merge</code> is present and <code>true</code>, or if the
changes are to the same lines of the file, and neither
<samp><span class="option">--resolve-conflicts</span></samp> nor <samp><span class="option">--non-interactive</span></samp> was
specified, the <a href="merge3.html#merge3">merge3</a> hook is called, with the content of both
conflicting versions and their common ancestor.
<p>Alternatively, you can use your favorite merge tool asychronously with
the merge, and specify the result file in the conflicts file, using
the <a href="Conflicts.html#Conflicts">Conflicts</a> command:
<pre class="smallexample">mtn conflicts resolve_first user filename
</pre>
<p>Then <samp><span class="option">--resolve-conflicts</span></samp> is specified on the merge command
line.
<p>Finally, rather than using a merge tool it is possible to commit
changes to one or both of the conflicting file versions so that they
will merge cleanly. This can also be a very helpful strategy if the
merge conflicts are due to sections of text in the file being moved
from one location to another. Rather than struggling to merge such
conflicting changes with a merge tool, similar rearrangements can be
made to one of the conflicting files before redoing the merge.
<h4 class="subheading">Duplicate Name Conflict</h4>
<p>A duplicate name conflict occurs when two distinct files or
directories have been given the same name in the two merge parents.
This can occur when each of the merge parents adds a new file or
directory with the conflicting name, or when one parent adds a new
file or directory with the conflicting name and the other renames an
existing file or directory to the conflicting name, or when both
parents rename an existing file or directory to the conflicting name.
<p>In earlier versions of monotone (before version 0.39) this type of
conflict was referred to as a <em>rename target conflict</em> although
it doesn't necessarily have anything to do with renames.
<p>There are two main situations in which duplicate name conflicts occur:
<ul>
<li>Two people both realize a new file should be added, and commit it. In
this case, the files have the right name and the right contents, but
monotone reports a conflict because they were added separately.
<li>Two people each decide to add new files with different content, and
accidently pick the same name.
</ul>
<p>These conflicts are reported when someone tries to merge the two
revisions containing the new files.
<p>There are similar conflicts for directories; the process for resolving
them is different, because we need to worry about the files in the
directories.
<h5 class="subsubheading">Same file</h5>
<p>For the first case, the conflict is resolved by dropping one file. The
contents should be manually merged, in case they are slightly
different. Typically, a user will have one of the files in their
current workspace; the other can be retrieved via <samp><span class="command">automate
get_file_of</span></samp>; the revision id is shown in the merge error message.
<p>This process can be confusing; here's a detailed example. We assume
the <a href="Conflicts.html#Conflicts">Conflicts</a> commands are used to resolve this conflict, since
that is supported.
<p>Suppose Beth and Abe each commit a new file <samp><span class="file">checkout.sh</span></samp>, with
similar contents. When Beth attempts to merge the two heads, she gets
a message like:
<pre class="smallexample">mtn: 2 heads on branch 'testbranch'
mtn: [left] ae94e6677b8e31692c67d98744dccf5fa9ccffe5
mtn: [right] dfdf50b19fb971f502671b0cfa6d15d69a0d04bb
mtn: conflict: duplicate name 'checkout.sh'
mtn: added as a new file on the left
mtn: added as a new file on the right
mtn: error: merge failed due to unresolved conflicts
</pre>
<p>The file labeled <code>right</code> is the file in Beth's workspace. To
start the conflict resolution process, Beth first saves the list of
conflicts:
<pre class="smallexample">mtn conflicts store
</pre>
<p>In order to merge Beth's and Abe's file versions, Beth retrieves a
copy of Abe's file:
<pre class="smallexample">mtn automate get_file_of checkout.sh \
--revision=ae94e6677b8e31692c67d98744dccf5fa9ccffe5 \
> _MTN/resolutions/checkout.sh-abe
</pre>
<p>Now Beth manually merges (using her favorite merge tool)
<samp><span class="file">checkout.sh</span></samp> and <samp><span class="file">_MTN/resolutions/checkout.sh-abe</span></samp>,
leaving the results in <samp><span class="file">_MTN/resolutions/checkout.sh-merge</span></samp>
(<em>not</em> in her copy).
<p>Then Beth specifies the conflict resolution, and finishes the merge:
<pre class="smallexample">mtn conflicts resolve_first_left drop
mtn conflicts resolve_first_right user _MTN/resolutions/checkout.sh-merge
mtn merge --resolve-conflicts-file=_MTN/conflicts
mtn conflicts clean
mtn update
</pre>
<p>When Abe later syncs and updates, he will get the merged version.
<h5 class="subsubheading">Different files</h5>
<p>The second case, where two different files accidently have the same
name, is resolved by renaming one or both of them.
<p>Suppose Beth and Abe each start working on different thermostat models
(say Honeywell and Westinghouse), but they both name the file
<samp><span class="file">thermostat</span></samp>. When Beth attempts to merge, she will get the same
error message as in the first case. When she retrieves Abe's file, she
will see that they should be different files. So she renames her file,
merges, and updates (again using <a href="Conflicts.html#Conflicts">Conflicts</a> commands):
<pre class="smallexample">mtn conflicts store
mtn conflicts resolve_first_left rename thermostat-westinghouse
mtn conflicts resolve_first_right rename thermostat-honeywell
mtn merge --resolve-conflicts-file=_MTN/conflicts
mtn conflicts clean
mtn update
</pre>
<p>Now she has her file contents in <samp><span class="file">thermostat-honeywell</span></samp>, and
Abe's in <samp><span class="file">thermostat-westinghouse</span></samp>.
<h5 class="subsubheading">Directories</h5>
<p>When two directories are given the same name, there are still the two
basic approaches to resolving the conflict; drop or rename. However,
if a directory is dropped, all the files in it must also be dropped.
Therefore, it is almost always better to first rename one of the
directories to a temporary name as the conflict resolution, and then
deal with the files individually, renaming or merging and dropping
each. Then finally drop the temporary directory. The
<samp><span class="command">conflicts</span></samp> commands do not support doing this; it must be
done directly.
<h4 class="subheading">Missing Root Conflict</h4>
<p>Monotone's merge strategy is sometimes referred to as
<em>die-die-die</em> merge, with reference to the fact that when a file
or directory is deleted there is no means of resurrecting it. Merging
the deletion of a file or directory will <em>always</em> result in that
file or directory being deleted.
<p>A missing root conflict occurs when some directory has been moved to
the root directory in one of the merge parents and has been deleted in
the other merge parent. Because of die-die-die merge the result will
not contain the directory that has been moved to the root.
<p>Missing root conflicts should be very rare because it is unlikely that
a project's root directory will change. It is even more unlikely that
a project's root directory will be changed to some other directory in
one merge parent and that this directory will also be deleted in the
other merge parent. Even still, a missing root directory conflict can
be easily resolved by moving another directory to the root in the
merge parent where the root directory was previously changed. Because
of die-die-die merge, no change to resolve the conflict can be made to
the merge parent that deleted the directory which was moved to the
root in the other merge parent.
<p>See the <samp><span class="command">pivot_root</span></samp> command for more information on moving
another directory to the project root.
<p><samp><span class="command">conflicts</span></samp> does not yet support resolving this conflict.
<h4 class="subheading">Invalid Name Conflict</h4>
<p>Monotone reserves the name <samp><span class="file">_MTN</span></samp> in a workspace root directory
for internal use and treats this name as <em>illegal</em> for a
versioned file or directory in the project root. This name is
<em>legal</em> for a versioned file or directory as long as it is not in
the project root directory.
<p>An invalid name conflict occurs when some directory is moved to the
project root in one of the merge parents and a file or directory that
exists in this new root directory is renamed to <samp><span class="file">_MTN</span></samp> or a new
file or directory is added with the name <samp><span class="file">_MTN</span></samp> to this directory
in the other merge parent.
<p>Invalid name conflicts should be very rare because it is unlikely that
a project's root directory will change. It is even more unlikely that
a project's root directory will change and the new root directory will
contain a file or directory named <samp><span class="file">_MTN</span></samp>. Even still, an invalid
name conflict can be easily resolved in several different ways. A
different root directory can be chosen, the offending <samp><span class="file">_MTN</span></samp> file
or directory can be renamed or deleted, or it can be moved to some
other subdirectory in the project.
<p>See the <samp><span class="command">pivot_root</span></samp> command for more information on moving
another directory to the project root.
<p><samp><span class="command">conflicts</span></samp> does not yet support resolving this conflict.
<h4 class="subheading">Directory Loop Conflict</h4>
<p>A directory loop conflict occurs when one directory is moved under a
second in one of the merge parents and the second directory is moved
under the first in the other merge parent.
<p>Directory loop conflicts should be rare but can be easily resolved by
moving one of the conflicting directories out from under the other.
<p><samp><span class="command">conflicts</span></samp> does not yet support resolving this conflict.
<h4 class="subheading">Orphaned Node Conflict</h4>
<p>An orphaned node conflict occurs when a directory and all of its
contents are deleted in one of the merge parents and further files or
directories are added to this deleted directory, or renamed into it,
in the other merge parent.
<p>Orphaned node conflicts do happen occasionally but can be easily
resolved by renaming the orphaned files or directories out of the
directory that has been deleted and into another directory that exists
in both merge parents, or that has been added in the revision
containing the orphaned files or directories.
<p><samp><span class="command">conflicts</span></samp> supports resolving this conflict. However, if the
orphaned node is a directory that is not empty, and the desired
resolution is 'drop', the user must drop the directory contents and
commit before invoking the conflicts commands.
<h4 class="subheading">Multiple Name Conflict</h4>
<p>A multiple name conflict occurs when a single file or directory has
been renamed to two different names in the two merge parents.
Monotone does not allow this and requires that each file and directory
has exactly one unique name.
<p>Multiple name conflicts do happen occasionally but can be easily
resolved by renaming the conflicting file or directory in one or both
of the merge parents so that both agree on the name.
<p><samp><span class="command">conflicts</span></samp> does not yet support resolving this conflict.
<p>In earlier versions of monotone (those before version 0.39) this type
of conflict was referred to as a <em>name conflict</em>.
<h4 class="subheading">Attribute Conflict</h4>
<p>An attribute conflict occurs when a versioned attribute on a file or
directory is set to two different values by the two merge parents or
if one of the merge parents changes the attribute's value and the
other deletes the attribute entirely.
<p>Attribute conflicts may happen occasionally but can be easily resolved
by ensuring that the attribute is set to the same value or is deleted
in both of the merge parents. Attributes are <em>not</em> merged using
the die-die-die rules and may be resurrected by simply setting their
values.
<p><samp><span class="command">conflicts</span></samp> does not yet support resolving this conflict.
</body></html>
|