Mercurial > hgbook
changeset 365:427e0fed6d5e
started tour-merge.tex
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Mon, 20 Oct 2008 17:22:47 +0900 |
parents | 1b372620963a |
children | 4e746f46085c |
files | ja/todo.txt ja/tour-merge.tex |
diffstat | 2 files changed, 163 insertions(+), 77 deletions(-) [+] |
line wrap: on
line diff
--- a/ja/todo.txt Mon Oct 20 15:22:06 2008 +0900 +++ b/ja/todo.txt Mon Oct 20 17:22:47 2008 +0900 @@ -16,6 +16,6 @@ srcinstall.tex 100% template.tex 100% tour-basic.tex -tour-merge.tex +tour-merge.tex 10% undo.tex 100% cmdref.tex 100%
--- a/ja/tour-merge.tex Mon Oct 20 15:22:06 2008 +0900 +++ b/ja/tour-merge.tex Mon Oct 20 17:22:47 2008 +0900 @@ -1,116 +1,198 @@ -\chapter{A tour of Mercurial: merging work} +%\chapter{A tour of Mercurial: merging work} +\chapter{Mercurial$B%D%"!<(B: $B%^!<%8(B} \label{chap:tour-merge} -We've now covered cloning a repository, making changes in a -repository, and pulling or pushing changes from one repository into -another. Our next step is \emph{merging} changes from separate -repositories. +%We've now covered cloning a repository, making changes in a +%repository, and pulling or pushing changes from one repository into +%another. Our next step is \emph{merging} changes from separate +%repositories. + +$B2f!9$O4{$K%j%]%8%H%j$N%/%m!<%s!$%j%]%8%H%j$KBP$9$kJQ99!$(B1$B$D$N%j%]%8%H%j$+(B +$B$i$N(Bpull$B$HJL$N(B1$B$D$N%j%]%8%H%j$KBP$9$k(Bpush$B$r9T$C$?!%<!$N%9%F%C%W$OJL$N%j%](B +$B%8%H%j$+$iJQ99$r(B\emph{$B%^!<%8(B}$B$9$k$3$H$G$"$k!%(B -\section{Merging streams of work} +%\section{Merging streams of work} +\section{$BJ#?t$N:n6H7k2L$r%^!<%8$9$k(B} + +%Merging is a fundamental part of working with a distributed revision +%control tool. + +$B%^!<%8$OJ,;6%j%S%8%g%s%3%s%H%m!<%k%D!<%k$G$N:n6H$K$*$$$FIT2D7g$NItJ,$G$"(B +$B$k!%(B -Merging is a fundamental part of working with a distributed revision -control tool. \begin{itemize} -\item Alice and Bob each have a personal copy of a repository for a - project they're collaborating on. Alice fixes a bug in her - repository; Bob adds a new feature in his. They want the shared - repository to contain both the bug fix and the new feature. -\item I frequently work on several different tasks for a single - project at once, each safely isolated in its own repository. - Working this way means that I often need to merge one piece of my - own work with another. +%\item Alice and Bob each have a personal copy of a repository for a + +% project they're collaborating on. Alice fixes a bug in her +% repository; Bob adds a new feature in his. They want the shared +% repository to contain both the bug fix and the new feature. + \item $B%"%j%9$H%\%V$O6&F1:n6H$7$F$$$k%W%m%8%'%/%H$N%j%]%8%H%j%3%T!<$r3F!9(B +$B;}$C$F$$$k!%%"%j%9$O<+J,$N%j%]%8%H%j$G%P%0$r=$@5$7!$%\%V$OH`$N%j%]%8%H%j(B +$B$G?75!G=$rDI2C$7$?!%H`$i$O%P%0=$@5$H?75!G=$NN>J}$r;}$D%j%]%8%H%j$r6&M-$7(B +$B$?$$$H9M$($F$$$k!%(B + +%\item I frequently work on several different tasks for a single +% project at once, each safely isolated in its own repository. +% Working this way means that I often need to merge one piece of my +% own work with another. + \item $B;d$O0l$D$N%W%m%8%'%/%H$NJL!9$N%?%9%/$KBP$7$FF1;~$K:n6H$r9T$&$3$H$r(B + $B$h$/9T$C$F$$$k!%$3$N$h$&$J:n6H%9%?%$%k$G$O!$<+J,$N:n6H$N0l$D$+$iJL(B + $B$N:n6H$N0l$D$X7k2L$r%^!<%8$7$?$$$H;W$&$3$H$,$7$P$7$P$"$k!%(B + \end{itemize} -Because merging is such a common thing to need to do, Mercurial makes -it easy. Let's walk through the process. We'll begin by cloning yet -another repository (see how often they spring up?) and making a change -in it. +%Because merging is such a common thing to need to do, Mercurial makes +%it easy. Let's walk through the process. We'll begin by cloning yet +%another repository (see how often they spring up?) and making a change +%in it. + +$B>e$G=R$Y$?$h$&$K%^!<%8$r9T$$$?$$>u67$O$H$F$bB?$$$?$a!$(B Mercurial$B$G$O%^!<(B +$B%8$r4JC1$K9T$($k$h$&$K$J$C$F$$$k!%$^$:JL$N%j%]%8%H%j$r%/%m!<%s$7!$JQ99$r(B +$B2C$($k$H$3$m$+$i;O$a$h$&!%(B \interaction{tour.merge.clone} -We should now have two copies of \filename{hello.c} with different -contents. The histories of the two repositories have also diverged, -as illustrated in figure~\ref{fig:tour-merge:sep-repos}. + +%We should now have two copies of \filename{hello.c} with different +%contents. The histories of the two repositories have also diverged, +%as illustrated in figure~\ref{fig:tour-merge:sep-repos}. + +$B:#!$FbMF$N0[$J$C$?(B2$B$D$N(B\filename{hello.c}$B$,$"$k!%(B 2$B$D$N%j%]%8%H%j$NMzNr$O(B +$B?^(B~\ref{fig:tour-merge:sep-repos}$B$K<($9$h$&$KJ,$+$l$F$$$k!%(B \interaction{tour.merge.cat} \begin{figure}[ht] \centering \grafix{tour-merge-sep-repos} - \caption{Divergent recent histories of the \dirname{my-hello} and - \dirname{my-new-hello} repositories} +% \caption{Divergent recent histories of the \dirname{my-hello} and +% \dirname{my-new-hello} repositories} + \caption{\dirname{my-hello}$B%j%]%8%H%j$H(B\dirname{my-new-hello}$B%j%]%8%H(B + $B%j$NMzNr$N:90[(B} \label{fig:tour-merge:sep-repos} \end{figure} -We already know that pulling changes from our \dirname{my-hello} -repository will have no effect on the working directory. +%We already know that pulling changes from our \dirname{my-hello} +%repository will have no effect on the working directory. +$B4{$K(B\dirname{my-hello}$B%j%]%8%H%j$+$i$N(Bpull$B$O%o!<%-%s%0%G%#%l%/%H%j$K2?$N(B +$B1F6A$bM?$($J$$$3$H$r3X$s$@!%(B \interaction{tour.merge.pull} -However, the \hgcmd{pull} command says something about ``heads''. +%However, the \hgcmd{pull} command says something about ``heads''. +$B$7$+$7(B\hgcmd{pull}$B%3%^%s%I$O(B``heads''$B$K$D$$$F%a%C%;!<%8$rI=<($9$k!%(B -\subsection{Head changesets} +%\subsection{Head changesets} +\subsection{Head$B%A%'%s%8%;%C%H(B} -A head is a change that has no descendants, or children, as they're -also known. The tip revision is thus a head, because the newest -revision in a repository doesn't have any children, but a repository -can contain more than one head. +%A head is a change that has no descendants, or children, as they're +%also known. The tip revision is thus a head, because the newest +%revision in a repository doesn't have any children, but a repository +%can contain more than one head. +head$B$O;RB9$d;R$r;}$?$J$$JQ99$G$"$k!%%j%]%8%H%j$N:G?7$N%j%S%8%g%s$O;R$r;}(B +$B$?$J$$$?$a!$(Btip$B%j%S%8%g%s$O$9$J$o$A(Bhead$B$G$"$k!%0lJ}$G%j%]%8%H%j$OJ#?t$N(B +head$B$r;}$AF@$k!%(B \begin{figure}[ht] \centering \grafix{tour-merge-pull} - \caption{Repository contents after pulling from \dirname{my-hello} into - \dirname{my-new-hello}} +% \caption{Repository contents after pulling from \dirname{my-hello} into +% \dirname{my-new-hello}} + \caption{\dirname{my-hello}$B$+$i(B\dirname{my-new-hello}$B$X(Bpull$B$7$?$"$H$N(B + $B%j%]%8%H%j$NFbMF(B} \label{fig:tour-merge:pull} \end{figure} -In figure~\ref{fig:tour-merge:pull}, you can see the effect of the -pull from \dirname{my-hello} into \dirname{my-new-hello}. The history -that was already present in \dirname{my-new-hello} is untouched, but a -new revision has been added. By referring to -figure~\ref{fig:tour-merge:sep-repos}, we can see that the -\emph{changeset ID} remains the same in the new repository, but the -\emph{revision number} has changed. (This, incidentally, is a fine -example of why it's not safe to use revision numbers when discussing -changesets.) We can view the heads in a repository using the -\hgcmd{heads} command. +%In figure~\ref{fig:tour-merge:pull}, you can see the effect of the +%pull from \dirname{my-hello} into \dirname{my-new-hello}. The history +%that was already present in \dirname{my-new-hello} is untouched, but a +%new revision has been added. By referring to +%figure~\ref{fig:tour-merge:sep-repos}, we can see that the +%\emph{changeset ID} remains the same in the new repository, but the +%\emph{revision number} has changed. (This, incidentally, is a fine +%example of why it's not safe to use revision numbers when discussing +%changesets.) We can view the heads in a repository using the +%\hgcmd{heads} command. +%\interaction{tour.merge.heads} + +$B?^(B~\ref{fig:tour-merge:pull}$B$K(B\dirname{my-hello}$B$+$i(B +\dirname{my-new-hello}$B$X(Bpull$B$r9T$C$?8z2L$r<($9!%(B \dirname{my-new-hello}$B$K(B +$B4{$KB8:_$7$?MzNr$OJQ99$5$l$:!$?7$?$K%j%S%8%g%s$,DI2C$5$l$k!%(B +figure~\ref{fig:tour-merge:sep-repos}$B$r8+$k$H!$?7$7$$%j%]%8%H%j$K$b(B +\emph{changeset ID}$B$,;D$C$F$$$k$3$H!$(B\emph{$B%j%S%8%g%sHV9f(B}$B$,JQ99$5$l$F$$(B +$B$k$3$H$,J,$+$k!%(B $B!J$3$l$OF1;~$K%A%'%s%8%;%C%H$K$D$$$FO@$8$k:]$K%j%S%8%g%s(B +$BHV9f$rMQ$$$k$N$,0BA4$G$J$$$3$H$NNc$K$J$C$F$$$k!%!K%j%]%8%H%jFb$K$"$k(Bhead +$B$O(B\hgcmd{heads}$B$K$h$C$F8+$k$3$H$,$G$-$k!%(B \interaction{tour.merge.heads} -\subsection{Performing the merge} +%\subsection{Performing the merge} +\subsection{$B%^!<%8$r<B9T$9$k(B} -What happens if we try to use the normal \hgcmd{update} command to -update to the new tip? +%What happens if we try to use the normal \hgcmd{update} command to +%update to the new tip? +%\interaction{tour.merge.update} + +$B?7$7$$(Btip$B$X99?7$9$k$?$a$K(B\hgcmd{update}$B$r;H$C$?>l9g2?$,5/$-$k$+!)(B \interaction{tour.merge.update} -Mercurial is telling us that the \hgcmd{update} command won't do a -merge; it won't update the working directory when it thinks we might -be wanting to do a merge, unless we force it to do so. Instead, we -use the \hgcmd{merge} command to merge the two heads. + +%Mercurial is telling us that the \hgcmd{update} command won't do a +%merge; it won't update the working directory when it thinks we might +%be wanting to do a merge, unless we force it to do so. Instead, we +%use the \hgcmd{merge} command to merge the two heads. +%\interaction{tour.merge.merge} + +Mercurial$B$O(B\hgcmd{update}$B%3%^%s%I$,%^!<%8$r9T$o$J$$$H%a%C%;!<%8$rI=<($9(B +$B$k!%(B \hgcmd{update}$B%3%^%s%I$O!$%^!<%8$,I,MW$H9M$($i$l$k>l9g$O!$%f!<%6$,(B +$B!J%*%W%7%g%s$K$h$C$F!K6/@)$7$J$$8B$j%o!<%-%s%0%G%#%l%/%H%j$r99?7$7$J$$!%(B +$B0lJ}!$(B\hgcmd{merge}$B%3%^%s%I$O(B2$B$D$N%X%C%I$N%^!<%8$r9T$&!%(B \interaction{tour.merge.merge} \begin{figure}[ht] \centering \grafix{tour-merge-merge} - \caption{Working directory and repository during merge, and - following commit} +% \caption{Working directory and repository during merge, and +% following commit} + \caption{$B%^!<%8Cf$N%o!<%-%s%0%G%#%l%/%H%j$H%j%]%8%H%j$*$h$S8eB3$N%3%_%C(B + $B%H(B} \label{fig:tour-merge:merge} \end{figure} -This updates the working directory so that it contains changes from -\emph{both} heads, which is reflected in both the output of -\hgcmd{parents} and the contents of \filename{hello.c}. -\interaction{tour.merge.parents} +%This updates the working directory so that it contains changes from +%\emph{both} heads, which is reflected in both the output of +%\hgcmd{parents} and the contents of \filename{hello.c}. +%\interaction{tour.merge.parents} + +$B$3$NA`:n$K$h$C$F(B\hgcmd{parents}$B$H(B\filename{hello.c}$B$N=PNO$NAPJ}$rH?1G$9$k(B +\emph{$BAPJ}$N(B}head$B$+$i$NJQ99$r4^$`$h$&$K%o!<%-%s%0%G%#%l%/%H%j$,99?7$5$l$k!%(B -\subsection{Committing the results of the merge} +%\subsection{Committing the results of the merge} +\subsection{$B%^!<%87k2L$r%3%_%C%H$9$k(B} -Whenever we've done a merge, \hgcmd{parents} will display two parents -until we \hgcmd{commit} the results of the merge. +%Whenever we've done a merge, \hgcmd{parents} will display two parents +%until we \hgcmd{commit} the results of the merge. +%\interaction{tour.merge.commit} + +$B%^!<%8$r9T$&$H!$%^!<%8$N7k2L$r(B\hgcmd{commit}$B$9$k$^$G!$(B\hgcmd{parents}$B$O(B2 +$B$D$N%Z%"%l%s%H$rI=<($9$k!%(B \interaction{tour.merge.commit} -We now have a new tip revision; notice that it has \emph{both} of -our former heads as its parents. These are the same revisions that -were previously displayed by \hgcmd{parents}. + +%We now have a new tip revision; notice that it has \emph{both} of +%our former heads as its parents. These are the same revisions that +%were previously displayed by \hgcmd{parents}. +%\interaction{tour.merge.tip} + +$B?7$7$$(Btip$B%j%S%8%g%s$O0JA0$N%X%C%I(B\emph{$BN>J}(B}$B$r?F$H$7$F;}$D!%$3$l$i$O(B +\hgcmd{parents}$B%3%^%s%I$GI=<($7$?$N$HF1$8%j%S%8%g%s$G$"$k!%(B \interaction{tour.merge.tip} -In figure~\ref{fig:tour-merge:merge}, you can see a representation of -what happens to the working directory during the merge, and how this -affects the repository when the commit happens. During the merge, the -working directory has two parent changesets, and these become the -parents of the new changeset. + +%In figure~\ref{fig:tour-merge:merge}, you can see a representation of +%what happens to the working directory during the merge, and how this +%affects the repository when the commit happens. During the merge, the +%working directory has two parent changesets, and these become the +%parents of the new changeset. -\section{Merging conflicting changes} +$B?^(B~\ref{fig:tour-merge:merge}$B$G!$%^!<%8$N4V$K%o!<%-%s%0%G%#%l%/%H%j$K2?$,(B +$B5/$-!$%3%_%C%H$7$?;~$K%j%]%8%H%j$K$I$&1F6A$9$k$N$+$r8+$k$3$H$,$G$-$k!%(B +$B%^!<%8$N4V!$%o!<%-%s%0%G%#%l%/%H%j$O(B2$B$D$N?F%A%'%s%8%;%C%H$r;}$A!$$3$l$i$O(B +$B?7$7$$%A%'%s%8%;%C%H$NN>?F$H$J$k!%(B + +%\section{Merging conflicting changes} +\section{$B%3%s%U%j%/%H$N$"$kJQ99$r%^!<%8$9$k(B} Most merges are simple affairs, but sometimes you'll find yourself merging changes where each modifies the same portions of the same @@ -145,7 +227,8 @@ instead of \command{hgmerge}, by setting the \envar{HGMERGE} environment variable to the name of your preferred program. -\subsection{Using a graphical merge tool} +%\subsection{Using a graphical merge tool} +\subsection{$B%0%i%U%#%+%k%^!<%8%D!<%k$N;HMQ(B} My preferred graphical merge tool is \command{kdiff3}, which I'll use to describe the features that are common to graphical file merging @@ -175,7 +258,8 @@ \begin{figure}[ht] \centering \grafix{kdiff3} - \caption{Using \command{kdiff3} to merge versions of a file} +% \caption{Using \command{kdiff3} to merge versions of a file} + \caption{$B%U%!%$%k$NJ#?t%j%S%8%g%s$r(B\command{kdiff3}$B$r;H$C$F%^!<%8$9$k(B} \label{fig:tour-merge:kdiff3} \end{figure} @@ -190,7 +274,8 @@ files containing plain text, while a few are aimed at specialised file formats (generally XML). -\subsection{A worked example} +%\subsection{A worked example} +\subsection{$B<B9TNc(B} In this example, we will reproduce the file modification history of figure~\ref{fig:tour-merge:conflict} above. Let's begin by creating a @@ -231,7 +316,8 @@ of our merge: \interaction{tour-merge-conflict.commit} -\section{Simplifying the pull-merge-commit sequence} +%\section{Simplifying the pull-merge-commit sequence} +\section{pull-merge-commit$B<j=g$r4JC1$K$9$k(B} \label{sec:tour-merge:fetch} The process of merging changes as outlined above is straightforward, @@ -277,7 +363,7 @@ is in the standard distribution, Mercurial knows where to search for it.) -%%% Local Variables: +%%% Local Variables: %%% mode: yatex %%% TeX-master: "00book" -%%% End: +%%% End: