Mercurial > hgbook
changeset 300:e5d4fca73f97
more undo.tex
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Fri, 08 Feb 2008 19:14:09 +0900 |
parents | 5f6ebc8f4e74 |
children | 828f5606faf0 |
files | ja/undo.tex |
diffstat | 1 files changed, 112 insertions(+), 52 deletions(-) [+] |
line wrap: on
line diff
--- a/ja/undo.tex Fri Feb 08 14:44:14 2008 +0900 +++ b/ja/undo.tex Fri Feb 08 19:14:09 2008 +0900 @@ -404,88 +404,148 @@ %\subsection{Backing out a changeset} \subsection{$B%A%'%s%8%;%C%H$N%P%C%/%"%&%H(B} -The \hgcmd{backout} command lets you ``undo'' the effects of an entire -changeset in an automated fashion. Because Mercurial's history is -immutable, this command \emph{does not} get rid of the changeset you -want to undo. Instead, it creates a new changeset that -\emph{reverses} the effect of the to-be-undone changeset. +%The \hgcmd{backout} command lets you ``undo'' the effects of an entire +%changeset in an automated fashion. Because Mercurial's history is +%immutable, this command \emph{does not} get rid of the changeset you +%want to undo. Instead, it creates a new changeset that +%\emph{reverses} the effect of the to-be-undone changeset. -The operation of the \hgcmd{backout} command is a little intricate, so -let's illustrate it with some examples. First, we'll create a -repository with some simple changes. +\hgcmd{backout}$B%3%^%s%I$O%A%'%s%8%;%C%HA4BN$N:nMQ$rBG$A>C$9!%(BMercurial$B$N(B +$BMzNr$OITJQ$J$N$G!$$3$N%3%^%s%I$O<h$j>C$7$?$$%A%'%s%8%;%C%H$r<h$j=|$/$b$N(B +$B$G$O(B\emph{$B$J$$(B}$B!%$=$NBe$o$j!$<h$j=|$-$?$$%A%'%s%8%;%C%H$N(B\emph{$B5U(B}$B$NF/$-(B +$B$N?7$?$J%A%'%s%8%;%C%H$r$r@8@.$9$k!%(B + +%The operation of the \hgcmd{backout} command is a little intricate, so +%let's illustrate it with some examples. First, we'll create a +%repository with some simple changes. +%\interaction{backout.init} + +\hgcmd{backout}$B%3%^%s%I$NF0:n$O$d$dJ#;($J$N$G!$Nc$r5s$2$F@bL@$9$k$3$H$K(B +$B$9$k!%$^$:$$$/$D$+$NC1=c$JJQ99$N$"$k%j%]%8%H%j$r9M$($k!%(B \interaction{backout.init} -The \hgcmd{backout} command takes a single changeset ID as its -argument; this is the changeset to back out. Normally, -\hgcmd{backout} will drop you into a text editor to write a commit -message, so you can record why you're backing the change out. In this -example, we provide a commit message on the command line using the -\hgopt{backout}{-m} option. +%The \hgcmd{backout} command takes a single changeset ID as its +%argument; this is the changeset to back out. Normally, +%\hgcmd{backout} will drop you into a text editor to write a commit +%message, so you can record why you're backing the change out. In this +%example, we provide a commit message on the command line using the +%\hgopt{backout}{-m} option. -\subsection{Backing out the tip changeset} +\hgcmd{backout}$B%3%^%s%I$O%P%C%/%"%&%H$9$Y$-%A%'%s%8%;%C%H$N(BID$B$r0l$D0z?t$K(B +$B<h$k!%(B\hgcmd{backout}$B$O%G%U%)%k%H$G%3%_%C%H%a%C%;!<%8F~NO$N$?$a$K%F%-%9%H(B +$B%(%G%#%?$r5/F0$9$k$N$G!%%P%C%/%"%&%H$NM}M3$r5-O?$7$F$*$/!%$3$NNc$G$O(B +\hgopt{backout}{-m}$B%*%W%7%g%s$r;H$C$F%3%_%C%H%a%C%;!<%8$r5-O?$7$F$$$k!%(B + + +%\subsection{Backing out the tip changeset} +\subsection{tip$B%A%'%s%8%;%C%H$r%P%C%/%"%&%H$9$k(B} -We're going to start by backing out the last changeset we committed. +%We're going to start by backing out the last changeset we committed. +%\interaction{backout.simple} +%You can see that the second line from \filename{myfile} is no longer +%present. Taking a look at the output of \hgcmd{log} gives us an idea +%of what the \hgcmd{backout} command has done. +%\interaction{backout.simple.log} +%Notice that the new changeset that \hgcmd{backout} has created is a +%child of the changeset we backed out. It's easier to see this in +%figure~\ref{fig:undo:backout}, which presents a graphical view of the +%change history. As you can see, the history is nice and linear. + +$B:G8e$K%3%_%C%H$7$?%A%'%s%8%;%C%H$r%P%C%/%"%&%H$9$k$3$H$+$i;O$a$k!%(B \interaction{backout.simple} -You can see that the second line from \filename{myfile} is no longer -present. Taking a look at the output of \hgcmd{log} gives us an idea -of what the \hgcmd{backout} command has done. +\filename{myfile}$B$N(B2$B9TL\$,$J$/$J$C$F$$$k$N$,J,$+$k$H;W$&!%(B\hgcmd{log}$B$r(B +$B8+$F$_$k$H!$(B\hgcmd{backout}$B$,2?$r$7$?$N$+$,J,$+$k!%(B \interaction{backout.simple.log} -Notice that the new changeset that \hgcmd{backout} has created is a -child of the changeset we backed out. It's easier to see this in -figure~\ref{fig:undo:backout}, which presents a graphical view of the -change history. As you can see, the history is nice and linear. +\hgcmd{backout}$B$,@8@.$7$??7$7$$%A%'%s%8%;%C%H$O!$%P%C%/%"%&%H$7$?%A%'%s(B +$B%8%;%C%H$N;R$K$J$C$F$$$k!%(B\ref{fig:undo:backout}$B$O99?7MzNr$r?^<($7$?$b$N(B +$B$G!$M}2r$N=u$1$K$J$k$O$:$@!%?^$+$iJ,$+$k$h$&$KMzNr$O@~7A$G@09g$,<h$l$F$$$k!%(B \begin{figure}[htb] \centering \grafix{undo-simple} - \caption{Backing out a change using the \hgcmd{backout} command} +% \caption{Backing out a change using the \hgcmd{backout} command} + \caption{\hgcmd{backout}$B%3%^%s%I$r;H$C$F99?7$r%P%C%/%"%&%H(B} \label{fig:undo:backout} \end{figure} -\subsection{Backing out a non-tip change} +%\subsection{Backing out a non-tip change} +\subsection{tip$B$G$J$$JQ99$r%P%C%/%"%&%H$9$k(B} -If you want to back out a change other than the last one you -committed, pass the \hgopt{backout}{--merge} option to the -\hgcmd{backout} command. +%If you want to back out a change other than the last one you +%committed, pass the \hgopt{backout}{--merge} option to the +%\hgcmd{backout} command. +%\interaction{backout.non-tip.clone} +%This makes backing out any changeset a ``one-shot'' operation that's +%usually simple and fast. +%\interaction{backout.non-tip.backout} + +$B:G8e$N%3%_%C%H0J30$NJQ99$r%P%C%/%"%&%H$7$?$$;~$O!$(B +\hgcmd{backout}$B$K(B\hgopt{backout}{--merge}$B%*%W%7%g%s$rIU$1$k!%(B \interaction{backout.non-tip.clone} -This makes backing out any changeset a ``one-shot'' operation that's -usually simple and fast. +$B$3$N%*%W%7%g%s$O$I$s$J%A%'%s%8%;%C%H$G$b0l2s$NF0:n$G9T$J$&$3$H$,$G$-!$<j(B +$BAa$/4JC1$G$"$k!%(B \interaction{backout.non-tip.backout} -If you take a look at the contents of \filename{myfile} after the -backout finishes, you'll see that the first and third changes are -present, but not the second. +%If you take a look at the contents of \filename{myfile} after the +%backout finishes, you'll see that the first and third changes are +%present, but not the second. +%\interaction{backout.non-tip.cat} + +$B%P%C%/%"%&%H$,=*$C$?$"$H$G(B\filename{myfile}$B$NCf?H$r8+$k$H!$(B1$BHVL\$H(B3$BHVL\(B +$B$NJQ99$@$1$,;D$C$F$*$j!$(B2$BHVL\$NJQ99$,>C$($F$$$k$3$H$,$o$+$k!%(B \interaction{backout.non-tip.cat} -As the graphical history in figure~\ref{fig:undo:backout-non-tip} -illustrates, Mercurial actually commits \emph{two} changes in this -kind of situation (the box-shaped nodes are the ones that Mercurial -commits automatically). Before Mercurial begins the backout process, -it first remembers what the current parent of the working directory -is. It then backs out the target changeset, and commits that as a -changeset. Finally, it merges back to the previous parent of the -working directory, and commits the result of the merge. +%As the graphical history in figure~\ref{fig:undo:backout-non-tip} +%illustrates, Mercurial actually commits \emph{two} changes in this +%kind of situation (the box-shaped nodes are the ones that Mercurial +%commits automatically). Before Mercurial begins the backout process, +%it first remembers what the current parent of the working directory +%is. It then backs out the target changeset, and commits that as a +%changeset. Finally, it merges back to the previous parent of the +%working directory, and commits the result of the merge. + +$B?^(B\ref{fig:undo:backout-non-tip}$B$G<($5$l$?MzNr$G!$(BMercurial$B$O(B2$B$D$N%3%_%C(B +$B%H$r9T$J$C$F$$$k!%!J?^Cf$GH"$G<($5$l$?@aE@$O(BMercurial$B$,<+F0E*$K%3%_%C%H$7(B +$B$?JQ99$G$"$k!%!K%P%C%/%"%&%H%W%m%;%9$NA0$K(BMercurial$B$O!$8=:_$N%o!<%-%s%0%G%#(B +$B%l%/%H%j$N?F$,2?$G$"$k$+$r5-21$9$k!%$=$7$F%?!<%2%C%H$N%A%'%s%8%;%C%H$r<h(B +$B$j=|$-!$$3$l$r%A%'%s%8%;%C%H$H$7$F%3%_%C%H$9$k!%:G8e$K%o!<%-%s%0%G%#%l%/(B +$B%H%j$NA0$N?F$X%^!<%8$r9T$J$$!$%^!<%8$N7k2L$r%3%_%C%H$9$k!%(B \begin{figure}[htb] \centering \grafix{undo-non-tip} - \caption{Automated backout of a non-tip change using the \hgcmd{backout} command} +% \caption{Automated backout of a non-tip change using the + % \hgcmd{backout} command} + \caption{tip$B$G$J$$JQ99$r(B\hgcmd{backout}$B%3%^%s%I$G<+F0E*$K%P%C%/%"%&%H$9$k(B} \label{fig:undo:backout-non-tip} \end{figure} -The result is that you end up ``back where you were'', only with some -extra history that undoes the effect of the changeset you wanted to -back out. +%The result is that you end up ``back where you were'', only with some +%extra history that undoes the effect of the changeset you wanted to +%back out. -\subsubsection{Always use the \hgopt{backout}{--merge} option} +$B:G=*E*$K!$$$$/$i$+$NM>7W$JMzNr$r;D$7$D$D!$<h$j=|$-$?$+$C$?%A%'%s%8%;%C%H(B +$B$N1F6A$r=|5n$7$F!$K>$`>uBV$KLa$9$3$H$,$G$-$F$$$k!%(B + + +%\subsubsection{Always use the \hgopt{backout}{--merge} option} +\subsubsection{$B>o$K(B\hgopt{backout}{--merge}$B%*%W%7%g%s$r;H$&(B} -In fact, since the \hgopt{backout}{--merge} option will do the ``right -thing'' whether or not the changeset you're backing out is the tip -(i.e.~it won't try to merge if it's backing out the tip, since there's -no need), you should \emph{always} use this option when you run the -\hgcmd{backout} command. +%In fact, since the \hgopt{backout}{--merge} option will do the ``right +%thing'' whether or not the changeset you're backing out is the tip +%(i.e.~it won't try to merge if it's backing out the tip, since there's +%no need), you should \emph{always} use this option when you run the +%\hgcmd{backout} command. -\subsection{Gaining more control of the backout process} +$B%P%C%/%"%&%H$7$h$&$H$9$k%A%'%s%8%;%C%H$,%A%C%W$+%A%C%W$G$J$$$+$K$+JQ$o$i(B +$B$:!$(B\hgcmd{backout}$B%3%^%s%I$r;H$*$&$H$9$k;~$O(B\emph{$B>o$K(B} +\hgopt{backout}{--merge}$B%*%W%7%g%s$r;H$&$Y$-$G$"$k!%BP>]$,%A%C%W$G$"$k>l(B +$B9g$OITMW$J%^!<%8$r;n$_$k$3$H$O$J$$$?$a!$>o$K$3$N%*%W%7%g%s$r;XDj$7$FLdBj(B +$B$J$$!%(B + + +%\subsection{Gaining more control of the backout process} +\subsection{$B%P%C%/%"%&%H%W%m%;%9$r$h$j:Y$+$/@)8f$9$k(B} While I've recommended that you always use the \hgopt{backout}{--merge} option when backing out a change, the