hgbook
changeset 94:0b97b0bdc830
Basic merge coverage.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Fri Oct 13 13:55:06 2006 -0700 (2006-10-13) |
parents | 97638d862ef3 |
children | 47ea206351d5 |
files | en/examples/tour en/tour.tex |
line diff
1.1 --- a/en/examples/tour Thu Oct 12 16:27:00 2006 -0700 1.2 +++ b/en/examples/tour Fri Oct 13 13:55:06 2006 -0700 1.3 @@ -105,6 +105,7 @@ 1.4 1.5 hg update 2 1.6 hg parents 1.7 +hg update 1.8 1.9 #$ name: clone-push 1.10 1.11 @@ -132,5 +133,44 @@ 1.12 1.13 hg push http://hg.serpentine.com/tutorial/hello 1.14 1.15 -#$ name: 1.16 -exit 0 1.17 +#$ name: merge.clone 1.18 + 1.19 +cd .. 1.20 +hg clone hello my-new-hello 1.21 +cd my-new-hello 1.22 +sed -i '/printf/i\\tprintf("once more, hello.\\n");' hello.c 1.23 +hg commit -m 'A new hello for a new day.' 1.24 + 1.25 +#$ name: merge.cat 1.26 + 1.27 +cat hello.c 1.28 +cat ../my-hello/hello.c 1.29 + 1.30 +#$ name: merge.pull 1.31 + 1.32 +hg pull ../my-hello 1.33 + 1.34 +#$ name: merge.heads 1.35 + 1.36 +hg heads 1.37 + 1.38 +#$ name: merge.update 1.39 + 1.40 +hg update 1.41 + 1.42 +#$ name: merge.merge 1.43 + 1.44 +hg merge 1.45 + 1.46 +#$ name: merge.parents 1.47 + 1.48 +hg parents 1.49 +cat hello.c 1.50 + 1.51 +#$ name: merge.commit 1.52 + 1.53 +hg commit -m 'Merged changes' 1.54 + 1.55 +#$ name: merge.tip 1.56 + 1.57 +hg tip
2.1 --- a/en/tour.tex Thu Oct 12 16:27:00 2006 -0700 2.2 +++ b/en/tour.tex Fri Oct 13 13:55:06 2006 -0700 2.3 @@ -477,7 +477,8 @@ 2.4 revision number or changeset~ID to the \hgcmd{update} command. 2.5 \interaction{tour.older} 2.6 If you omit an explicit revision, \hgcmd{update} will update to the 2.7 -tip revision. 2.8 +tip revision, as shown by the second call to \hgcmd{update} in the 2.9 +example above. 2.10 2.11 \subsection{Pushing changes to another repository} 2.12 2.13 @@ -512,6 +513,63 @@ 2.14 anonymous users push to it. 2.15 \interaction{tour.push.net} 2.16 2.17 +\section{Merging streams of work} 2.18 + 2.19 +We've now covered cloning a repository, making changes in a 2.20 +repository, and pulling or pushing changes from one repository into 2.21 +another. Our next step is \emph{merging} changes from separate 2.22 +repositories. 2.23 + 2.24 +Merging is a fundamental part of working with a distributed revision 2.25 +control tool. 2.26 +\begin{itemize} 2.27 +\item Alice and Bob each have a personal copy of a repository for a 2.28 + project they're collaborating on. Alice fixes a bug in her 2.29 + repository; Bob adds a new feature in his. They want the shared 2.30 + repository to contain both the bug fix and the new feature. 2.31 +\item I frequently work on several different tasks for a single 2.32 + project at once, each safely isolated in its own repository. 2.33 + Working this way means that I often need to merge one piece of my 2.34 + own work with another. 2.35 +\end{itemize} 2.36 + 2.37 +Because merging is such a common thing to need to do, Mercurial makes 2.38 +it easy. Let's walk through the process. We'll begin by cloning yet 2.39 +another repository (see how often they spring up?) and making a change 2.40 +in it. 2.41 +\interaction{tour.merge.clone} 2.42 +We should now have two copies of \filename{hello.c} with different 2.43 +contents. 2.44 +\interaction{tour.merge.cat} 2.45 + 2.46 +We already know that pulling changes from our \dirname{my-hello} 2.47 +repository will have no effect on the working directory. 2.48 +\interaction{tour.merge.pull} 2.49 +However, the \hgcmd{pull} command says something about ``heads''. 2.50 + 2.51 +A head is a change that has no descendants. The tip revision is thus 2.52 +a head, but a repository can contain more than one head. We can view 2.53 +them using the \hgcmd{heads} command. 2.54 +\interaction{tour.merge.heads} 2.55 +What happens if we try to use the normal \hgcmd{update} command to 2.56 +update to the new tip? 2.57 +\interaction{tour.merge.update} 2.58 +Mercurial is telling us that the \hgcmd{update} command won't do a 2.59 +merge. Instead, we use the \hgcmd{merge} command to merge the two 2.60 +heads. 2.61 +\interaction{tour.merge.merge} 2.62 +This updates the working directory so that it contains changes from 2.63 +both heads, which is reflected in both the output of \hgcmd{parents} 2.64 +and the contents of \filename{hello.c}. 2.65 +\interaction{tour.merge.parents} 2.66 +Whenever we've done a merge, \hgcmd{parents} will display two parents 2.67 +until we \hgcmd{commit} the results of the merge. 2.68 +\interaction{tour.merge.commit} 2.69 +We now have a new tip revision; notice that it has \emph{both} of 2.70 +our former heads as its parents. These are the same revisions that 2.71 +were previously displayed by \hgcmd{parents}. 2.72 +\interaction{tour.merge.tip} 2.73 + 2.74 %%% Local Variables: 2.75 %%% mode: latex 2.76 %%% TeX-master: "00book"