hgbook

diff en/tour-merge.tex @ 102:ff9dc8bc2a8b

More. Merge. Stuff.
author Bryan O'Sullivan <bos@serpentine.com>
date Wed Oct 18 15:47:04 2006 -0700 (2006-10-18)
parents 321732566ac1
children 5b80c922ebdd
line diff
     1.1 --- a/en/tour-merge.tex	Wed Oct 18 14:11:51 2006 -0700
     1.2 +++ b/en/tour-merge.tex	Wed Oct 18 15:47:04 2006 -0700
     1.3 @@ -44,6 +44,8 @@
     1.4  \interaction{tour.merge.pull}
     1.5  However, the \hgcmd{pull} command says something about ``heads''.  
     1.6  
     1.7 +\subsection{Head changesets}
     1.8 +
     1.9  A head is a change that has no descendants, or children, as they're
    1.10  also known.  The tip revision is thus a head, because the newest
    1.11  revision in a repository doesn't have any children, but a repository
    1.12 @@ -68,6 +70,9 @@
    1.13  changesets.)  We can view the heads in a repository using the
    1.14  \hgcmd{heads} command.
    1.15  \interaction{tour.merge.heads}
    1.16 +
    1.17 +\subsection{Performing the merge}
    1.18 +
    1.19  What happens if we try to use the normal \hgcmd{update} command to
    1.20  update to the new tip?
    1.21  \interaction{tour.merge.update}
    1.22 @@ -89,6 +94,9 @@
    1.23  \emph{both} heads, which is reflected in both the output of
    1.24  \hgcmd{parents} and the contents of \filename{hello.c}.
    1.25  \interaction{tour.merge.parents}
    1.26 +
    1.27 +\subsection{Committing the results of the merge}
    1.28 +
    1.29  Whenever we've done a merge, \hgcmd{parents} will display two parents
    1.30  until we \hgcmd{commit} the results of the merge.
    1.31  \interaction{tour.merge.commit}
    1.32 @@ -102,6 +110,59 @@
    1.33  working directory has two parent changesets, and these become the
    1.34  parents of the new changeset.
    1.35  
    1.36 +\section{Merging conflicting changes}
    1.37 +
    1.38 +Most merges are simple affairs, but sometimes you'll find yourself
    1.39 +merging a change that you made with another, where both modify the
    1.40 +same portions of the same files.  Unless both modifications are
    1.41 +identical, this results in a \emph{conflict}, where you have to decide
    1.42 +how to reconcile the different changes into something coherent.
    1.43 +
    1.44 +\section{Using an extension to simplify merging}
    1.45 +
    1.46 +The process of merging changes as outlined above is straightforward,
    1.47 +but requires running three commands in sequence.
    1.48 +\begin{codesample2}
    1.49 +  hg pull
    1.50 +  hg merge
    1.51 +  hg commit -m 'Merged remote changes'
    1.52 +\end{codesample2}
    1.53 +In the case of the final commit, you also need to come up with a
    1.54 +commit message, which is almost always going to be a piece of
    1.55 +uninteresting ``boilerplate'' text.
    1.56 +
    1.57 +It would be nice to reduce the number of steps needed, if this were
    1.58 +possible.  Indeed, Mercurial is distributed with an extension called
    1.59 +\hgext{fetch} that does just this.
    1.60 +
    1.61 +Mercurial provides a flexible extension mechanism that lets people
    1.62 +extend its functionality, while keeping the core of Mercurial small
    1.63 +and easy to deal with.  Some extensions add new commands that you can
    1.64 +use from the command line, while others work ``behind the scenes,''
    1.65 +for example adding capabilities to the server.
    1.66 +
    1.67 +The \hgext{fetch} extension adds a new command called, not
    1.68 +surprisingly, \hgcmd{fetch}.  This extension acts as a combination of
    1.69 +\hgcmd{pull}, \hgcmd{update} and \hgcmd{merge}.  It begins by pulling
    1.70 +changes from another repository into the current repository.  If it
    1.71 +finds that the changes added a new head to the repository, it begins a
    1.72 +merge, then commits the result of the merge with an
    1.73 +automatically-generated commit message.  If no new heads were added,
    1.74 +it updates the working directory to the new tip changeset.
    1.75 +
    1.76 +Enabling the \hgext{fetch} extension is easy.  Edit your
    1.77 +\sfilename{.hgrc}, and either go to the \rcsection{extensions} section
    1.78 +or create an \rcsection{extensions} section.  Then add a line that
    1.79 +simply reads ``\Verb+fetch +''.
    1.80 +\begin{codesample2}
    1.81 +  [extensions]
    1.82 +  fetch =
    1.83 +\end{codesample2}
    1.84 +(Normally, on the right-hand side of the ``\texttt{=}'' would appear
    1.85 +the location of the extension, but since the \hgext{fetch} extension
    1.86 +is in the standard distribution, Mercurial knows where to search for
    1.87 +it.)
    1.88 +
    1.89  %%% Local Variables: 
    1.90  %%% mode: latex
    1.91  %%% TeX-master: "00book"