annotate en/ch08-undo.xml @ 808:557552d4699f

Add IDs to paragraphs.
author Bryan O'Sullivan <bos@serpentine.com>
date Tue, 21 Apr 2009 23:51:47 -0700
parents 7226e5e750a6
children 1a0a78e197c3
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:
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:
diff changeset
2
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
3 <chapter id="chap:undo">
671
13513d2a128d Add sensible names to chapters.
Bryan O'Sullivan <bos@serpentine.com>
parents: 666
diff changeset
4 <?dbhtml filename="finding-and-fixing-mistakes.html"?>
13513d2a128d Add sensible names to chapters.
Bryan O'Sullivan <bos@serpentine.com>
parents: 666
diff changeset
5 <title>Finding and fixing mistakes</title>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
6
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
7 <para id="x_d2">To err might be human, but to really handle the consequences
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
8 well takes a top-notch revision control system. In this chapter,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
9 we'll discuss some of the techniques you can use when you find
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
10 that a problem has crept into your project. Mercurial has some
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
11 highly capable features that will help you to isolate the sources
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
12 of problems, and to handle them appropriately.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
13
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
14 <sect1>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
15 <title>Erasing local history</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
16
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
17 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
18 <title>The accidental commit</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
19
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
20 <para id="x_d3">I have the occasional but persistent problem of typing
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
21 rather more quickly than I can think, which sometimes results
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
22 in me committing a changeset that is either incomplete or
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
23 plain wrong. In my case, the usual kind of incomplete
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
24 changeset is one in which I've created a new source file, but
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
25 forgotten to <command role="hg-cmd">hg add</command> it. A
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
26 <quote>plain wrong</quote> changeset is not as common, but no
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
27 less annoying.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
28
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
29 </sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
30 <sect2 id="sec:undo:rollback">
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
31 <title>Rolling back a transaction</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
32
691
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
33 <para id="x_d4">In <xref linkend="sec:concepts:txn"/>, I
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
34 mentioned that Mercurial treats each modification of a
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
35 repository as a <emphasis>transaction</emphasis>. Every time
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
36 you commit a changeset or pull changes from another
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
37 repository, Mercurial remembers what you did. You can undo,
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
38 or <emphasis>roll back</emphasis>, exactly one of these
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
39 actions using the <command role="hg-cmd">hg rollback</command>
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
40 command. (See <xref linkend="sec:undo:rollback-after-push"/>
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
41 for an important caveat about the use of this command.)</para>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
42
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
43 <para id="x_d5">Here's a mistake that I often find myself making:
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
44 committing a change in which I've created a new file, but
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
45 forgotten to <command role="hg-cmd">hg add</command>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
46 it.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
47
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
48 &interaction.rollback.commit;
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
49
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
50 <para id="x_d6">Looking at the output of <command role="hg-cmd">hg
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
51 status</command> after the commit immediately confirms the
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
52 error.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
53
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
54 &interaction.rollback.status;
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
55
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
56 <para id="x_d7">The commit captured the changes to the file
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
57 <filename>a</filename>, but not the new file
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
58 <filename>b</filename>. If I were to push this changeset to a
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
59 repository that I shared with a colleague, the chances are
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
60 high that something in <filename>a</filename> would refer to
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
61 <filename>b</filename>, which would not be present in their
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
62 repository when they pulled my changes. I would thus become
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
63 the object of some indignation.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
64
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
65 <para id="x_d8">However, luck is with me&emdash;I've caught my error
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
66 before I pushed the changeset. I use the <command
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
67 role="hg-cmd">hg rollback</command> command, and Mercurial
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
68 makes that last changeset vanish.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
69
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
70 &interaction.rollback.rollback;
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
71
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
72 <para id="x_d9">Notice that the changeset is no longer present in the
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
73 repository's history, and the working directory once again
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
74 thinks that the file <filename>a</filename> is modified. The
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
75 commit and rollback have left the working directory exactly as
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
76 it was prior to the commit; the changeset has been completely
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
77 erased. I can now safely <command role="hg-cmd">hg
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
78 add</command> the file <filename>b</filename>, and rerun my
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
79 commit.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
80
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
81 &interaction.rollback.add;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
82
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
83 </sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
84 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
85 <title>The erroneous pull</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
86
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
87 <para id="x_da">It's common practice with Mercurial to maintain separate
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
88 development branches of a project in different repositories.
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
89 Your development team might have one shared repository for
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
90 your project's <quote>0.9</quote> release, and another,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
91 containing different changes, for the <quote>1.0</quote>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
92 release.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
93
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
94 <para id="x_db">Given this, you can imagine that the consequences could be
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
95 messy if you had a local <quote>0.9</quote> repository, and
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
96 accidentally pulled changes from the shared <quote>1.0</quote>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
97 repository into it. At worst, you could be paying
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
98 insufficient attention, and push those changes into the shared
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
99 <quote>0.9</quote> tree, confusing your entire team (but don't
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
100 worry, we'll return to this horror scenario later). However,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
101 it's more likely that you'll notice immediately, because
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
102 Mercurial will display the URL it's pulling from, or you will
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
103 see it pull a suspiciously large number of changes into the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
104 repository.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
105
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
106 <para id="x_dc">The <command role="hg-cmd">hg rollback</command> command
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
107 will work nicely to expunge all of the changesets that you
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
108 just pulled. Mercurial groups all changes from one <command
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
109 role="hg-cmd">hg pull</command> into a single transaction,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
110 so one <command role="hg-cmd">hg rollback</command> is all you
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
111 need to undo this mistake.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
112
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
113 </sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
114 <sect2 id="sec:undo:rollback-after-push">
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
115 <title>Rolling back is useless once you've pushed</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
116
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
117 <para id="x_dd">The value of the <command role="hg-cmd">hg
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
118 rollback</command> command drops to zero once you've pushed
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
119 your changes to another repository. Rolling back a change
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
120 makes it disappear entirely, but <emphasis>only</emphasis> in
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
121 the repository in which you perform the <command
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
122 role="hg-cmd">hg rollback</command>. Because a rollback
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
123 eliminates history, there's no way for the disappearance of a
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
124 change to propagate between repositories.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
125
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
126 <para id="x_de">If you've pushed a change to another
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
127 repository&emdash;particularly if it's a shared
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
128 repository&emdash;it has essentially <quote>escaped into the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
129 wild,</quote> and you'll have to recover from your mistake
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
130 in a different way. If you push a changeset somewhere, then
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
131 roll it back, then pull from the repository you pushed to, the
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
132 changeset you thought you'd gotten rid of will simply reappear
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
133 in your repository.</para>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
134
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
135 <para id="x_df">(If you absolutely know for sure that the change
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
136 you want to roll back is the most recent change in the
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
137 repository that you pushed to, <emphasis>and</emphasis> you
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
138 know that nobody else could have pulled it from that
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
139 repository, you can roll back the changeset there, too, but
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
140 you really should not expect this to work reliably. Sooner or
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
141 later a change really will make it into a repository that you
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
142 don't directly control (or have forgotten about), and come
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
143 back to bite you.)</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
144
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
145 </sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
146 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
147 <title>You can only roll back once</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
148
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
149 <para id="x_e0">Mercurial stores exactly one transaction in its
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
150 transaction log; that transaction is the most recent one that
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
151 occurred in the repository. This means that you can only roll
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
152 back one transaction. If you expect to be able to roll back
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
153 one transaction, then its predecessor, this is not the
771
b338f5490029 Americanize spellings :-(
Bryan O'Sullivan <bos@serpentine.com>
parents: 753
diff changeset
154 behavior you will get.</para>
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
155
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
156 &interaction.rollback.twice;
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
157
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
158 <para id="x_e1">Once you've rolled back one transaction in a repository,
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
159 you can't roll back again in that repository until you perform
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
160 another commit or pull.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
161
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
162 </sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
163 </sect1>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
164 <sect1>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
165 <title>Reverting the mistaken change</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
166
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
167 <para id="x_e2">If you make a modification to a file, and decide that you
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
168 really didn't want to change the file at all, and you haven't
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
169 yet committed your changes, the <command role="hg-cmd">hg
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
170 revert</command> command is the one you'll need. It looks at
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
171 the changeset that's the parent of the working directory, and
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
172 restores the contents of the file to their state as of that
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
173 changeset. (That's a long-winded way of saying that, in the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
174 normal case, it undoes your modifications.)</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
175
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
176 <para id="x_e3">Let's illustrate how the <command role="hg-cmd">hg
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
177 revert</command> command works with yet another small example.
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
178 We'll begin by modifying a file that Mercurial is already
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
179 tracking.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
180
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
181 &interaction.daily.revert.modify;
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
182
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
183 <para id="x_e4">If we don't
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
184 want that change, we can simply <command role="hg-cmd">hg
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
185 revert</command> the file.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
186
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
187 &interaction.daily.revert.unmodify;
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
188
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
189 <para id="x_e5">The <command role="hg-cmd">hg revert</command> command
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
190 provides us with an extra degree of safety by saving our
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
191 modified file with a <filename>.orig</filename>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
192 extension.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
193
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
194 &interaction.daily.revert.status;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
195
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
196 <tip>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
197 <title>Be careful with <filename>.orig</filename> files</title>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
198
808
557552d4699f Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 807
diff changeset
199 <para id="x_6b8">It's extremely unlikely that you are either using
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
200 Mercurial to manage files with <filename>.orig</filename>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
201 extensions or that you even care about the contents of such
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
202 files. Just in case, though, it's useful to remember that
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
203 <command role="hg-cmd">hg revert</command> will
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
204 unconditionally overwrite an existing file with a
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
205 <filename>.orig</filename> extension. For instance, if you
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
206 already have a file named <filename>foo.orig</filename> when
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
207 you revert <filename>foo</filename>, the contents of
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
208 <filename>foo.orig</filename> will be clobbered.</para>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
209 </tip>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
210
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
211 <para id="x_e6">Here is a summary of the cases that the <command
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
212 role="hg-cmd">hg revert</command> command can deal with. We
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
213 will describe each of these in more detail in the section that
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
214 follows.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
215 <itemizedlist>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
216 <listitem><para id="x_e7">If you modify a file, it will restore the file
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
217 to its unmodified state.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
218 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
219 <listitem><para id="x_e8">If you <command role="hg-cmd">hg add</command> a
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
220 file, it will undo the <quote>added</quote> state of the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
221 file, but leave the file itself untouched.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
222 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
223 <listitem><para id="x_e9">If you delete a file without telling Mercurial,
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
224 it will restore the file to its unmodified contents.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
225 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
226 <listitem><para id="x_ea">If you use the <command role="hg-cmd">hg
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
227 remove</command> command to remove a file, it will undo
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
228 the <quote>removed</quote> state of the file, and restore
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
229 the file to its unmodified contents.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
230 </listitem></itemizedlist>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
231
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
232 <sect2 id="sec:undo:mgmt">
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
233 <title>File management errors</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
234
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
235 <para id="x_eb">The <command role="hg-cmd">hg revert</command> command is
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
236 useful for more than just modified files. It lets you reverse
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
237 the results of all of Mercurial's file management
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
238 commands&emdash;<command role="hg-cmd">hg add</command>,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
239 <command role="hg-cmd">hg remove</command>, and so on.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
240
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
241 <para id="x_ec">If you <command role="hg-cmd">hg add</command> a file,
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
242 then decide that in fact you don't want Mercurial to track it,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
243 use <command role="hg-cmd">hg revert</command> to undo the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
244 add. Don't worry; Mercurial will not modify the file in any
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
245 way. It will just <quote>unmark</quote> the file.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
246
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
247 &interaction.daily.revert.add;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
248
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
249 <para id="x_ed">Similarly, if you ask Mercurial to <command
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
250 role="hg-cmd">hg remove</command> a file, you can use
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
251 <command role="hg-cmd">hg revert</command> to restore it to
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
252 the contents it had as of the parent of the working directory.
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
253 &interaction.daily.revert.remove; This works just as
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
254 well for a file that you deleted by hand, without telling
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
255 Mercurial (recall that in Mercurial terminology, this kind of
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
256 file is called <quote>missing</quote>).</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
257
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
258 &interaction.daily.revert.missing;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
259
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
260 <para id="x_ee">If you revert a <command role="hg-cmd">hg copy</command>,
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
261 the copied-to file remains in your working directory
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
262 afterwards, untracked. Since a copy doesn't affect the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
263 copied-from file in any way, Mercurial doesn't do anything
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
264 with the copied-from file.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
265
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
266 &interaction.daily.revert.copy;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
267 </sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
268 </sect1>
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
269
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
270 <sect1>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
271 <title>Dealing with committed changes</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
272
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
273 <para id="x_f5">Consider a case where you have committed a change
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
274 <emphasis>a</emphasis>, and another change
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
275 <emphasis>b</emphasis> on top of it; you then realise that
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
276 change <emphasis>a</emphasis> was incorrect. Mercurial lets you
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
277 <quote>back out</quote> an entire changeset automatically, and
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
278 building blocks that let you reverse part of a changeset by
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
279 hand.</para>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
280
691
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
281 <para id="x_f6">Before you read this section, here's something to
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
282 keep in mind: the <command role="hg-cmd">hg backout</command>
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
283 command undoes the effect of a change by
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
284 <emphasis>adding</emphasis> to your repository's history, not by
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
285 modifying or erasing it. It's the right tool to use if you're
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
286 fixing bugs, but not if you're trying to undo some change that
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
287 has catastrophic consequences. To deal with those, see
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
288 <xref linkend="sec:undo:aaaiiieee"/>.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
289
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
290 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
291 <title>Backing out a changeset</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
292
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
293 <para id="x_f7">The <command role="hg-cmd">hg backout</command> command
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
294 lets you <quote>undo</quote> the effects of an entire
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
295 changeset in an automated fashion. Because Mercurial's
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
296 history is immutable, this command <emphasis>does
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
297 not</emphasis> get rid of the changeset you want to undo.
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
298 Instead, it creates a new changeset that
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
299 <emphasis>reverses</emphasis> the effect of the to-be-undone
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
300 changeset.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
301
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
302 <para id="x_f8">The operation of the <command role="hg-cmd">hg
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
303 backout</command> command is a little intricate, so let's
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
304 illustrate it with some examples. First, we'll create a
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
305 repository with some simple changes.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
306
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
307 &interaction.backout.init;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
308
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
309 <para id="x_f9">The <command role="hg-cmd">hg backout</command> command
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
310 takes a single changeset ID as its argument; this is the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
311 changeset to back out. Normally, <command role="hg-cmd">hg
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
312 backout</command> will drop you into a text editor to write
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
313 a commit message, so you can record why you're backing the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
314 change out. In this example, we provide a commit message on
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
315 the command line using the <option
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
316 role="hg-opt-backout">-m</option> option.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
317
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
318 </sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
319 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
320 <title>Backing out the tip changeset</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
321
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
322 <para id="x_fa">We're going to start by backing out the last changeset we
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
323 committed.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
324
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
325 &interaction.backout.simple;
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
326
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
327 <para id="x_fb">You can see that the second line from
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
328 <filename>myfile</filename> is no longer present. Taking a
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
329 look at the output of <command role="hg-cmd">hg log</command>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
330 gives us an idea of what the <command role="hg-cmd">hg
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
331 backout</command> command has done.
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
332 &interaction.backout.simple.log; Notice that the new changeset
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
333 that <command role="hg-cmd">hg backout</command> has created
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
334 is a child of the changeset we backed out. It's easier to see
691
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
335 this in <xref linkend="fig:undo:backout"/>, which presents a
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
336 graphical view of the change history. As you can see, the
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
337 history is nice and linear.</para>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
338
690
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
339 <figure id="fig:undo:backout">
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
340 <title>Backing out a change using the <command
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
341 role="hg-cmd">hg backout</command> command</title>
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
342 <mediaobject>
693
0b45854f0b7b Generate and include images properly.
Bryan O'Sullivan <bos@serpentine.com>
parents: 691
diff changeset
343 <imageobject><imagedata fileref="figs/undo-simple.png"/></imageobject>
690
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
344 <textobject><phrase>XXX add text</phrase></textobject>
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
345 </mediaobject>
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
346 </figure>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
347
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
348 </sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
349 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
350 <title>Backing out a non-tip change</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
351
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
352 <para id="x_fd">If you want to back out a change other than the last one
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
353 you committed, pass the <option
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
354 role="hg-opt-backout">--merge</option> option to the
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
355 <command role="hg-cmd">hg backout</command> command.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
356
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
357 &interaction.backout.non-tip.clone;
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
358
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
359 <para id="x_fe">This makes backing out any changeset a
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
360 <quote>one-shot</quote> operation that's usually simple and
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
361 fast.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
362
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
363 &interaction.backout.non-tip.backout;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
364
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
365 <para id="x_ff">If you take a look at the contents of
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
366 <filename>myfile</filename> after the backout finishes, you'll
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
367 see that the first and third changes are present, but not the
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
368 second.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
369
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
370 &interaction.backout.non-tip.cat;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
371
691
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
372 <para id="x_100">As the graphical history in <xref
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
373 linkend="fig:undo:backout-non-tip"/> illustrates, Mercurial
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
374 still commits one change in this kind of situation (the
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
375 box-shaped node is the ones that Mercurial commits
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
376 automatically), but the revision graph now looks different.
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
377 Before Mercurial begins the backout process, it first
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
378 remembers what the current parent of the working directory is.
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
379 It then backs out the target changeset, and commits that as a
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
380 changeset. Finally, it merges back to the previous parent of
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
381 the working directory, but notice that it <emphasis>does not
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
382 commit</emphasis> the result of the merge. The repository
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
383 now contains two heads, and the working directory is in a
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
384 merge state.</para>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
385
690
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
386 <figure id="fig:undo:backout-non-tip">
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
387 <title>Automated backout of a non-tip change using the
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
388 <command role="hg-cmd">hg backout</command> command</title>
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
389 <mediaobject>
693
0b45854f0b7b Generate and include images properly.
Bryan O'Sullivan <bos@serpentine.com>
parents: 691
diff changeset
390 <imageobject><imagedata fileref="figs/undo-non-tip.png"/></imageobject>
690
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
391 <textobject><phrase>XXX add text</phrase></textobject>
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
392 </mediaobject>
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
393 </figure>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
394
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
395 <para id="x_103">The result is that you end up <quote>back where you
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
396 were</quote>, only with some extra history that undoes the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
397 effect of the changeset you wanted to back out.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
398
808
557552d4699f Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 807
diff changeset
399 <para id="x_6b9">You might wonder why Mercurial does not commit the result
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
400 of the merge that it performed. The reason lies in Mercurial
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
401 behaving conservatively: a merge naturally has more scope for
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
402 error than simply undoing the effect of the tip changeset,
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
403 so your work will be safest if you first inspect (and test!)
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
404 the result of the merge, <emphasis>then</emphasis> commit
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
405 it.</para>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
406
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
407 <sect3>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
408 <title>Always use the <option
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
409 role="hg-opt-backout">--merge</option> option</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
410
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
411 <para id="x_104">In fact, since the <option
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
412 role="hg-opt-backout">--merge</option> option will do the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
413 <quote>right thing</quote> whether or not the changeset
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
414 you're backing out is the tip (i.e. it won't try to merge if
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
415 it's backing out the tip, since there's no need), you should
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
416 <emphasis>always</emphasis> use this option when you run the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
417 <command role="hg-cmd">hg backout</command> command.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
418
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
419 </sect3>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
420 </sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
421 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
422 <title>Gaining more control of the backout process</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
423
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
424 <para id="x_105">While I've recommended that you always use the <option
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
425 role="hg-opt-backout">--merge</option> option when backing
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
426 out a change, the <command role="hg-cmd">hg backout</command>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
427 command lets you decide how to merge a backout changeset.
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
428 Taking control of the backout process by hand is something you
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
429 will rarely need to do, but it can be useful to understand
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
430 what the <command role="hg-cmd">hg backout</command> command
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
431 is doing for you automatically. To illustrate this, let's
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
432 clone our first repository, but omit the backout change that
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
433 it contains.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
434
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
435 &interaction.backout.manual.clone;
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
436
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
437 <para id="x_106">As with our
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
438 earlier example, We'll commit a third changeset, then back out
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
439 its parent, and see what happens.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
440
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
441 &interaction.backout.manual.backout;
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
442
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
443 <para id="x_107">Our new changeset is again a descendant of the changeset
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
444 we backout out; it's thus a new head, <emphasis>not</emphasis>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
445 a descendant of the changeset that was the tip. The <command
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
446 role="hg-cmd">hg backout</command> command was quite
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
447 explicit in telling us this.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
448
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
449 &interaction.backout.manual.log;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
450
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
451 <para id="x_108">Again, it's easier to see what has happened by looking at
691
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
452 a graph of the revision history, in <xref
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
453 linkend="fig:undo:backout-manual"/>. This makes it clear
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
454 that when we use <command role="hg-cmd">hg backout</command>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
455 to back out a change other than the tip, Mercurial adds a new
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
456 head to the repository (the change it committed is
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
457 box-shaped).</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
458
690
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
459 <figure id="fig:undo:backout-manual">
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
460 <title>Backing out a change using the <command
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
461 role="hg-cmd">hg backout</command> command</title>
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
462 <mediaobject>
693
0b45854f0b7b Generate and include images properly.
Bryan O'Sullivan <bos@serpentine.com>
parents: 691
diff changeset
463 <imageobject><imagedata fileref="figs/undo-manual.png"/></imageobject>
690
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
464 <textobject><phrase>XXX add text</phrase></textobject>
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
465 </mediaobject>
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
466 </figure>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
467
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
468 <para id="x_10a">After the <command role="hg-cmd">hg backout</command>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
469 command has completed, it leaves the new
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
470 <quote>backout</quote> changeset as the parent of the working
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
471 directory.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
472
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
473 &interaction.backout.manual.parents;
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
474
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
475 <para id="x_10b">Now we have two isolated sets of changes.</para>
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
476
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
477 &interaction.backout.manual.heads;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
478
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
479 <para id="x_10c">Let's think about what we expect to see as the contents of
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
480 <filename>myfile</filename> now. The first change should be
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
481 present, because we've never backed it out. The second change
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
482 should be missing, as that's the change we backed out. Since
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
483 the history graph shows the third change as a separate head,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
484 we <emphasis>don't</emphasis> expect to see the third change
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
485 present in <filename>myfile</filename>.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
486
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
487 &interaction.backout.manual.cat;
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
488
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
489 <para id="x_10d">To get the third change back into the file, we just do a
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
490 normal merge of our two heads.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
491
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
492 &interaction.backout.manual.merge;
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
493
691
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
494 <para id="x_10e">Afterwards, the graphical history of our
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
495 repository looks like
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
496 <xref linkend="fig:undo:backout-manual-merge"/>.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
497
690
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
498 <figure id="fig:undo:backout-manual-merge">
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
499 <title>Manually merging a backout change</title>
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
500 <mediaobject>
693
0b45854f0b7b Generate and include images properly.
Bryan O'Sullivan <bos@serpentine.com>
parents: 691
diff changeset
501 <imageobject><imagedata fileref="figs/undo-manual-merge.png"/></imageobject>
690
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
502 <textobject><phrase>XXX add text</phrase></textobject>
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
503 </mediaobject>
b788b405e141 Replace uses of <informalfigure> with <figure>
Bryan O'Sullivan <bos@serpentine.com>
parents: 683
diff changeset
504 </figure>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
505
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
506 </sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
507 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
508 <title>Why <command role="hg-cmd">hg backout</command> works as
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
509 it does</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
510
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
511 <para id="x_110">Here's a brief description of how the <command
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
512 role="hg-cmd">hg backout</command> command works.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
513 <orderedlist>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
514 <listitem><para id="x_111">It ensures that the working directory is
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
515 <quote>clean</quote>, i.e. that the output of <command
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
516 role="hg-cmd">hg status</command> would be empty.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
517 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
518 <listitem><para id="x_112">It remembers the current parent of the working
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
519 directory. Let's call this changeset
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
520 <literal>orig</literal>.</para>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
521 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
522 <listitem><para id="x_113">It does the equivalent of a <command
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
523 role="hg-cmd">hg update</command> to sync the working
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
524 directory to the changeset you want to back out. Let's
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
525 call this changeset <literal>backout</literal>.</para>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
526 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
527 <listitem><para id="x_114">It finds the parent of that changeset. Let's
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
528 call that changeset <literal>parent</literal>.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
529 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
530 <listitem><para id="x_115">For each file that the
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
531 <literal>backout</literal> changeset affected, it does the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
532 equivalent of a <command role="hg-cmd">hg revert -r
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
533 parent</command> on that file, to restore it to the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
534 contents it had before that changeset was
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
535 committed.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
536 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
537 <listitem><para id="x_116">It commits the result as a new changeset.
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
538 This changeset has <literal>backout</literal> as its
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
539 parent.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
540 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
541 <listitem><para id="x_117">If you specify <option
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
542 role="hg-opt-backout">--merge</option> on the command
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
543 line, it merges with <literal>orig</literal>, and commits
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
544 the result of the merge.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
545 </listitem></orderedlist>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
546
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
547 <para id="x_118">An alternative way to implement the <command
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
548 role="hg-cmd">hg backout</command> command would be to
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
549 <command role="hg-cmd">hg export</command> the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
550 to-be-backed-out changeset as a diff, then use the <option
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
551 role="cmd-opt-patch">--reverse</option> option to the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
552 <command>patch</command> command to reverse the effect of the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
553 change without fiddling with the working directory. This
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
554 sounds much simpler, but it would not work nearly as
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
555 well.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
556
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
557 <para id="x_119">The reason that <command role="hg-cmd">hg
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
558 backout</command> does an update, a commit, a merge, and
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
559 another commit is to give the merge machinery the best chance
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
560 to do a good job when dealing with all the changes
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
561 <emphasis>between</emphasis> the change you're backing out and
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
562 the current tip.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
563
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
564 <para id="x_11a">If you're backing out a changeset that's 100 revisions
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
565 back in your project's history, the chances that the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
566 <command>patch</command> command will be able to apply a
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
567 reverse diff cleanly are not good, because intervening changes
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
568 are likely to have <quote>broken the context</quote> that
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
569 <command>patch</command> uses to determine whether it can
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
570 apply a patch (if this sounds like gibberish, see <xref
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
571 linkend="sec:mq:patch"/> for a
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
572 discussion of the <command>patch</command> command). Also,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
573 Mercurial's merge machinery will handle files and directories
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
574 being renamed, permission changes, and modifications to binary
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
575 files, none of which <command>patch</command> can deal
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
576 with.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
577
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
578 </sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
579 </sect1>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
580 <sect1 id="sec:undo:aaaiiieee">
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
581 <title>Changes that should never have been</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
582
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
583 <para id="x_11b">Most of the time, the <command role="hg-cmd">hg
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
584 backout</command> command is exactly what you need if you want
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
585 to undo the effects of a change. It leaves a permanent record
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
586 of exactly what you did, both when committing the original
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
587 changeset and when you cleaned up after it.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
588
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
589 <para id="x_11c">On rare occasions, though, you may find that you've
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
590 committed a change that really should not be present in the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
591 repository at all. For example, it would be very unusual, and
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
592 usually considered a mistake, to commit a software project's
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
593 object files as well as its source files. Object files have
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
594 almost no intrinsic value, and they're <emphasis>big</emphasis>,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
595 so they increase the size of the repository and the amount of
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
596 time it takes to clone or pull changes.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
597
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
598 <para id="x_11d">Before I discuss the options that you have if you commit a
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
599 <quote>brown paper bag</quote> change (the kind that's so bad
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
600 that you want to pull a brown paper bag over your head), let me
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
601 first discuss some approaches that probably won't work.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
602
691
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
603 <para id="x_11e">Since Mercurial treats history as
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
604 accumulative&emdash;every change builds on top of all changes
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
605 that preceded it&emdash;you generally can't just make disastrous
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
606 changes disappear. The one exception is when you've just
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
607 committed a change, and it hasn't been pushed or pulled into
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
608 another repository. That's when you can safely use the <command
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
609 role="hg-cmd">hg rollback</command> command, as I detailed in
4ce9d0754af3 Remove the words "section", "chapter", etc from in front of xref tags.
Bryan O'Sullivan <bos@serpentine.com>
parents: 690
diff changeset
610 <xref linkend="sec:undo:rollback"/>.</para>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
611
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
612 <para id="x_11f">After you've pushed a bad change to another repository, you
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
613 <emphasis>could</emphasis> still use <command role="hg-cmd">hg
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
614 rollback</command> to make your local copy of the change
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
615 disappear, but it won't have the consequences you want. The
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
616 change will still be present in the remote repository, so it
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
617 will reappear in your local repository the next time you
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
618 pull.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
619
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
620 <para id="x_120">If a situation like this arises, and you know which
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
621 repositories your bad change has propagated into, you can
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
622 <emphasis>try</emphasis> to get rid of the change from
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
623 <emphasis>every</emphasis> one of those repositories. This is,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
624 of course, not a satisfactory solution: if you miss even a
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
625 single repository while you're expunging, the change is still
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
626 <quote>in the wild</quote>, and could propagate further.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
627
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
628 <para id="x_121">If you've committed one or more changes
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
629 <emphasis>after</emphasis> the change that you'd like to see
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
630 disappear, your options are further reduced. Mercurial doesn't
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
631 provide a way to <quote>punch a hole</quote> in history, leaving
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
632 changesets intact.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
633
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
634 <sect2>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
635 <title>Backing out a merge</title>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
636
808
557552d4699f Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 807
diff changeset
637 <para id="x_6ba">Since merges are often complicated, it is not unheard of
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
638 for a merge to be mangled badly, but committed erroneously.
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
639 Mercurial provides an important safeguard against bad merges
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
640 by refusing to commit unresolved files, but human ingenuity
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
641 guarantees that it is still possible to mess a merge up and
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
642 commit it.</para>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
643
808
557552d4699f Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 807
diff changeset
644 <para id="x_6bb">Given a bad merge that has been committed, usually the
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
645 best way to approach it is to simply try to repair the damage
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
646 by hand. A complete disaster that cannot be easily fixed up
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
647 by hand ought to be very rare, but the <command
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
648 role="hg-cmd">hg backout</command> command may help in
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
649 making the cleanup easier. It offers a <option
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
650 role="hg-opt-backout">--parent</option> option, which lets
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
651 you specify which parent to revert to when backing out a
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
652 merge.</para>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
653
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
654 <figure id="fig:undo:bad-merge-1">
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
655 <title>A bad merge</title>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
656 <mediaobject>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
657 <imageobject><imagedata fileref="figs/bad-merge-1.png"/></imageobject>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
658 <textobject><phrase>XXX add text</phrase></textobject>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
659 </mediaobject>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
660 </figure>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
661
808
557552d4699f Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 807
diff changeset
662 <para id="x_6bc">Suppose we have a revision graph like that in <xref
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
663 linkend="fig:undo:bad-merge-1"/>. What we'd like is to
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
664 <emphasis>redo</emphasis> the merge of revisions 2 and
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
665 3.</para>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
666
808
557552d4699f Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 807
diff changeset
667 <para id="x_6bd">One way to do so would be as follows.</para>
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
668
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
669 <orderedlist>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
670 <listitem>
808
557552d4699f Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 807
diff changeset
671 <para id="x_6be">Call <command role="hg-cmd">hg backout --rev=4
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
672 --parent=2</command>. This tells <command
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
673 role="hg-cmd">hg backout</command> to back out revision
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
674 4, which is the bad merge, and to when deciding which
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
675 revision to prefer, to choose parent 2, one of the parents
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
676 of the merge. The effect can be seen in <xref
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
677 linkend="fig:undo:bad-merge-2"/>.</para>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
678 <figure id="fig:undo:bad-merge-2">
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
679 <title>Backing out the merge, favoring one parent</title>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
680 <mediaobject>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
681 <imageobject><imagedata fileref="figs/bad-merge-2.png"/></imageobject>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
682 <textobject><phrase>XXX add text</phrase></textobject>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
683 </mediaobject>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
684 </figure>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
685 </listitem>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
686
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
687 <listitem>
808
557552d4699f Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 807
diff changeset
688 <para id="x_6bf">Call <command role="hg-cmd">hg backout --rev=4
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
689 --parent=3</command>. This tells <command
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
690 role="hg-cmd">hg backout</command> to back out revision
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
691 4 again, but this time to choose parent 3, the other
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
692 parent of the merge. The result is visible in <xref
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
693 linkend="fig:undo:bad-merge-3"/>, in which the repository
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
694 now contains three heads.</para>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
695 <figure id="fig:undo:bad-merge-3">
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
696 <title>Backing out the merge, favoring the other
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
697 parent</title>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
698 <mediaobject>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
699 <imageobject><imagedata fileref="figs/bad-merge-3.png"/></imageobject>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
700 <textobject><phrase>XXX add text</phrase></textobject>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
701 </mediaobject>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
702 </figure>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
703 </listitem>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
704
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
705 <listitem>
808
557552d4699f Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 807
diff changeset
706 <para id="x_6c0">Redo the bad merge by merging the two backout heads,
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
707 which reduces the number of heads in the repository to
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
708 two, as can be seen in <xref
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
709 linkend="fig:undo:bad-merge-4"/>.</para>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
710 <figure id="fig:undo:bad-merge-4">
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
711 <title>Merging the backouts</title>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
712 <mediaobject>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
713 <imageobject><imagedata fileref="figs/bad-merge-4.png"/></imageobject>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
714 <textobject><phrase>XXX add text</phrase></textobject>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
715 </mediaobject>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
716 </figure>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
717 </listitem>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
718
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
719 <listitem>
808
557552d4699f Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 807
diff changeset
720 <para id="x_6c1">Merge with the commit that was made after the bad
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
721 merge, as shown in <xref
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
722 linkend="fig:undo:bad-merge-5"/>.</para>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
723 <figure id="fig:undo:bad-merge-5">
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
724 <title>Merging the backouts</title>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
725 <mediaobject>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
726 <imageobject><imagedata fileref="figs/bad-merge-5.png"/></imageobject>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
727 <textobject><phrase>XXX add text</phrase></textobject>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
728 </mediaobject>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
729 </figure>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
730 </listitem>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
731 </orderedlist>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
732 </sect2>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
733
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
734 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
735 <title>Protect yourself from <quote>escaped</quote>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
736 changes</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
737
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
738 <para id="x_123">If you've committed some changes to your local repository
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
739 and they've been pushed or pulled somewhere else, this isn't
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
740 necessarily a disaster. You can protect yourself ahead of
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
741 time against some classes of bad changeset. This is
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
742 particularly easy if your team usually pulls changes from a
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
743 central repository.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
744
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
745 <para id="x_124">By configuring some hooks on that repository to validate
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
746 incoming changesets (see chapter <xref linkend="chap:hook"/>),
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
747 you can
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
748 automatically prevent some kinds of bad changeset from being
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
749 pushed to the central repository at all. With such a
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
750 configuration in place, some kinds of bad changeset will
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
751 naturally tend to <quote>die out</quote> because they can't
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
752 propagate into the central repository. Better yet, this
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
753 happens without any need for explicit intervention.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
754
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
755 <para id="x_125">For instance, an incoming change hook that
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
756 verifies that a changeset will actually compile can prevent
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
757 people from inadvertently <quote>breaking the
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
758 build</quote>.</para>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
759 </sect2>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
760
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
761 <sect2>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
762 <title>What to do about sensitive changes that escape</title>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
763
808
557552d4699f Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 807
diff changeset
764 <para id="x_6c2">Even a carefully run project can suffer an unfortunate
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
765 event such as the committing and uncontrolled propagation of a
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
766 file that contains important passwords.</para>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
767
808
557552d4699f Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 807
diff changeset
768 <para id="x_6c3">If something like this happens to you, and the information
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
769 that gets accidentally propagated is truly sensitive, your
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
770 first step should be to mitigate the effect of the leak
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
771 without trying to control the leak itself. If you are not 100%
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
772 certain that you know exactly who could have seen the changes,
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
773 you should immediately change passwords, cancel credit cards,
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
774 or find some other way to make sure that the information that
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
775 has leaked is no longer useful. In other words, assume that
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
776 the change has propagated far and wide, and that there's
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
777 nothing more you can do.</para>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
778
808
557552d4699f Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 807
diff changeset
779 <para id="x_6c4">You might hope that there would be mechanisms you could
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
780 use to either figure out who has seen a change or to erase the
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
781 change permanently everywhere, but there are good reasons why
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
782 these are not possible.</para>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
783
808
557552d4699f Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 807
diff changeset
784 <para id="x_6c5">Mercurial does not provide an audit trail of who has
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
785 pulled changes from a repository, because it is usually either
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
786 impossible to record such information or trivial to spoof it.
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
787 In a multi-user or networked environment, you should thus be
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
788 extremely skeptical of yourself if you think that you have
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
789 identified every place that a sensitive changeset has
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
790 propagated to. Don't forget that people can and will send
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
791 bundles by email, have their backup software save data
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
792 offsite, carry repositories on USB sticks, and find other
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
793 completely innocent ways to confound your attempts to track
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
794 down every copy of a problematic change.</para>
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
795
808
557552d4699f Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 807
diff changeset
796 <para id="x_6c6">Mercurial also does not provide a way to make a file or
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
797 changeset completely disappear from history, because there is
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
798 no way to enforce its disappearance; someone could easily
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
799 modify their copy of Mercurial to ignore such directives. In
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
800 addition, even if Mercurial provided such a capability,
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
801 someone who simply hadn't pulled a <quote>make this file
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
802 disappear</quote> changeset wouldn't be affected by it, nor
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
803 would web crawlers visiting at the wrong time, disk backups,
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
804 or other mechanisms. Indeed, no distributed revision control
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
805 system can make data reliably vanish. Providing the illusion
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
806 of such control could easily give a false sense of security,
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
807 and be worse than not providing it at all.</para>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
808 </sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
809 </sect1>
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
810
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
811 <sect1 id="sec:undo:bisect">
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
812 <title>Finding the source of a bug</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
813
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
814 <para id="x_126">While it's all very well to be able to back out a changeset
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
815 that introduced a bug, this requires that you know which
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
816 changeset to back out. Mercurial provides an invaluable
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
817 command, called <command role="hg-cmd">hg bisect</command>, that
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
818 helps you to automate this process and accomplish it very
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
819 efficiently.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
820
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
821 <para id="x_127">The idea behind the <command role="hg-cmd">hg
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
822 bisect</command> command is that a changeset has introduced
771
b338f5490029 Americanize spellings :-(
Bryan O'Sullivan <bos@serpentine.com>
parents: 753
diff changeset
823 some change of behavior that you can identify with a simple
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
824 binary test. You don't know which piece of code introduced the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
825 change, but you know how to test for the presence of the bug.
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
826 The <command role="hg-cmd">hg bisect</command> command uses your
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
827 test to direct its search for the changeset that introduced the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
828 code that caused the bug.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
829
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
830 <para id="x_128">Here are a few scenarios to help you understand how you
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
831 might apply this command.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
832 <itemizedlist>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
833 <listitem><para id="x_129">The most recent version of your software has a
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
834 bug that you remember wasn't present a few weeks ago, but
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
835 you don't know when it was introduced. Here, your binary
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
836 test checks for the presence of that bug.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
837 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
838 <listitem><para id="x_12a">You fixed a bug in a rush, and now it's time to
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
839 close the entry in your team's bug database. The bug
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
840 database requires a changeset ID when you close an entry,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
841 but you don't remember which changeset you fixed the bug in.
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
842 Once again, your binary test checks for the presence of the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
843 bug.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
844 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
845 <listitem><para id="x_12b">Your software works correctly, but runs 15%
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
846 slower than the last time you measured it. You want to know
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
847 which changeset introduced the performance regression. In
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
848 this case, your binary test measures the performance of your
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
849 software, to see whether it's <quote>fast</quote> or
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
850 <quote>slow</quote>.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
851 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
852 <listitem><para id="x_12c">The sizes of the components of your project that
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
853 you ship exploded recently, and you suspect that something
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
854 changed in the way you build your project.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
855 </listitem></itemizedlist>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
856
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
857 <para id="x_12d">From these examples, it should be clear that the <command
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
858 role="hg-cmd">hg bisect</command> command is not useful only
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
859 for finding the sources of bugs. You can use it to find any
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
860 <quote>emergent property</quote> of a repository (anything that
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
861 you can't find from a simple text search of the files in the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
862 tree) for which you can write a binary test.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
863
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
864 <para id="x_12e">We'll introduce a little bit of terminology here, just to
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
865 make it clear which parts of the search process are your
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
866 responsibility, and which are Mercurial's. A
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
867 <emphasis>test</emphasis> is something that
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
868 <emphasis>you</emphasis> run when <command role="hg-cmd">hg
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
869 bisect</command> chooses a changeset. A
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
870 <emphasis>probe</emphasis> is what <command role="hg-cmd">hg
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
871 bisect</command> runs to tell whether a revision is good.
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
872 Finally, we'll use the word <quote>bisect</quote>, as both a
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
873 noun and a verb, to stand in for the phrase <quote>search using
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
874 the <command role="hg-cmd">hg bisect</command>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
875 command</quote>.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
876
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
877 <para id="x_12f">One simple way to automate the searching process would be
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
878 simply to probe every changeset. However, this scales poorly.
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
879 If it took ten minutes to test a single changeset, and you had
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
880 10,000 changesets in your repository, the exhaustive approach
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
881 would take on average 35 <emphasis>days</emphasis> to find the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
882 changeset that introduced a bug. Even if you knew that the bug
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
883 was introduced by one of the last 500 changesets, and limited
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
884 your search to those, you'd still be looking at over 40 hours to
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
885 find the changeset that introduced your bug.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
886
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
887 <para id="x_130">What the <command role="hg-cmd">hg bisect</command> command
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
888 does is use its knowledge of the <quote>shape</quote> of your
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
889 project's revision history to perform a search in time
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
890 proportional to the <emphasis>logarithm</emphasis> of the number
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
891 of changesets to check (the kind of search it performs is called
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
892 a dichotomic search). With this approach, searching through
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
893 10,000 changesets will take less than three hours, even at ten
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
894 minutes per test (the search will require about 14 tests).
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
895 Limit your search to the last hundred changesets, and it will
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
896 take only about an hour (roughly seven tests).</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
897
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
898 <para id="x_131">The <command role="hg-cmd">hg bisect</command> command is
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
899 aware of the <quote>branchy</quote> nature of a Mercurial
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
900 project's revision history, so it has no problems dealing with
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
901 branches, merges, or multiple heads in a repository. It can
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
902 prune entire branches of history with a single probe, which is
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
903 how it operates so efficiently.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
904
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
905 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
906 <title>Using the <command role="hg-cmd">hg bisect</command>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
907 command</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
908
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
909 <para id="x_132">Here's an example of <command role="hg-cmd">hg
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
910 bisect</command> in action.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
911
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
912 <note>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
913 <para id="x_133"> In versions 0.9.5 and earlier of Mercurial, <command
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
914 role="hg-cmd">hg bisect</command> was not a core command:
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
915 it was distributed with Mercurial as an extension. This
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
916 section describes the built-in command, not the old
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
917 extension.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
918 </note>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
919
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
920 <para id="x_134">Now let's create a repository, so that we can try out the
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
921 <command role="hg-cmd">hg bisect</command> command in
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
922 isolation.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
923
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
924 &interaction.bisect.init;
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
925
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
926 <para id="x_135">We'll simulate a project that has a bug in it in a
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
927 simple-minded way: create trivial changes in a loop, and
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
928 nominate one specific change that will have the
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
929 <quote>bug</quote>. This loop creates 35 changesets, each
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
930 adding a single file to the repository. We'll represent our
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
931 <quote>bug</quote> with a file that contains the text <quote>i
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
932 have a gub</quote>.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
933
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
934 &interaction.bisect.commits;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
935
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
936 <para id="x_136">The next thing that we'd like to do is figure out how to
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
937 use the <command role="hg-cmd">hg bisect</command> command.
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
938 We can use Mercurial's normal built-in help mechanism for
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
939 this.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
940
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
941 &interaction.bisect.help;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
942
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
943 <para id="x_137">The <command role="hg-cmd">hg bisect</command> command
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
944 works in steps. Each step proceeds as follows.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
945 <orderedlist>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
946 <listitem><para id="x_138">You run your binary test.</para>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
947 <itemizedlist>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
948 <listitem><para id="x_139">If the test succeeded, you tell <command
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
949 role="hg-cmd">hg bisect</command> by running the
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
950 <command role="hg-cmd">hg bisect --good</command>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
951 command.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
952 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
953 <listitem><para id="x_13a">If it failed, run the <command
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
954 role="hg-cmd">hg bisect --bad</command>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
955 command.</para></listitem></itemizedlist>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
956 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
957 <listitem><para id="x_13b">The command uses your information to decide
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
958 which changeset to test next.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
959 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
960 <listitem><para id="x_13c">It updates the working directory to that
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
961 changeset, and the process begins again.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
962 </listitem></orderedlist>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
963 <para id="x_13d">The process ends when <command role="hg-cmd">hg
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
964 bisect</command> identifies a unique changeset that marks
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
965 the point where your test transitioned from
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
966 <quote>succeeding</quote> to <quote>failing</quote>.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
967
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
968 <para id="x_13e">To start the search, we must run the <command
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
969 role="hg-cmd">hg bisect --reset</command> command.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
970
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
971 &interaction.bisect.search.init;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
972
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
973 <para id="x_13f">In our case, the binary test we use is simple: we check to
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
974 see if any file in the repository contains the string <quote>i
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
975 have a gub</quote>. If it does, this changeset contains the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
976 change that <quote>caused the bug</quote>. By convention, a
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
977 changeset that has the property we're searching for is
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
978 <quote>bad</quote>, while one that doesn't is
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
979 <quote>good</quote>.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
980
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
981 <para id="x_140">Most of the time, the revision to which the working
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
982 directory is synced (usually the tip) already exhibits the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
983 problem introduced by the buggy change, so we'll mark it as
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
984 <quote>bad</quote>.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
985
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
986 &interaction.bisect.search.bad-init;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
987
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
988 <para id="x_141">Our next task is to nominate a changeset that we know
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
989 <emphasis>doesn't</emphasis> have the bug; the <command
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
990 role="hg-cmd">hg bisect</command> command will
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
991 <quote>bracket</quote> its search between the first pair of
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
992 good and bad changesets. In our case, we know that revision
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
993 10 didn't have the bug. (I'll have more words about choosing
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
994 the first <quote>good</quote> changeset later.)</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
995
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
996 &interaction.bisect.search.good-init;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
997
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
998 <para id="x_142">Notice that this command printed some output.</para>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
999 <itemizedlist>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
1000 <listitem><para id="x_143">It told us how many changesets it must
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1001 consider before it can identify the one that introduced
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1002 the bug, and how many tests that will require.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1003 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
1004 <listitem><para id="x_144">It updated the working directory to the next
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1005 changeset to test, and told us which changeset it's
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1006 testing.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1007 </listitem></itemizedlist>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1008
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
1009 <para id="x_145">We now run our test in the working directory. We use the
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1010 <command>grep</command> command to see if our
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1011 <quote>bad</quote> file is present in the working directory.
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1012 If it is, this revision is bad; if not, this revision is good.
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
1013 &interaction.bisect.search.step1;</para>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1014
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
1015 <para id="x_146">This test looks like a perfect candidate for automation,
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
1016 so let's turn it into a shell function.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
1017 &interaction.bisect.search.mytest;
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
1018
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
1019 <para id="x_147">We can now run an entire test step with a single command,
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
1020 <literal>mytest</literal>.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
1021
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
1022 &interaction.bisect.search.step2;
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
1023
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
1024 <para id="x_148">A few more invocations of our canned test step command,
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
1025 and we're done.</para>
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
1026
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
1027 &interaction.bisect.search.rest;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1028
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
1029 <para id="x_149">Even though we had 40 changesets to search through, the
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1030 <command role="hg-cmd">hg bisect</command> command let us find
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1031 the changeset that introduced our <quote>bug</quote> with only
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1032 five tests. Because the number of tests that the <command
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1033 role="hg-cmd">hg bisect</command> command performs grows
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1034 logarithmically with the number of changesets to search, the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1035 advantage that it has over the <quote>brute force</quote>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1036 search approach increases with every changeset you add.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1037
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1038 </sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1039 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1040 <title>Cleaning up after your search</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1041
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
1042 <para id="x_14a">When you're finished using the <command role="hg-cmd">hg
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1043 bisect</command> command in a repository, you can use the
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
1044 <command role="hg-cmd">hg bisect --reset</command> command to
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1045 drop the information it was using to drive your search. The
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1046 command doesn't use much space, so it doesn't matter if you
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1047 forget to run this command. However, <command
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1048 role="hg-cmd">hg bisect</command> won't let you start a new
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1049 search in that repository until you do a <command
807
7226e5e750a6 Clean up chapter 8, and add content
Bryan O'Sullivan <bos@serpentine.com>
parents: 771
diff changeset
1050 role="hg-cmd">hg bisect --reset</command>.</para>
666
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
1051
8fcd44708f41 Uncomment all the mangled interaction examples.
Bryan O'Sullivan <bos@serpentine.com>
parents: 658
diff changeset
1052 &interaction.bisect.search.reset;
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1053
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1054 </sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1055 </sect1>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1056 <sect1>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1057 <title>Tips for finding bugs effectively</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1058
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1059 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1060 <title>Give consistent input</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1061
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
1062 <para id="x_14b">The <command role="hg-cmd">hg bisect</command> command
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1063 requires that you correctly report the result of every test
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1064 you perform. If you tell it that a test failed when it really
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1065 succeeded, it <emphasis>might</emphasis> be able to detect the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1066 inconsistency. If it can identify an inconsistency in your
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1067 reports, it will tell you that a particular changeset is both
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1068 good and bad. However, it can't do this perfectly; it's about
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1069 as likely to report the wrong changeset as the source of the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1070 bug.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1071
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1072 </sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1073 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1074 <title>Automate as much as possible</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1075
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
1076 <para id="x_14c">When I started using the <command role="hg-cmd">hg
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1077 bisect</command> command, I tried a few times to run my
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1078 tests by hand, on the command line. This is an approach that
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1079 I, at least, am not suited to. After a few tries, I found
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1080 that I was making enough mistakes that I was having to restart
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1081 my searches several times before finally getting correct
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1082 results.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1083
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
1084 <para id="x_14d">My initial problems with driving the <command
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1085 role="hg-cmd">hg bisect</command> command by hand occurred
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1086 even with simple searches on small repositories; if the
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1087 problem you're looking for is more subtle, or the number of
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1088 tests that <command role="hg-cmd">hg bisect</command> must
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1089 perform increases, the likelihood of operator error ruining
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1090 the search is much higher. Once I started automating my
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1091 tests, I had much better results.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1092
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
1093 <para id="x_14e">The key to automated testing is twofold:</para>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1094 <itemizedlist>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
1095 <listitem><para id="x_14f">always test for the same symptom, and</para>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1096 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
1097 <listitem><para id="x_150">always feed consistent input to the <command
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1098 role="hg-cmd">hg bisect</command> command.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1099 </listitem></itemizedlist>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
1100 <para id="x_151">In my tutorial example above, the <command>grep</command>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1101 command tests for the symptom, and the <literal>if</literal>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1102 statement takes the result of this check and ensures that we
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1103 always feed the same input to the <command role="hg-cmd">hg
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1104 bisect</command> command. The <literal>mytest</literal>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1105 function marries these together in a reproducible way, so that
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1106 every test is uniform and consistent.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1107
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1108 </sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1109 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1110 <title>Check your results</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1111
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
1112 <para id="x_152">Because the output of a <command role="hg-cmd">hg
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1113 bisect</command> search is only as good as the input you
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1114 give it, don't take the changeset it reports as the absolute
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1115 truth. A simple way to cross-check its report is to manually
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1116 run your test at each of the following changesets:</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1117 <itemizedlist>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
1118 <listitem><para id="x_153">The changeset that it reports as the first bad
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1119 revision. Your test should still report this as
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1120 bad.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1121 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
1122 <listitem><para id="x_154">The parent of that changeset (either parent,
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1123 if it's a merge). Your test should report this changeset
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1124 as good.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1125 </listitem>
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
1126 <listitem><para id="x_155">A child of that changeset. Your test should
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1127 report this changeset as bad.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1128 </listitem></itemizedlist>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1129
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1130 </sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1131 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1132 <title>Beware interference between bugs</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1133
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
1134 <para id="x_156">It's possible that your search for one bug could be
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1135 disrupted by the presence of another. For example, let's say
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1136 your software crashes at revision 100, and worked correctly at
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1137 revision 50. Unknown to you, someone else introduced a
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1138 different crashing bug at revision 60, and fixed it at
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1139 revision 80. This could distort your results in one of
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1140 several ways.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1141
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
1142 <para id="x_157">It is possible that this other bug completely
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1143 <quote>masks</quote> yours, which is to say that it occurs
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1144 before your bug has a chance to manifest itself. If you can't
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1145 avoid that other bug (for example, it prevents your project
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1146 from building), and so can't tell whether your bug is present
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1147 in a particular changeset, the <command role="hg-cmd">hg
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1148 bisect</command> command cannot help you directly. Instead,
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1149 you can mark a changeset as untested by running <command
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1150 role="hg-cmd">hg bisect --skip</command>.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1151
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
1152 <para id="x_158">A different problem could arise if your test for a bug's
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1153 presence is not specific enough. If you check for <quote>my
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1154 program crashes</quote>, then both your crashing bug and an
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1155 unrelated crashing bug that masks it will look like the same
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1156 thing, and mislead <command role="hg-cmd">hg
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1157 bisect</command>.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1158
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
1159 <para id="x_159">Another useful situation in which to use <command
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1160 role="hg-cmd">hg bisect --skip</command> is if you can't
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1161 test a revision because your project was in a broken and hence
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1162 untestable state at that revision, perhaps because someone
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1163 checked in a change that prevented the project from
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1164 building.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1165
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1166 </sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1167 <sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1168 <title>Bracket your search lazily</title>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1169
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
1170 <para id="x_15a">Choosing the first <quote>good</quote> and
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1171 <quote>bad</quote> changesets that will mark the end points of
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1172 your search is often easy, but it bears a little discussion
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1173 nevertheless. From the perspective of <command
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1174 role="hg-cmd">hg bisect</command>, the <quote>newest</quote>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1175 changeset is conventionally <quote>bad</quote>, and the older
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1176 changeset is <quote>good</quote>.</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1177
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
1178 <para id="x_15b">If you're having trouble remembering when a suitable
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1179 <quote>good</quote> change was, so that you can tell <command
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1180 role="hg-cmd">hg bisect</command>, you could do worse than
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1181 testing changesets at random. Just remember to eliminate
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1182 contenders that can't possibly exhibit the bug (perhaps
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1183 because the feature with the bug isn't present yet) and those
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1184 where another problem masks the bug (as I discussed
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1185 above).</para>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1186
683
c838b3975bc6 Add IDs to paragraphs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 682
diff changeset
1187 <para id="x_15c">Even if you end up <quote>early</quote> by thousands of
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1188 changesets or months of history, you will only add a handful
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1189 of tests to the total number that <command role="hg-cmd">hg
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1190 bisect</command> must perform, thanks to its logarithmic
771
b338f5490029 Americanize spellings :-(
Bryan O'Sullivan <bos@serpentine.com>
parents: 753
diff changeset
1191 behavior.</para>
658
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1192
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1193 </sect2>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1194 </sect1>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1195 </chapter>
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1196
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1197 <!--
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1198 local variables:
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1199 sgml-parent-document: ("00book.xml" "book" "chapter")
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1200 end:
b90b024729f1 WIP DocBook snapshot that all compiles. Mirabile dictu!
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1201 -->