annotate en/ch02-tour-merge.xml @ 828:477d6a3e5023

Many final changes.
author Bryan O'Sullivan <bos@serpentine.com>
date Mon, 04 May 2009 23:52:38 -0700
parents d2aacc06e562
children 18131160f7ee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
1 <!-- vim: set filetype=docbkxml shiftwidth=2 autoindent expandtab tw=77 : -->
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
2
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
3 <chapter id="chap:tour-merge">
671
13513d2a128d Add sensible names to chapters.
Bryan O'Sullivan <bos@serpentine.com>
parents: 666
diff changeset
4 <?dbhtml filename="a-tour-of-mercurial-merging-work.html"?>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
5 <title>A tour of Mercurial: merging work</title>
94
0b97b0bdc830 Basic merge coverage.
Bryan O'Sullivan <bos@serpentine.com>
parents: 93
diff changeset
6
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
7 <para id="x_338">We've now covered cloning a repository, making changes in a
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
8 repository, and pulling or pushing changes from one repository
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
9 into another. Our next step is <emphasis>merging</emphasis>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
10 changes from separate repositories.</para>
94
0b97b0bdc830 Basic merge coverage.
Bryan O'Sullivan <bos@serpentine.com>
parents: 93
diff changeset
11
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
12 <sect1>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
13 <title>Merging streams of work</title>
95
47ea206351d5 Split tour into two sections.
Bryan O'Sullivan <bos@serpentine.com>
parents: 94
diff changeset
14
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
15 <para id="x_339">Merging is a fundamental part of working with a distributed
826
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
16 revision control tool. Here are a few cases in which the need
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
17 to merge work arises.</para>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
18 <itemizedlist>
826
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
19 <listitem>
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
20 <para id="x_33a">Alice and Bob each have a personal copy of a
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
21 repository for a project they're collaborating on. Alice
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
22 fixes a bug in her repository; Bob adds a new feature in
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
23 his. They want the shared repository to contain both the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
24 bug fix and the new feature.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
25 </listitem>
826
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
26 <listitem>
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
27 <para id="x_33b">Cynthia frequently works on several different
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
28 tasks for a single project at once, each safely isolated in
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
29 its own repository. Working this way means that she often
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
30 needs to merge one piece of her own work with
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
31 another.</para>
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
32 </listitem>
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
33 </itemizedlist>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
34
826
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
35 <para id="x_33c">Because we need to merge often, Mercurial makes
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
36 the process easy. Let's walk through a merge. We'll begin by
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
37 cloning yet another repository (see how often they spring up?)
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
38 and making a change in it.</para>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
39
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
40 &interaction.tour.merge.clone;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
41
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
42 <para id="x_33d">We should now have two copies of
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
43 <filename>hello.c</filename> with different contents. The
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
44 histories of the two repositories have also diverged, as
691
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
45 illustrated in <xref
826
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
46 linkend="fig:tour-merge:sep-repos"/>. Here is a copy of our
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
47 file from one repository.</para>
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
48
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
49 &interaction.tour.merge.cat1;
94
0b97b0bdc830 Basic merge coverage.
Bryan O'Sullivan <bos@serpentine.com>
parents: 93
diff changeset
50
827
d2aacc06e562 Add more paragraph IDs
Bryan O'Sullivan <bos@serpentine.com>
parents: 826
diff changeset
51 <para id="x_722">And here is our slightly different version from the other
826
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
52 repository.</para>
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
53
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
54 &interaction.tour.merge.cat2;
94
0b97b0bdc830 Basic merge coverage.
Bryan O'Sullivan <bos@serpentine.com>
parents: 93
diff changeset
55
690
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
56 <figure id="fig:tour-merge:sep-repos">
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
57 <title>Divergent recent histories of the <filename
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
58 class="directory">my-hello</filename> and <filename
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
59 class="directory">my-new-hello</filename>
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
60 repositories</title>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
61 <mediaobject>
693
0b45854f0b7b Generate and include images properly.
Bryan O'Sullivan <bos@serpentine.com>
parents: 691
diff changeset
62 <imageobject><imagedata fileref="figs/tour-merge-sep-repos.png"/></imageobject>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
63 <textobject><phrase>XXX add text</phrase></textobject>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
64 </mediaobject>
690
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
65 </figure>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
66
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
67 <para id="x_33f">We already know that pulling changes from our <filename
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
68 class="directory">my-hello</filename> repository will have no
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
69 effect on the working directory.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
70
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
71 &interaction.tour.merge.pull;
99
06383f9e46e4 More graphics.
Bryan O'Sullivan <bos@serpentine.com>
parents: 95
diff changeset
72
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
73 <para id="x_340">However, the <command role="hg-cmd">hg pull</command>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
74 command says something about <quote>heads</quote>.</para>
94
0b97b0bdc830 Basic merge coverage.
Bryan O'Sullivan <bos@serpentine.com>
parents: 93
diff changeset
75
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
76 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
77 <title>Head changesets</title>
102
ff9dc8bc2a8b More. Merge. Stuff.
Bryan O'Sullivan <bos@serpentine.com>
parents: 101
diff changeset
78
826
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
79 <para id="x_341">Remember that Mercurial records what the parent
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
80 of each change is. If a change has a parent, we call it a
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
81 child or descendant of the parent. A head is a change that
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
82 has no children. The tip revision is thus a head, because the
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
83 newest revision in a repository doesn't have any children.
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
84 There are times when a repository can contain more than one
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
85 head.</para>
99
06383f9e46e4 More graphics.
Bryan O'Sullivan <bos@serpentine.com>
parents: 95
diff changeset
86
690
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
87 <figure id="fig:tour-merge:pull">
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
88 <title>Repository contents after pulling from <filename
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
89 class="directory">my-hello</filename> into <filename
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
90 class="directory">my-new-hello</filename></title>
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
91 <mediaobject>
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
92 <imageobject>
693
0b45854f0b7b Generate and include images properly.
Bryan O'Sullivan <bos@serpentine.com>
parents: 691
diff changeset
93 <imagedata fileref="figs/tour-merge-pull.png"/>
690
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
94 </imageobject>
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
95 <textobject><phrase>XXX add text</phrase></textobject>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
96 </mediaobject>
690
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
97 </figure>
99
06383f9e46e4 More graphics.
Bryan O'Sullivan <bos@serpentine.com>
parents: 95
diff changeset
98
691
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
99 <para id="x_343">In <xref linkend="fig:tour-merge:pull"/>, you can
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
100 see the effect of the pull from <filename
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
101 class="directory">my-hello</filename> into <filename
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
102 class="directory">my-new-hello</filename>. The history that
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
103 was already present in <filename
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
104 class="directory">my-new-hello</filename> is untouched, but
691
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
105 a new revision has been added. By referring to <xref
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
106 linkend="fig:tour-merge:sep-repos"/>, we can see that the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
107 <emphasis>changeset ID</emphasis> remains the same in the new
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
108 repository, but the <emphasis>revision number</emphasis> has
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
109 changed. (This, incidentally, is a fine example of why it's
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
110 not safe to use revision numbers when discussing changesets.)
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
111 We can view the heads in a repository using the <command
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
112 role="hg-cmd">hg heads</command> command.</para>
102
ff9dc8bc2a8b More. Merge. Stuff.
Bryan O'Sullivan <bos@serpentine.com>
parents: 101
diff changeset
113
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
114 &interaction.tour.merge.heads;
826
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
115 </sect2>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
116
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
117 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
118 <title>Performing the merge</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
119
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
120 <para id="x_344">What happens if we try to use the normal <command
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
121 role="hg-cmd">hg update</command> command to update to the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
122 new tip?</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
123
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
124 &interaction.tour.merge.update;
102
ff9dc8bc2a8b More. Merge. Stuff.
Bryan O'Sullivan <bos@serpentine.com>
parents: 101
diff changeset
125
826
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
126 <para id="x_345">Mercurial is telling us that the <command
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
127 role="hg-cmd">hg update</command> command won't do a merge;
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
128 it won't update the working directory when it thinks we might
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
129 want to do a merge, unless we force it to do so.
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
130 (Incidentally, forcing the update with <command>hg update
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
131 -C</command> would revert any uncommitted changes in the
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
132 working directory.)</para>
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
133
827
d2aacc06e562 Add more paragraph IDs
Bryan O'Sullivan <bos@serpentine.com>
parents: 826
diff changeset
134 <para id="x_723">To start a merge between the two heads, we use the
826
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
135 <command role="hg-cmd">hg merge</command> command.</para>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
136
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
137 &interaction.tour.merge.merge;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
138
826
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
139 <para id="x_347">We resolve the contents of <filename>hello.c</filename>
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
140
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
141 This updates the working directory so that it
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
142 contains changes from <emphasis>both</emphasis> heads, which
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
143 is reflected in both the output of <command role="hg-cmd">hg
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
144 parents</command> and the contents of
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
145 <filename>hello.c</filename>.</para>
102
ff9dc8bc2a8b More. Merge. Stuff.
Bryan O'Sullivan <bos@serpentine.com>
parents: 101
diff changeset
146
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
147 &interaction.tour.merge.parents;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
148 </sect2>
828
477d6a3e5023 Many final changes.
Bryan O'Sullivan <bos@serpentine.com>
parents: 827
diff changeset
149
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
150 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
151 <title>Committing the results of the merge</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
152
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
153 <para id="x_348">Whenever we've done a merge, <command role="hg-cmd">hg
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
154 parents</command> will display two parents until we <command
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
155 role="hg-cmd">hg commit</command> the results of the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
156 merge.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
157
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
158 &interaction.tour.merge.commit;
94
0b97b0bdc830 Basic merge coverage.
Bryan O'Sullivan <bos@serpentine.com>
parents: 93
diff changeset
159
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
160 <para id="x_349">We now have a new tip revision; notice that it has
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
161 <emphasis>both</emphasis> of our former heads as its parents.
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
162 These are the same revisions that were previously displayed by
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
163 <command role="hg-cmd">hg parents</command>.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
164
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
165 &interaction.tour.merge.tip;
102
ff9dc8bc2a8b More. Merge. Stuff.
Bryan O'Sullivan <bos@serpentine.com>
parents: 101
diff changeset
166
691
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
167 <para id="x_34a">In <xref
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
168 linkend="fig:tour-merge:merge"/>, you can see a
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
169 representation of what happens to the working directory during
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
170 the merge, and how this affects the repository when the commit
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
171 happens. During the merge, the working directory has two
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
172 parent changesets, and these become the parents of the new
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
173 changeset.</para>
103
5b80c922ebdd More merge content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 102
diff changeset
174
718
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
175 <figure id="fig:tour-merge:merge">
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
176 <title>Working directory and repository during merge, and
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
177 following commit</title>
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
178 <mediaobject>
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
179 <imageobject>
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
180 <imagedata fileref="figs/tour-merge-merge.png"/>
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
181 </imageobject>
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
182 <textobject><phrase>XXX add text</phrase></textobject>
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
183 </mediaobject>
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
184 </figure>
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
185
775
29f0f79cf614 Update paragraph IDs
Bryan O'Sullivan <bos@serpentine.com>
parents: 769
diff changeset
186 <para id="x_69c">We sometimes talk about a merge having
718
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
187 <emphasis>sides</emphasis>: the left side is the first parent
769
e9ef075327c1 Merge with http://bitbucket.org/dongsheng/hgbook/
Bryan O'Sullivan <bos@serpentine.com>
parents: 718 754
diff changeset
188 in the output of <command role="hg-cmd">hg parents</command>,
718
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
189 and the right side is the second. If the working directory
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
190 was at e.g. revision 5 before we began a merge, that revision
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
191 will become the left side of the merge.</para>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
192 </sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
193 </sect1>
718
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
194
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
195 <sect1>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
196 <title>Merging conflicting changes</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
197
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
198 <para id="x_34b">Most merges are simple affairs, but sometimes you'll find
718
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
199 yourself merging changes where each side modifies the same portions
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
200 of the same files. Unless both modifications are identical,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
201 this results in a <emphasis>conflict</emphasis>, where you have
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
202 to decide how to reconcile the different changes into something
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
203 coherent.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
204
690
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
205 <figure id="fig:tour-merge:conflict">
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
206 <title>Conflicting changes to a document</title>
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
207 <mediaobject>
693
0b45854f0b7b Generate and include images properly.
Bryan O'Sullivan <bos@serpentine.com>
parents: 691
diff changeset
208 <imageobject><imagedata fileref="figs/tour-merge-conflict.png"/></imageobject>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
209 <textobject><phrase>XXX add text</phrase></textobject>
690
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
210 </mediaobject>
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
211 </figure>
103
5b80c922ebdd More merge content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 102
diff changeset
212
691
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
213 <para id="x_34d"><xref linkend="fig:tour-merge:conflict"/> illustrates
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
214 an instance of two conflicting changes to a document. We
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
215 started with a single version of the file; then we made some
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
216 changes; while someone else made different changes to the same
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
217 text. Our task in resolving the conflicting changes is to
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
218 decide what the file should look like.</para>
103
5b80c922ebdd More merge content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 102
diff changeset
219
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
220 <para id="x_34e">Mercurial doesn't have a built-in facility for handling
718
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
221 conflicts. Instead, it runs an external program, usually one
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
222 that displays some kind of graphical conflict resolution
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
223 interface. By default, Mercurial tries to find one of several
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
224 different merging tools that are likely to be installed on your
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
225 system. It first tries a few fully automatic merging tools; if
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
226 these don't succeed (because the resolution process requires
718
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
227 human guidance) or aren't present, it tries a few
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
228 different graphical merging tools.</para>
103
5b80c922ebdd More merge content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 102
diff changeset
229
826
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
230 <para id="x_34f">It's also possible to get Mercurial to run a
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
231 specific program or script, by setting the
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
232 <envar>HGMERGE</envar> environment variable to the name of your
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
233 preferred program.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
234
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
235 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
236 <title>Using a graphical merge tool</title>
103
5b80c922ebdd More merge content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 102
diff changeset
237
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
238 <para id="x_350">My preferred graphical merge tool is
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
239 <command>kdiff3</command>, which I'll use to describe the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
240 features that are common to graphical file merging tools. You
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
241 can see a screenshot of <command>kdiff3</command> in action in
691
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
242 <xref linkend="fig:tour-merge:kdiff3"/>. The kind of
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
243 merge it is performing is called a <emphasis>three-way
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
244 merge</emphasis>, because there are three different versions
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
245 of the file of interest to us. The tool thus splits the upper
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
246 portion of the window into three panes:</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
247 <itemizedlist>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
248 <listitem><para id="x_351">At the left is the <emphasis>base</emphasis>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
249 version of the file, i.e. the most recent version from
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
250 which the two versions we're trying to merge are
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
251 descended.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
252 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
253 <listitem><para id="x_352">In the middle is <quote>our</quote> version of
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
254 the file, with the contents that we modified.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
255 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
256 <listitem><para id="x_353">On the right is <quote>their</quote> version
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
257 of the file, the one that from the changeset that we're
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
258 trying to merge with.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
259 </listitem></itemizedlist>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
260 <para id="x_354">In the pane below these is the current
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
261 <emphasis>result</emphasis> of the merge. Our task is to
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
262 replace all of the red text, which indicates unresolved
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
263 conflicts, with some sensible merger of the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
264 <quote>ours</quote> and <quote>theirs</quote> versions of the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
265 file.</para>
102
ff9dc8bc2a8b More. Merge. Stuff.
Bryan O'Sullivan <bos@serpentine.com>
parents: 101
diff changeset
266
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
267 <para id="x_355">All four of these panes are <emphasis>locked
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
268 together</emphasis>; if we scroll vertically or horizontally
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
269 in any of them, the others are updated to display the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
270 corresponding sections of their respective files.</para>
103
5b80c922ebdd More merge content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 102
diff changeset
271
690
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
272 <figure id="fig:tour-merge:kdiff3">
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
273 <title>Using <command>kdiff3</command> to merge versions of a
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
274 file</title>
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
275 <mediaobject>
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
276 <imageobject>
754
65e9a18d2c7e Shrink large images to fit page
Dongsheng Song <dongsheng.song@gmail.com>
parents: 753
diff changeset
277 <imagedata width="100%" fileref="figs/kdiff3.png"/></imageobject>
690
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
278 <textobject>
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
279 <phrase>XXX add text</phrase>
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
280 </textobject>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
281 </mediaobject>
690
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
282 </figure>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
283
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
284 <para id="x_357">For each conflicting portion of the file, we can choose to
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
285 resolve the conflict using some combination of text from the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
286 base version, ours, or theirs. We can also manually edit the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
287 merged file at any time, in case we need to make further
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
288 modifications.</para>
103
5b80c922ebdd More merge content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 102
diff changeset
289
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
290 <para id="x_358">There are <emphasis>many</emphasis> file merging tools
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
291 available, too many to cover here. They vary in which
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
292 platforms they are available for, and in their particular
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
293 strengths and weaknesses. Most are tuned for merging files
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
294 containing plain text, while a few are aimed at specialised
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
295 file formats (generally XML).</para>
828
477d6a3e5023 Many final changes.
Bryan O'Sullivan <bos@serpentine.com>
parents: 827
diff changeset
296 </sect2>
103
5b80c922ebdd More merge content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 102
diff changeset
297
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
298 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
299 <title>A worked example</title>
103
5b80c922ebdd More merge content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 102
diff changeset
300
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
301 <para id="x_359">In this example, we will reproduce the file modification
691
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
302 history of <xref linkend="fig:tour-merge:conflict"/>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
303 above. Let's begin by creating a repository with a base
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
304 version of our document.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
305
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
306 &interaction.tour-merge-conflict.wife;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
307
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
308 <para id="x_35a">We'll clone the repository and make a change to the
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
309 file.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
310
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
311 &interaction.tour-merge-conflict.cousin;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
312
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
313 <para id="x_35b">And another clone, to simulate someone else making a
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
314 change to the file. (This hints at the idea that it's not all
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
315 that unusual to merge with yourself when you isolate tasks in
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
316 separate repositories, and indeed to find and resolve
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
317 conflicts while doing so.)</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
318
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
319 &interaction.tour-merge-conflict.son;
103
5b80c922ebdd More merge content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 102
diff changeset
320
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
321 <para id="x_35c">Having created two
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
322 different versions of the file, we'll set up an environment
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
323 suitable for running our merge.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
324
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
325 &interaction.tour-merge-conflict.pull;
649
5cd47f721686 Rename LaTeX input files to have numeric prefixes
Bryan O'Sullivan <bos@serpentine.com>
parents: 481
diff changeset
326
718
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
327 <para id="x_35d">In this example, I'll set
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
328 <envar>HGMERGE</envar> to tell Mercurial to use the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
329 non-interactive <command>merge</command> command. This is
718
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
330 bundled with many Unix-like systems. (If you're following this
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
331 example on your computer, don't bother setting
826
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
332 <envar>HGMERGE</envar>. You'll get dropped into a GUI file
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
333 merge tool instead, which is much preferable.)</para>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
334
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
335 &interaction.tour-merge-conflict.merge;
649
5cd47f721686 Rename LaTeX input files to have numeric prefixes
Bryan O'Sullivan <bos@serpentine.com>
parents: 481
diff changeset
336
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
337 <para id="x_35f">Because <command>merge</command> can't resolve the
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
338 conflicting changes, it leaves <emphasis>merge
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
339 markers</emphasis> inside the file that has conflicts,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
340 indicating which lines have conflicts, and whether they came
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
341 from our version of the file or theirs.</para>
103
5b80c922ebdd More merge content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 102
diff changeset
342
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
343 <para id="x_360">Mercurial can tell from the way <command>merge</command>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
344 exits that it wasn't able to merge successfully, so it tells
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
345 us what commands we'll need to run if we want to redo the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
346 merging operation. This could be useful if, for example, we
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
347 were running a graphical merge tool and quit because we were
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
348 confused or realised we had made a mistake.</para>
103
5b80c922ebdd More merge content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 102
diff changeset
349
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
350 <para id="x_361">If automatic or manual merges fail, there's nothing to
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
351 prevent us from <quote>fixing up</quote> the affected files
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
352 ourselves, and committing the results of our merge:</para>
103
5b80c922ebdd More merge content.
Bryan O'Sullivan <bos@serpentine.com>
parents: 102
diff changeset
353
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
354 &interaction.tour-merge-conflict.commit;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
355
826
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
356 <note>
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
357 <title>Where is the <command>hg resolve</command> command?</title>
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
358
827
d2aacc06e562 Add more paragraph IDs
Bryan O'Sullivan <bos@serpentine.com>
parents: 826
diff changeset
359 <para id="x_724">The <command>hg resolve</command> command was introduced
826
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
360 in Mercurial 1.1, which was released in December 2008. If
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
361 you are using an older version of Mercurial (run <command>hg
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
362 version</command> to see), this command will not be
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
363 present. If your version of Mercurial is older than 1.1,
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
364 you should strongly consider upgrading to a newer version
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
365 before trying to tackle complicated merges.</para>
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
366 </note>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
367 </sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
368 </sect1>
828
477d6a3e5023 Many final changes.
Bryan O'Sullivan <bos@serpentine.com>
parents: 827
diff changeset
369
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
370 <sect1 id="sec:tour-merge:fetch">
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
371 <title>Simplifying the pull-merge-commit sequence</title>
102
ff9dc8bc2a8b More. Merge. Stuff.
Bryan O'Sullivan <bos@serpentine.com>
parents: 101
diff changeset
372
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
373 <para id="x_362">The process of merging changes as outlined above is
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
374 straightforward, but requires running three commands in
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
375 sequence.</para>
718
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
376 <programlisting>hg pull -u
679
80928ea6e7ae Add the ability to include text files and have them XML-mangled.
Bryan O'Sullivan <bos@serpentine.com>
parents: 671
diff changeset
377 hg merge
80928ea6e7ae Add the ability to include text files and have them XML-mangled.
Bryan O'Sullivan <bos@serpentine.com>
parents: 671
diff changeset
378 hg commit -m 'Merged remote changes'</programlisting>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
379 <para id="x_363">In the case of the final commit, you also need to enter a
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
380 commit message, which is almost always going to be a piece of
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
381 uninteresting <quote>boilerplate</quote> text.</para>
102
ff9dc8bc2a8b More. Merge. Stuff.
Bryan O'Sullivan <bos@serpentine.com>
parents: 101
diff changeset
382
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
383 <para id="x_364">It would be nice to reduce the number of steps needed, if
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
384 this were possible. Indeed, Mercurial is distributed with an
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
385 extension called <literal role="hg-ext">fetch</literal> that
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
386 does just this.</para>
102
ff9dc8bc2a8b More. Merge. Stuff.
Bryan O'Sullivan <bos@serpentine.com>
parents: 101
diff changeset
387
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
388 <para id="x_365">Mercurial provides a flexible extension mechanism that lets
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
389 people extend its functionality, while keeping the core of
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
390 Mercurial small and easy to deal with. Some extensions add new
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
391 commands that you can use from the command line, while others
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
392 work <quote>behind the scenes,</quote> for example adding
826
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
393 capabilities to Mercurial's built-in server mode.</para>
102
ff9dc8bc2a8b More. Merge. Stuff.
Bryan O'Sullivan <bos@serpentine.com>
parents: 101
diff changeset
394
718
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
395 <para id="x_366">The <literal role="hg-ext">fetch</literal>
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
396 extension adds a new command called, not surprisingly, <command
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
397 role="hg-cmd">hg fetch</command>. This extension acts as a
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
398 combination of <command role="hg-cmd">hg pull -u</command>,
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
399 <command role="hg-cmd">hg merge</command> and <command
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
400 role="hg-cmd">hg commit</command>. It begins by pulling
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
401 changes from another repository into the current repository. If
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
402 it finds that the changes added a new head to the repository, it
826
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
403 updates to the new head, begins a merge, then (if the merge
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
404 succeeded) commits the result of the merge with an
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
405 automatically-generated commit message. If no new heads were
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
406 added, it updates the working directory to the new tip
a17d6390a480 More fixes to chapters 1 and 2.
Bryan O'Sullivan <bos@serpentine.com>
parents: 775
diff changeset
407 changeset.</para>
102
ff9dc8bc2a8b More. Merge. Stuff.
Bryan O'Sullivan <bos@serpentine.com>
parents: 101
diff changeset
408
718
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
409 <para id="x_367">Enabling the <literal
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
410 role="hg-ext">fetch</literal> extension is easy. Edit the
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
411 <filename role="special">.hgrc</filename> file in your home
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
412 directory, and either go to the <literal
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
413 role="rc-extensions">extensions</literal> section or create an
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
414 <literal role="rc-extensions">extensions</literal> section. Then
718
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
415 add a line that simply reads
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
416 <quote><literal>fetch=</literal></quote>.</para>
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
417
679
80928ea6e7ae Add the ability to include text files and have them XML-mangled.
Bryan O'Sullivan <bos@serpentine.com>
parents: 671
diff changeset
418 <programlisting>[extensions]
80928ea6e7ae Add the ability to include text files and have them XML-mangled.
Bryan O'Sullivan <bos@serpentine.com>
parents: 671
diff changeset
419 fetch =</programlisting>
718
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
420
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
421 <para id="x_368">(Normally, the right-hand side of the
4e23c220d1b0 Update chapter 2
Bryan O'Sullivan <bos@serpentine.com>
parents: 693
diff changeset
422 <quote><literal>=</literal></quote> would indicate where to find
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
423 the extension, but since the <literal
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
424 role="hg-ext">fetch</literal> extension is in the standard
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
425 distribution, Mercurial knows where to search for it.)</para>
828
477d6a3e5023 Many final changes.
Bryan O'Sullivan <bos@serpentine.com>
parents: 827
diff changeset
426 </sect1>
102
ff9dc8bc2a8b More. Merge. Stuff.
Bryan O'Sullivan <bos@serpentine.com>
parents: 101
diff changeset
427
828
477d6a3e5023 Many final changes.
Bryan O'Sullivan <bos@serpentine.com>
parents: 827
diff changeset
428 <sect1>
477d6a3e5023 Many final changes.
Bryan O'Sullivan <bos@serpentine.com>
parents: 827
diff changeset
429 <title>Renaming, copying, and merging</title>
477d6a3e5023 Many final changes.
Bryan O'Sullivan <bos@serpentine.com>
parents: 827
diff changeset
430
477d6a3e5023 Many final changes.
Bryan O'Sullivan <bos@serpentine.com>
parents: 827
diff changeset
431 <para>During the life of a project, we will often want to change
477d6a3e5023 Many final changes.
Bryan O'Sullivan <bos@serpentine.com>
parents: 827
diff changeset
432 the layout of its files and directories. This can be as simple
477d6a3e5023 Many final changes.
Bryan O'Sullivan <bos@serpentine.com>
parents: 827
diff changeset
433 as renaming a single file, or as complex as restructuring the
477d6a3e5023 Many final changes.
Bryan O'Sullivan <bos@serpentine.com>
parents: 827
diff changeset
434 entire hierarchy of files within the project.</para>
477d6a3e5023 Many final changes.
Bryan O'Sullivan <bos@serpentine.com>
parents: 827
diff changeset
435
477d6a3e5023 Many final changes.
Bryan O'Sullivan <bos@serpentine.com>
parents: 827
diff changeset
436 <para>Mercurial supports these kinds of complex changes fluently,
477d6a3e5023 Many final changes.
Bryan O'Sullivan <bos@serpentine.com>
parents: 827
diff changeset
437 provided we tell it what we're doing. If we want to rename a
477d6a3e5023 Many final changes.
Bryan O'Sullivan <bos@serpentine.com>
parents: 827
diff changeset
438 file, we should use the <command>hg rename</command><footnote>
477d6a3e5023 Many final changes.
Bryan O'Sullivan <bos@serpentine.com>
parents: 827
diff changeset
439 <para>If you're a Unix user, you'll be glad to know that the
477d6a3e5023 Many final changes.
Bryan O'Sullivan <bos@serpentine.com>
parents: 827
diff changeset
440 <command>hg rename</command> command can be abbreviated as
477d6a3e5023 Many final changes.
Bryan O'Sullivan <bos@serpentine.com>
parents: 827
diff changeset
441 <command>hg mv</command>.</para>
477d6a3e5023 Many final changes.
Bryan O'Sullivan <bos@serpentine.com>
parents: 827
diff changeset
442 </footnote> command to rename it, so that Mercurial can do the
477d6a3e5023 Many final changes.
Bryan O'Sullivan <bos@serpentine.com>
parents: 827
diff changeset
443 right thing later when we merge.</para>
477d6a3e5023 Many final changes.
Bryan O'Sullivan <bos@serpentine.com>
parents: 827
diff changeset
444
477d6a3e5023 Many final changes.
Bryan O'Sullivan <bos@serpentine.com>
parents: 827
diff changeset
445 <para>We will cover the use of these commands in more detail in
477d6a3e5023 Many final changes.
Bryan O'Sullivan <bos@serpentine.com>
parents: 827
diff changeset
446 <xref linkend="chap:daily.copy"/>.</para>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
447 </sect1>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
448 </chapter>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
449
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
450 <!--
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
451 local variables:
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
452 sgml-parent-document: ("00book.xml" "book" "chapter")
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
453 end:
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents: 650
diff changeset
454 -->