Mercurial > hgbook
annotate en/branch.tex @ 197:76697ae503db
Local branches.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Mon, 16 Apr 2007 16:33:51 -0700 |
parents | 4237e45506ee |
children | 615f3c6b30e1 |
rev | line source |
---|---|
196
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
1 \chapter{Managing releases and branchy development} |
187
b60e2de6dbc3
Add chapter on branch management.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
2 \label{chap:branch} |
b60e2de6dbc3
Add chapter on branch management.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
3 |
197 | 4 Mercurial provides several mechanisms for you to manage a project that |
5 is making progress on multiple fronts at once. To understand these | |
6 mechanisms, let's first take a brief look at a fairly normal software | |
7 project structure. | |
187
b60e2de6dbc3
Add chapter on branch management.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
8 |
196
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
9 Many software projects issue periodic ``major'' releases that contain |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
10 substantial new features. In parallel, they may issue ``minor'' |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
11 releases. These are usually identical to the major releases off which |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
12 they're based, but with a few bugs fixed. |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
13 |
197 | 14 In this chapter, we'll start by talking about how to keep records of |
15 project milestones such as releases. We'll then continue on to talk | |
16 about the flow of work between different phases of a project, and how | |
17 Mercurial can help you to isolate and manage this work. | |
18 | |
196
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
19 \section{Giving a persistent name to a revision} |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
20 |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
21 Once you decide that you'd like to call a particular revision a |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
22 ``release'', it's a good idea to record the identity of that revision. |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
23 This will let you reproduce that release at a later date, for whatever |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
24 purpose you might need at the time (reproducing a bug, porting to a |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
25 new platform, etc). |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
26 \interaction{tag.init} |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
27 |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
28 Mercurial lets you give a permanent name to any revision using the |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
29 \hgcmd{tag} command. Not surprisingly, these names are called |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
30 ``tags''. |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
31 \interaction{tag.tag} |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
32 |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
33 A tag is nothing more than a ``symbolic name'' for a revision. Tags |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
34 exist purely for your convenience, so that you have a handy permanent |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
35 way to refer to a revision; Mercurial doesn't interpret the tag names |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
36 you use in any way. Neither does Mercurial place any restrictions on |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
37 the name of a tag, beyond a few that are necessary to ensure that a |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
38 tag can be parsed unambiguously. A tag name cannot contain any of the |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
39 following characters: |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
40 \begin{itemize} |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
41 \item Colon (ASCII 58, ``\texttt{:}'') |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
42 \item Carriage return (ASCII 13, ``\texttt{$\backslash$r}'') |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
43 \item Newline (ASCII 10, ``\texttt{$\backslash$n}'') |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
44 \end{itemize} |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
45 |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
46 You can use the \hgcmd{tags} command to display the tags present in |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
47 your repository. In the output, each tagged revision is identified |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
48 first by its name, then by revision number, and finally by the unique |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
49 hash of the revision. |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
50 \interaction{tag.tags} |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
51 Notice that \texttt{tip} is listed in the output of \hgcmd{tags}. The |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
52 \texttt{tip} tag is a special ``floating'' tag, which always |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
53 identifies the newest revision in the repository. |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
54 |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
55 In the output of the \hgcmd{tags} command, tags are listed in reverse |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
56 order, by revision number. This usually means that recent tags are |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
57 listed before older tags. It also means that \texttt{tip} is always |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
58 going to be the first tag listed in the output of \hgcmd{tags}. |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
59 |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
60 When you run \hgcmd{log}, if it displays a revision that has tags |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
61 associated with it, it will print those tags. |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
62 \interaction{tag.log} |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
63 |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
64 Any time you need to provide a revision~ID to a Mercurial command, the |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
65 command will accept a tag name in its place. Internally, Mercurial |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
66 will translate your tag name into the corresponding revision~ID, then |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
67 use that. |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
68 \interaction{tag.log.v1.0} |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
69 |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
70 There's no limit on the number of tags you can have in a repository, |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
71 or on the number of tags that a single revision can have. As a |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
72 practical matter, it's not a great idea to have ``too many'' (a number |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
73 which will vary from project to project), simply because tags are |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
74 supposed to help you to find revisions. If you have lots of tags, the |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
75 ease of using them to identify revisions diminishes rapidly. |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
76 |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
77 For example, if your project has milestones as frequent as every few |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
78 days, it's perfectly reasonable to tag each one of those. But if you |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
79 have a continuous build system that makes sure every revision can be |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
80 built cleanly, you'd be introducing a lot of noise if you were to tag |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
81 every clean build. Instead, you could tag failed builds (on the |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
82 assumption that they're rare!), or simply not use tags to track |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
83 buildability. |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
84 |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
85 If you want to remove a tag that you no longer want, use |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
86 \hgcmdargs{tag}{--remove}. |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
87 \interaction{tag.remove} |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
88 You can also modify a tag at any time, so that it identifies a |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
89 different revision, by simply issuing a new \hgcmd{tag} command. |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
90 You'll have to use the \hgopt{tag}{-f} option to tell Mercurial that |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
91 you \emph{really} want to update the tag. |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
92 \interaction{tag.replace} |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
93 There will still be a permanent record of the previous identity of the |
197 | 94 tag, but Mercurial will no longer use it. There's thus no penalty to |
95 tagging the wrong revision; all you have to do is turn around and tag | |
96 the correct revision once you discover your error. | |
196
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
97 |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
98 Mercurial stores tags in a normal revision-controlled file in your |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
99 repository. If you've created any tags, you'll find them in a file |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
100 named \sfilename{.hgtags}. When you run the \hgcmd{tag} command, |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
101 Mercurial modifies this file, then automatically commits the change to |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
102 it. This means that every time you run \hgcmd{tag}, you'll see a |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
103 corresponding changeset in the output of \hgcmd{log}. |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
104 \interaction{tag.tip} |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
105 |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
106 \subsection{Handling tag conflicts during a merge} |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
107 |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
108 You won't often need to care about the \sfilename{.hgtags} file, but |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
109 it sometimes makes its presence known during a merge. The format of |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
110 the file is simple: it consists of a series of lines. Each line |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
111 starts with a changeset hash, followed by a space, followed by the |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
112 name of a tag. |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
113 |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
114 If you're resolving a conflict in the \sfilename{.hgtags} file during |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
115 a merge, there's one twist to modifying the \sfilename{.hgtags} file: |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
116 when Mercurial is parsing the tags in a repository, it \emph{never} |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
117 reads the working copy of the \sfilename{.hgtags} file. Instead, it |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
118 reads the \emph{most recently committed} revision of the file. |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
119 |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
120 An unfortunate consequence of this design is that you can't actually |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
121 verify that your merged \sfilename{.hgtags} file is correct until |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
122 \emph{after} you've committed a change. So if you find yourself |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
123 resolving a conflict on \sfilename{.hgtags} during a merge, be sure to |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
124 run \hgcmd{tags} after you commit. If it finds an error in the |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
125 \sfilename{.hgtags} file, it will report the location of the error, |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
126 which you can then fix and commit. You should then run \hgcmd{tags} |
4237e45506ee
Add early material describing tags.
Bryan O'Sullivan <bos@serpentine.com>
parents:
187
diff
changeset
|
127 again, just to be sure that your fix is correct. |
187
b60e2de6dbc3
Add chapter on branch management.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
128 |
197 | 129 \subsection{When permanent tags are too much} |
130 | |
131 Since Mercurial's tags are revision controlled and carried around with | |
132 a project's history, everyone you work with will see the tags you | |
133 create. But giving names to revisions has uses beyond simply noting | |
134 that revision \texttt{4237e45506ee} is really \texttt{v2.0.2}. If | |
135 you're trying to track down a subtle bug, you might want a tag to | |
136 remind you of something like ``Anne saw the symptoms with this | |
137 revision''. | |
138 | |
139 For cases like this, what you might want to use are \emph{local} tags. | |
140 You can create a local tag with the \hgopt{tag}{-l} option to the | |
141 \hgcmd{tag} command. This will store the tag in a file called | |
142 \sfilename{.hg/localtags}. Unlike \sfilename{.hgtags}, | |
143 \sfilename{.hg/localtags} is not revision controlled. Any tags you | |
144 create using \hgopt{tag}{-l} remain strictly local to the repository | |
145 you're currently working in. | |
146 | |
147 | |
187
b60e2de6dbc3
Add chapter on branch management.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
148 %%% Local Variables: |
b60e2de6dbc3
Add chapter on branch management.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
149 %%% mode: latex |
b60e2de6dbc3
Add chapter on branch management.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
150 %%% TeX-master: "00book" |
b60e2de6dbc3
Add chapter on branch management.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff
changeset
|
151 %%% End: |