Mercurial > hgbook
changeset 321:2b25fe6e4331
I've done branch.tex
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Thu, 27 Mar 2008 18:35:07 +0900 |
parents | 5357ca303e85 |
children | 4301500fca37 |
files | ja/branch.tex |
diffstat | 1 files changed, 141 insertions(+), 63 deletions(-) [+] |
line wrap: on
line diff
--- a/ja/branch.tex Thu Mar 27 06:07:34 2008 +0900 +++ b/ja/branch.tex Thu Mar 27 18:35:07 2008 +0900 @@ -557,97 +557,175 @@ %\section{Dealing with multiple named branches in a repository} \section{$B%j%]%8%H%jFb$GJ#?t$NL>A0$NIU$$$?%V%i%s%A$N<h$j07$$(B} -If you have more than one named branch in a repository, Mercurial will -remember the branch that your working directory on when you start a -command like \hgcmd{update} or \hgcmdargs{pull}{-u}. It will update -the working directory to the tip of this branch, no matter what the -``repo-wide'' tip is. To update to a revision that's on a different -named branch, you may need to use the \hgopt{update}{-C} option to -\hgcmd{update}. +%If you have more than one named branch in a repository, Mercurial will +%remember the branch that your working directory on when you start a +%command like \hgcmd{update} or \hgcmdargs{pull}{-u}. It will update +%the working directory to the tip of this branch, no matter what the +%``repo-wide'' tip is. To update to a revision that's on a different +%named branch, you may need to use the \hgopt{update}{-C} option to +%\hgcmd{update}. + +1$B$D$N%j%]%8%H%jFb$K(B2$B$D0J>e$N%V%i%s%A$r;}$C$F$$$k>l9g!$(BMercurial$B$O!$(B +\hgcmd{update}$B$d(B\hgcmdargs{pull}{-u}$B$N$h$&$J%3%^%s%I$rN)$A>e$2$k$H$-$K!$(B +$B%o!<%-%s%0%G%#%l%/%H%j$,$I$N%V%i%s%A$G$"$k$+5-21$7$F$$$k!%(B +$B$3$l$i$N%3%^%s%I$O!$%j%]%8%H%jA4BN$G$N(Btip$B$,2?$G$"$k$+$K$O4X78$J$/!$%o!<%-(B +$B%s%0%G%#%l%/%H%j$r8=:_$N%V%i%s%A$N(Btip$B$K99?7$9$k!%(B +$BB>$NL>A0$D$-%V%i%s%A$KB0$9%j%S%8%g%s$X99?7$9$k$K$O!$(B\hgopt{update}{-C}$B%*(B +$B%W%7%g%sIU$-$G(B\hgcmd{update}$B%3%^%s%I$r<B9T$9$kI,MW$,$"$k$+$b$7$l$J$$!%(B -This behaviour is a little subtle, so let's see it in action. First, -let's remind ourselves what branch we're currently on, and what -branches are in our repository. +%This behaviour is a little subtle, so let's see it in action. First, +%let's remind ourselves what branch we're currently on, and what +%branches are in our repository. +%\interaction{branch-named.parents} +%We're on the \texttt{bar} branch, but there also exists an older +%\texttt{foo} branch. + +$B$3$N$U$k$^$$$O$d$d4q0[$+$b$7$l$J$$!%<B:]$NF0:n$r8+$F$_$k$3$H$K$9$k!%$^$:(B +$B2f!9$,$I$N%V%i%s%A$K$$$k$+$rD4$Y!$%j%]%8%H%j$K$I$s$J%V%i%s%A$,$"$k$+8+$F(B +$B$_$h$&!%(B \interaction{branch-named.parents} -We're on the \texttt{bar} branch, but there also exists an older -\hgcmd{foo} branch. +$B:#$$$k$N$O(B\texttt{bar}$B%V%i%s%A$G!$(B\texttt{foo}$B%V%i%s%A$bB8:_$9$k!%(B -We can \hgcmd{update} back and forth between the tips of the -\texttt{foo} and \texttt{bar} branches without needing to use the -\hgopt{update}{-C} option, because this only involves going backwards -and forwards linearly through our change history. +%We can \hgcmd{update} back and forth between the tips of the +%\texttt{foo} and \texttt{bar} branches without needing to use the +%\hgopt{update}{-C} option, because this only involves going backwards +%and forwards linearly through our change history. +%\interaction{branch-named.update-switchy} + +\texttt{foo}$B$H(B\texttt{bar}$B$N(Btip$B$N4V$r(B\hgcmd{update}$B%3%^%s%I$G9T$-Mh$9$k$3(B +$B$H$,$G$-$k!%$3$NA`:n$O99?7MzNr$NCf$r@~7A$K0\F0$9$k$@$1$J$N$G!$(B +\hgopt{update}{-C}$B%*%W%7%g%s$OI,MW$J$$!%(B \interaction{branch-named.update-switchy} -If we go back to the \texttt{foo} branch and then run \hgcmd{update}, -it will keep us on \texttt{foo}, not move us to the tip of -\texttt{bar}. +%If we go back to the \texttt{foo} branch and then run \hgcmd{update}, +%it will keep us on \texttt{foo}, not move us to the tip of +%\texttt{bar}. +%\interaction{branch-named.update-nothing} + +\texttt{foo}$B%V%i%s%A$XLa$j!$(B\hgcmd{update}$B$r<B9T$7$F$b!$(B\texttt{bar}$B$N(B +tip$B$K$O0\F0$;$:!$(B\texttt{foo}$B$N$^$^$G$"$k!%(B \interaction{branch-named.update-nothing} -Committing a new change on the \texttt{foo} branch introduces a new -head. +%Committing a new change on the \texttt{foo} branch introduces a new +%head. +%\interaction{branch-named.foo-commit} +%We can no longer update from \texttt{foo} to \texttt{bar} without +%going ``sideways'' in history, so Mercurial forces us to provide the +%\hgopt{update}{-C} option to \hgcmd{update}. +%\interaction{branch-named.update-bar} + +$B?7$7$$JQ99$r(B\texttt{foo}$B$K%3%_%C%H$9$k$H!$?7$7$$(Bhead$B$,:n$i$l$k!%(B \interaction{branch-named.foo-commit} -We can no longer update from \texttt{foo} to \texttt{bar} without -going ``sideways'' in history, so Mercurial forces us to provide the -\hgopt{update}{-C} option to \hgcmd{update}. +$B$b$O$d(B\texttt{foo}$B$+$i(B\texttt{bar}$B$X$O!$OFF;$K0o$l$k$3$H$J$/99?7$9$k$3$H(B +$B$O$G$-$J$$!%$=$3$G!$(B\hgopt{update}{-C}$B%*%W%7%g%s$r;H$C$F(B\hgcmd{update}$B$r(B +$B<B9T$9$k$3$H$,I,MW$K$J$k!%(B \interaction{branch-named.update-bar} %\section{Branch names and merging} \section{$B%V%i%s%AL>$H%^!<%8(B} -As you've probably noticed, merges in Mercurial are not symmetrical. -Let's say our repository has two heads, 17 and 23. If I -\hgcmd{update} to 17 and then \hgcmd{merge} with 23, Mercurial records -17 as the first parent of the merge, and 23 as the second. Whereas if -I \hgcmd{update} to 23 and then \hgcmd{merge} with 17, it records 23 -as the first parent, and 17 as the second. +%As you've probably noticed, merges in Mercurial are not symmetrical. +%Let's say our repository has two heads, 17 and 23. If I +%\hgcmd{update} to 17 and then \hgcmd{merge} with 23, Mercurial records +%17 as the first parent of the merge, and 23 as the second. Whereas if +%I \hgcmd{update} to 23 and then \hgcmd{merge} with 17, it records 23 +%as the first parent, and 17 as the second. + +$B$*$=$i$/5$$E$$$F$$$k$3$H$H;W$&$,!$(BMercurial$B$G$N%^!<%8$OBP>NE*$G$O$J$$!%(B +$B:#!$%j%]%8%H%j$,(B17$B$H(B23$B$H$$$&(B2$B$D$N(Bhead$B$r;}$D$H$7$h$&!%$3$3$G(B +\hgcmd{update}$B$G(B17$B$K99?7$7!$(B\hgcmd{merge}$B$K$h$C$F(B23$B$H%^!<%8$9$k$H!$(B +Mercurial$B$O(B17$B$r%^!<%8$N:G=i$N?F!$(B23$B$r(B2$BHVL\$N?F$H$7$F5-O?$9$k!%5U$K(B +\hgcmd{update}$B$G(B23$B$K99?7$7!$(B\hgcmd{merge}$B$G(B17$B$H%^!<%8$9$l$P!$(B23$B$r:G=i$N(B +$B?F!$(B17$B$r(B2$BHVL\$N?F$H5-O?$9$k!%(B + +%This affects Mercurial's choice of branch name when you merge. After +%a merge, Mercurial will retain the branch name of the first parent +%when you commit the result of the merge. If your first parent's +%branch name is \texttt{foo}, and you merge with \texttt{bar}, the +%branch name will still be \texttt{foo} after you merge. -This affects Mercurial's choice of branch name when you merge. After -a merge, Mercurial will retain the branch name of the first parent -when you commit the result of the merge. If your first parent's -branch name is \texttt{foo}, and you merge with \texttt{bar}, the -branch name will still be \texttt{foo} after you merge. +$B$3$l$O%^!<%8$N:]$K(BMercurial$B$,%V%i%s%AL>$r$I$N$h$&$KA*$V$+$K1F6A$rM?$($k!%(B +$B%^!<%88e!"%^!<%8$N7k2L$r%3%_%C%H$9$k:]$K(BMercurial$B$O(B1$BHVL\$N?F$N%V%i%s%AL>(B +$B$rMQ$$$k!%(B1$BHVL\$N?F$N%V%i%s%AL>$,(B\texttt{foo}$B$G!$(B\texttt{bar}$B$H%^!<%8$r(B +$B9T$J$C$?$H$9$k$H!$%^!<%88e$N%V%i%s%AL>$O(B\texttt{foo}$B$H$J$k!%(B + +%It's not unusual for a repository to contain multiple heads, each with +%the same branch name. Let's say I'm working on the \texttt{foo} +%branch, and so are you. We commit different changes; I pull your +%changes; I now have two heads, each claiming to be on the \texttt{foo} +%branch. The result of a merge will be a single head on the +%\texttt{foo} branch, as you might hope. -It's not unusual for a repository to contain multiple heads, each with -the same branch name. Let's say I'm working on the \texttt{foo} -branch, and so are you. We commit different changes; I pull your -changes; I now have two heads, each claiming to be on the \texttt{foo} -branch. The result of a merge will be a single head on the -\texttt{foo} branch, as you might hope. +1$B$D$N%j%]%8%H%j$,F1$8%V%i%s%AL>$r;}$D$$$/$D$b$N(Bhead$B$r;}$C$F$$$k$3$H$ODA$7(B +$B$$$3$H$G$O$J$$!%:#!$;d$H$"$J$?$,F1$8(B\texttt{foo}$B%V%i%s%A$G:n6H$r$7$F$*$j!$(B +$B$=$l$>$l0[$J$C$?JQ99$r%3%_%C%H$9$k$H$7$h$&!%$"$J$?$N9T$J$C$?JQ99$r;d$,(B +pull$B$9$k$H!$;d$O(B\texttt{foo}$B%V%i%s%A$K(B2$B$D$N(Bhead$B$r;}$D$3$H$K$J$k!%%^!<%8(B +$B$N7k2L$O!$$"$J$?$,4|BT$9$k$h$&$K(B\texttt{foo}$B%V%i%s%A>e$G(B1$B$D$N(Bhead$B$K$J$k!%(B -But if I'm working on the \texttt{bar} branch, and I merge work from -the \texttt{foo} branch, the result will remain on the \texttt{bar} -branch. +%But if I'm working on the \texttt{bar} branch, and I merge work from +%the \texttt{foo} branch, the result will remain on the \texttt{bar} +%branch. +%\interaction{branch-named.merge} + +$B$7$+$7!$;d$,(B\texttt{bar}$B%V%i%s%A$G:n6H$r$7$F$$$F!$(B\texttt{foo}$B%V%i%s%A$+(B +$B$i%^!<%8$r9T$J$&$H!$@.2LJ*$O(B\texttt{bar}$B%V%i%s%A$K;D$k$3$H$K$J$k!%(B \interaction{branch-named.merge} -To give a more concrete example, if I'm working on the -\texttt{bleeding-edge} branch, and I want to bring in the latest fixes -from the \texttt{stable} branch, Mercurial will choose the ``right'' -(\texttt{bleeding-edge}) branch name when I pull and merge from -\texttt{stable}. +%To give a more concrete example, if I'm working on the +%\texttt{bleeding-edge} branch, and I want to bring in the latest fixes +%from the \texttt{stable} branch, Mercurial will choose the ``right'' +%(\texttt{bleeding-edge}) branch name when I pull and merge from +%\texttt{stable}. + +$B$b$C$H6qBNE*$JNc$r5s$2$k$H!$$b$7;d$,(B\texttt{bleeding-edge}$B%V%i%s%A$G:n6H(B +$B$r$7$F$$$F!$(B\texttt{stable}$B%V%i%s%A$N?7$7$$=$@5$r<h$j9~$`$?$a$K(B +\texttt{stable}$B$+$i(Bpull$B$H(Bmerge$B$r9T$J$&$H!$(BMercurial$B$O(B``$B@5$7$$(B''$B%V%i%s%AL>(B +(\texttt{bleeding-edge})$B$rA*$V!%(B %\section{Branch naming is generally useful} \section{$B%V%i%s%A$KL>A0$rIU$1$k$3$H$OLr$KN)$D(B} -You shouldn't think of named branches as applicable only to situations -where you have multiple long-lived branches cohabiting in a single -repository. They're very useful even in the one-branch-per-repository -case. +%You shouldn't think of named branches as applicable only to situations +%where you have multiple long-lived branches cohabiting in a single +%repository. They're very useful even in the one-branch-per-repository +%case. + +$BL>A0IU$-%V%i%s%A$r(B1$B$D$N%j%]%8%H%j$NCf$KD9L?$J%V%i%s%A$rJ#?t;}$D>u67$K$N$_(B +$BMQ$$$k$Y$-$@$H9M$($k$Y$-$G$O$J$$!%L>A0IU$-%V%i%s%A$O%V%i%s%AKh$K%j%]%8%H(B +$B%j$r;}$D>l9g$G$b6K$a$FM-MQ$G$"$k!%(B + +%In the simplest case, giving a name to each branch gives you a +%permanent record of which branch a changeset originated on. This +%gives you more context when you're trying to follow the history of a +%long-lived branchy project. -In the simplest case, giving a name to each branch gives you a -permanent record of which branch a changeset originated on. This -gives you more context when you're trying to follow the history of a -long-lived branchy project. +$B:G$bC1=c$JNc$O!$$=$l$>$l$N%V%i%s%A$KL>A0$rM?$($k$3$H$G!$%A%'%s%8%;%C%H$,(B +$B$I$N%V%i%s%A$r5/8;$K;}$D$N$+1JB3E*$K5-O?$9$k$3$H$,$G$-$k!%$3$l$K$h$j!$D9(B +$BL?$J%V%i%s%A$r;}$D%W%m%8%'%/%H$NNr;K$rDI$$$+$1$k;~$K!$A08e4X78$,DO$_$d$9(B +$B$/$J$k!%(B -If you're working with shared repositories, you can set up a -\hook{pretxnchangegroup} hook on each that will block incoming changes -that have the ``wrong'' branch name. This provides a simple, but -effective, defence against people accidentally pushing changes from a -``bleeding edge'' branch to a ``stable'' branch. Such a hook might -look like this inside the shared repo's \hgrc. +%If you're working with shared repositories, you can set up a +%\hook{pretxnchangegroup} hook on each that will block incoming changes +%that have the ``wrong'' branch name. This provides a simple, but +%effective, defence against people accidentally pushing changes from a +%``bleeding edge'' branch to a ``stable'' branch. Such a hook might +%look like this inside the shared repo's \hgrc. +%\begin{codesample2} +% [hooks] +% pretxnchangegroup.branch = hg heads --template '{branches} ' | grep mybranch +%\end{codesample2} + +$B6&M-%j%]%8%H%j$r;H$C$F:n6H$7$F$$$k>l9g!$(B\hook{pretxnchangegroup}$B%U%C%/$r(B +$B@_Dj$9$k$3$H$G4V0c$C$?%V%i%s%AL>$r;}$D99?7$r%V%m%C%/$9$k$3$H$,$G$-$k!%$3(B +$B$l$ONc$($P(B``$B:G@hC<(B''$B%V%i%s%A$+$i(B``$B0BDj(B''$B%V%i%s%A$XJQ99$r(Bpush$B$9$k$h$&$J4V(B +$B0c$$$rKI$0$N$K%7%s%W%k$+$D8z2LE*$JJ}K!$G$"$k!%%U%C%/$O!$Nc$($P6&M-%j%]%8(B +$B%H%j$N(B\hgrc$B$K(B \begin{codesample2} [hooks] pretxnchangegroup.branch = hg heads --template '{branches} ' | grep mybranch \end{codesample2} +$B$N$h$&$K5-=R$5$l$k!%(B + %%% Local Variables: %%% mode: yatex