Mercurial > hgbook
changeset 306:62ea8107a73b
more undo.tex
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Tue, 12 Feb 2008 02:39:14 +0900 |
parents | 8202b13f7707 |
children | bb4c3994cec7 |
files | ja/undo.tex |
diffstat | 1 files changed, 115 insertions(+), 54 deletions(-) [+] |
line wrap: on
line diff
--- a/ja/undo.tex Sat Feb 09 00:33:04 2008 +0900 +++ b/ja/undo.tex Tue Feb 12 02:39:14 2008 +0900 @@ -606,79 +606,140 @@ \label{fig:undo:backout-manual} \end{figure} -After the \hgcmd{backout} command has completed, it leaves the new -``backout'' changeset as the parent of the working directory. +%After the \hgcmd{backout} command has completed, it leaves the new +%``backout'' changeset as the parent of the working directory. +%\interaction{backout.manual.parents} +%Now we have two isolated sets of changes. +%\interaction{backout.manual.heads} + +\hgcmd{backout}$B%3%^%s%I$O!$40N;$7$?8e!$%P%C%/%"%&%H%A%'%s%8%;%C%H$r%o!<%-(B +$B%s%0%G%#%l%/%H%j$N?F$H$7$F;D$9!%(B \interaction{backout.manual.parents} -Now we have two isolated sets of changes. +$B$3$3$G(B2$B$D$N3VN%$5$l$?JQ99$N%;%C%H$,B8:_$9$k$3$H$K$J$k!%(B \interaction{backout.manual.heads} -Let's think about what we expect to see as the contents of -\filename{myfile} now. The first change should be present, because -we've never backed it out. The second change should be missing, as -that's the change we backed out. Since the history graph shows the -third change as a separate head, we \emph{don't} expect to see the -third change present in \filename{myfile}. + +%Let's think about what we expect to see as the contents of +%\filename{myfile} now. The first change should be present, because +%we've never backed it out. The second change should be missing, as +%that's the change we backed out. Since the history graph shows the +%third change as a separate head, we \emph{don't} expect to see the +%third change present in \filename{myfile}. +%\interaction{backout.manual.cat} +%To get the third change back into the file, we just do a normal merge +%of our two heads. +%\interaction{backout.manual.merge} +%Afterwards, the graphical history of our repository looks like +%figure~\ref{fig:undo:backout-manual-merge}. + +$B:#$3$3$G(B\filename{myfile}$B$NFbMF$r8+$?$$$H$9$k!%:G=i$NJQ99$O%P%C%/%"%&%H$7(B +$B$F$$$J$$$N$GB8:_$7$F$$$k$O$:$G$"$k!%(B2$BHVL\$NJQ99$O%P%C%/%"%&%H$7$?$N$G>C(B +$B$($FL5$/$J$C$F$$$k$O$:$@!%(B3$BHVL\$NJQ99$OMzNr%0%i%U$GJ,N%$7$?%X%C%I$H$7$F(B +$BI=<($5$l$k$?$a!$(B3$BHVL\$NJQ99$,(B\filename{myfile}$B$K$"$k$H$O4|BT$7$F$$$J$$!%(B \interaction{backout.manual.cat} -To get the third change back into the file, we just do a normal merge -of our two heads. +3$BHVL\$NJQ99$r%U%!%$%k$KH?1G$5$;$k$?$a$K$O!$(B2$B$D$N%X%C%I$r%^!<%8$7$F$d$l$P(B +$B$h$$!%(B \interaction{backout.manual.merge} -Afterwards, the graphical history of our repository looks like -figure~\ref{fig:undo:backout-manual-merge}. +$B$=$N8e$G$O%j%]%8%H%j$NMzNr$N%0%i%U$O?^(B +\ref{fig:undo:backout-manual-merge}$B$N$h$&$K$J$k(B \begin{figure}[htb] \centering \grafix{undo-manual-merge} - \caption{Manually merging a backout change} +% \caption{Manually merging a backout change} + \caption{$B%P%C%/%"%&%H%A%'%s%8$N<jF0$K$h$k%^!<%8(B} \label{fig:undo:backout-manual-merge} \end{figure} -\subsection{Why \hgcmd{backout} works as it does} +%\subsection{Why \hgcmd{backout} works as it does} +\subsection{$B$J$<(B\hgcmd{backout}$B$O$3$N$h$&$KF0:n$9$k$N$+(B} -Here's a brief description of how the \hgcmd{backout} command works. +%Here's a brief description of how the \hgcmd{backout} command works. +%\begin{enumerate} +%\item It ensures that the working directory is ``clean'', i.e.~that +% the output of \hgcmd{status} would be empty. +%\item It remembers the current parent of the working directory. Let's +% call this changeset \texttt{orig} +%\item It does the equivalent of a \hgcmd{update} to sync the working +% directory to the changeset you want to back out. Let's call this +% changeset \texttt{backout} +%\item It finds the parent of that changeset. Let's call that +% changeset \texttt{parent}. +%\item For each file that the \texttt{backout} changeset affected, it +% does the equivalent of a \hgcmdargs{revert}{-r parent} on that file, +% to restore it to the contents it had before that changeset was +% committed. +%\item It commits the result as a new changeset. This changeset has +% \texttt{backout} as its parent. +%\item If you specify \hgopt{backout}{--merge} on the command line, it +% merges with \texttt{orig}, and commits the result of the merge. +%\end{enumerate} + +\hgcmd{backout}$B$,$I$N$h$&$KF0:n$9$k$+407k$K@bL@$9$k$H0J2<$N$h$&$K$J$k!%(B \begin{enumerate} -\item It ensures that the working directory is ``clean'', i.e.~that - the output of \hgcmd{status} would be empty. -\item It remembers the current parent of the working directory. Let's - call this changeset \texttt{orig} -\item It does the equivalent of a \hgcmd{update} to sync the working - directory to the changeset you want to back out. Let's call this - changeset \texttt{backout} -\item It finds the parent of that changeset. Let's call that - changeset \texttt{parent}. -\item For each file that the \texttt{backout} changeset affected, it - does the equivalent of a \hgcmdargs{revert}{-r parent} on that file, - to restore it to the contents it had before that changeset was - committed. -\item It commits the result as a new changeset. This changeset has - \texttt{backout} as its parent. -\item If you specify \hgopt{backout}{--merge} on the command line, it - merges with \texttt{orig}, and commits the result of the merge. + \item $B%o!<%-%s%0%G%#%l%/%H%j$,%/%j!<%s$G$"$k$3$H$r3NG'$9$k!%(Bi.e.\hgcmd{status} + $B$,6u$G$"$k$3$H$r3NG'$9$k(B + \item $B8=:_$N%o!<%-%s%0%G%#%l%/%H%j$N?F$r5-21$9$k$3$N%A%'%s%8%;%C%H$r(B + \texttt{orig}$B$H8F$V$3$H$K$9$k!%(B + \item $B%o!<%-%s%0%G%#%l%/%H%j$r!$%P%C%/%"%&%H$7$?%A%'%s%8%;%C%H$NFbMF$K(B + $B$9$k$?$a$K(B\hgcmd{update}$B$HEy2A$JF0:n$r9T$J$&!%$3$N%A%'%s%8%;%C%H(B + $B$r(B\texttt{backout}$B$H8F$V!%(B + \item $B$=$N%A%'%s%8%;%C%H$N?F$r8+$D$1=P$9$3$N%A%'%s%8%;%C%H$r(B + \texttt{parent}$B$H8F$V$3$H$K$9$k!%(B + \item \texttt{backout}$B%A%'%s%8%;%C%H$,1F6A$9$k3F!9$N%U%!%$%k$KBP$7$F!$(B + \hgcmdargs{revert}{-r parent}$B$HEy2A$JA`:n$r9T$$!$%A%'%s%8%;%C%H$,(B + $B%3%_%C%H$5$l$kA0$N>uBV$KLa$9!%(B + \item $B?7$7$$%A%'%s%8%;%C%H$N7k2L$r%3%_%C%H$9$k!%$3$N%A%'%s%8%;%C%H$O(B + \texttt{backout}$B$r?F$K;}$D!%(B + \item \hgopt{backout}{--merge}$B$r%3%^%s%I%i%$%s$+$iF~NO$7$?>l9g!$(B + \texttt{orig}$B$H$N%^!<%8$r9T$J$$!$7k2L$r%3%_%C%H$9$k!%(B \end{enumerate} -An alternative way to implement the \hgcmd{backout} command would be -to \hgcmd{export} the to-be-backed-out changeset as a diff, then use -the \cmdopt{patch}{--reverse} option to the \command{patch} command to -reverse the effect of the change without fiddling with the working -directory. This sounds much simpler, but it would not work nearly as -well. +%An alternative way to implement the \hgcmd{backout} command would be +%to \hgcmd{export} the to-be-backed-out changeset as a diff, then use +%the \cmdopt{patch}{--reverse} option to the \command{patch} command to +%reverse the effect of the change without fiddling with the working +%directory. This sounds much simpler, but it would not work nearly as +%well. -The reason that \hgcmd{backout} does an update, a commit, a merge, and -another commit is to give the merge machinery the best chance to do a -good job when dealing with all the changes \emph{between} the change -you're backing out and the current tip. +\hgcmd{backout}$B%3%^%s%I$r<BAu$9$kJL$NJ}K!$H$7$F!$(B\hgcmd{export}$B$G%P%C%/%"(B +$B%&%H$5$l$k$Y$-%A%'%s%8%;%C%H$r(Bdiff$B$H$7$F=PNO$7!$(B +\command{patch}$B$r(B}\cmdopt{patch}{--reverse}$B%*%W%7%g%sIU$-$G8F$S!$%o!<%-%s(B +$B%0%G%#%l%/%H%j$NA`:n$r>JN,$7$F%j%P!<%9%Q%C%A$9$kJ}K!$,9M$($i$l$k!%(B +$B$3$NJ}K!$O$:$C$HC1=c$@$,!$$[$H$s$I$&$^$/F0$+$J$$!%(B + +%The reason that \hgcmd{backout} does an update, a commit, a merge, and +%another commit is to give the merge machinery the best chance to do a +%good job when dealing with all the changes \emph{between} the change +%you're backing out and the current tip. + +\hgcmd{backout}$B$,%"%C%W%G!<%H!$%3%_%C%H!$%^!<%8!$%3%_%C%H$r9T$J$&M}M3$O!$(B +$B%P%C%/%"%&%H$9$Y$-JQ99$H8=:_$N%A%C%W$N4V$G!$%^!<%85!9=$,:G$bNI$$7k2L$rF@(B +$B$i$l$k$h$&$K$9$k$?$a$G$"$k!%(B -If you're backing out a changeset that's~100 revisions back in your -project's history, the chances that the \command{patch} command will -be able to apply a reverse diff cleanly are not good, because -intervening changes are likely to have ``broken the context'' that -\command{patch} uses to determine whether it can apply a patch (if -this sounds like gibberish, see \ref{sec:mq:patch} for a -discussion of the \command{patch} command). Also, Mercurial's merge -machinery will handle files and directories being renamed, permission -changes, and modifications to binary files, none of which -\command{patch} can deal with. +%If you're backing out a changeset that's~100 revisions back in your +%project's history, the chances that the \command{patch} command will +%be able to apply a reverse diff cleanly are not good,because +%intervening changes are likely to have ``broken the context'' that +%\command{patch} uses to determine whether it can apply a patch (if +%this sounds like gibberish, see \ref{sec:mq:patch} for a +%discussion of the \command{patch} command). +%Also, Mercurial's merge machinery will handle files and directories +%being renamed, permission changes, and modifications to binary files, +%none of which \command{patch} can deal with. -\section{Changes that should never have been} +$B$b$7%W%m%8%'%/%H$NMzNr$NCf$G(B100$B%j%S%8%g%s$bAL$k$h$&$J%A%'%s%8%;%C%H$r%P%C(B +$B%/%"%&%H$9$k$H$9$l$P!$(B\command{patch}$B$,(Bdiff$B$rE,MQ$G$-$k2DG=@-$OL@$i$+$KDc(B +$B$$!%4V$K$"$kJQ99$,!$(B\command{patch}$B%3%^%s%I$,%Q%C%AE,MQ$N2DH]$rH=CG$9$k$?(B +$B$a$NJ8L.$r2u$7$F$$$k2DG=@-$,9b$$$+$i$G$"$k!%!J$3$NOC$,J,$+$i$J$$>l9g$O(B +\ref{sec:mq:patch}$B$N(B\command{patch}$B%3%^%s%I$K4X$9$k5DO@$r;2>H$7$FM_$7$$!%!K(B +$B$^$?!$(BMercurial$B$N%^!<%85!9=$O!$(B\command{patch}$B%3%^%s%I$,07$($J$$%U%!%$%k(B +$B$H%G%#%l%/%H%j$N%j%M!<%`!$%Q!<%_%C%7%g%sJQ99!$%P%$%J%j%U%!%$%k$X$NJQ99$J(B +$B$I$r07$&$3$H$,$G$-$k!%(B + + +%\section{Changes that should never have been} +\section{$B$9$Y$-$G$J$$JQ99(B} \label{sec:undo:aaaiiieee} Most of the time, the \hgcmd{backout} command is exactly what you need