Mercurial > hgbook
comparison ja/undo.tex @ 307:bb4c3994cec7
more undo.tex
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Tue, 12 Feb 2008 06:09:08 +0900 |
parents | 62ea8107a73b |
children | dd775100013d |
comparison
equal
deleted
inserted
replaced
306:62ea8107a73b | 307:bb4c3994cec7 |
---|---|
737 $B$H%G%#%l%/%H%j$N%j%M!<%`!$%Q!<%_%C%7%g%sJQ99!$%P%$%J%j%U%!%$%k$X$NJQ99$J(B | 737 $B$H%G%#%l%/%H%j$N%j%M!<%`!$%Q!<%_%C%7%g%sJQ99!$%P%$%J%j%U%!%$%k$X$NJQ99$J(B |
738 $B$I$r07$&$3$H$,$G$-$k!%(B | 738 $B$I$r07$&$3$H$,$G$-$k!%(B |
739 | 739 |
740 | 740 |
741 %\section{Changes that should never have been} | 741 %\section{Changes that should never have been} |
742 \section{$B$9$Y$-$G$J$$JQ99(B} | 742 \section{$BB8:_$9$Y$-$G$J$$JQ99(B} |
743 \label{sec:undo:aaaiiieee} | 743 \label{sec:undo:aaaiiieee} |
744 | 744 |
745 Most of the time, the \hgcmd{backout} command is exactly what you need | 745 %Most of the time, the \hgcmd{backout} command is exactly what you need |
746 if you want to undo the effects of a change. It leaves a permanent | 746 %if you want to undo the effects of a change. It leaves a permanent |
747 record of exactly what you did, both when committing the original | 747 %record of exactly what you did, both when committing the original |
748 changeset and when you cleaned up after it. | 748 %changeset and when you cleaned up after it. |
749 | 749 |
750 On rare occasions, though, you may find that you've committed a change | 750 $BBgDq$N>l9g!$(B\hgcmd{backout}$B$O$"$kJQ99$r<h$j>C$=$&$H$9$k:]$K;W$C$?$h$&$K5!(B |
751 that really should not be present in the repository at all. For | 751 $BG=$9$k$O$:$G$"$k!%85!9$N%3%_%C%H$d$=$l$r<h$j=|$$$?;~$K2?$r$7$?$N$+1JB3E*(B |
752 example, it would be very unusual, and usually considered a mistake, | 752 $B$J5-21$,;D$5$l$k!%(B |
753 to commit a software project's object files as well as its source | 753 |
754 files. Object files have almost no intrinsic value, and they're | 754 %On rare occasions, though, you may find that you've committed a change |
755 \emph{big}, so they increase the size of the repository and the amount | 755 %that really should not be present in the repository at all. For |
756 of time it takes to clone or pull changes. | 756 %example, it would be very unusual, and usually considered a mistake, |
757 | 757 %to commit a software project's object files as well as its source |
758 Before I discuss the options that you have if you commit a ``brown | 758 %files.Object files have almost no intrinsic value, and they're |
759 paper bag'' change (the kind that's so bad that you want to pull a | 759 %\emph{big}, so they increase the size of the repository and the amount |
760 brown paper bag over your head), let me first discuss some approaches | 760 %of time it takes to clone or pull changes. |
761 that probably won't work. | 761 |
762 | 762 $B$=$l$G$b$?$^$K%j%]%8%H%j$KA4$/;D$7$?$/$J$$JQ99$r%3%_%C%H$7$F$7$^$&$3$H$,(B |
763 Since Mercurial treats history as accumulative---every change builds | 763 $B$"$k!%$?$H$($P!$Hs>o$KJQ$J%3%_%C%H$d!$DL>o%_%9$H9M$($i$l$k$h$&$J%3%_%C%H!$(B |
764 on top of all changes that preceded it---you generally can't just make | 764 $B%=!<%9$@$1$G$O$J$/%W%m%8%'%/%H$N%*%V%8%'%/%H%U%!%$%k$b%3%_%C%H$7$F$7$^$&(B |
765 disastrous changes disappear. The one exception is when you've just | 765 $B$J$I$,M-$jF@$k!%%*%V%8%'%/%H%U%!%$%k$O8GM-$NCM$r;}$AF@$:!$$+$D(B\emph{$BBg$-(B |
766 committed a change, and it hasn't been pushed or pulled into another | 766 $B$$(B}$B!%$=$N$?$a!$%j%]%8%H%j$N%5%$%:$rA}$d$7!$%/%m!<%s$d%W%k$KM>7W$J;~4V$,3](B |
767 repository. That's when you can safely use the \hgcmd{rollback} | 767 $B$+$k$h$&$K$J$k!%(B |
768 command, as I detailed in section~\ref{sec:undo:rollback}. | 768 |
769 | 769 %Before I discuss the options that you have if you commit a ``brown |
770 After you've pushed a bad change to another repository, you | 770 %paper bag'' change (the kind that's so bad that you want to pull a |
771 \emph{could} still use \hgcmd{rollback} to make your local copy of the | 771 %brown paper bag over your head), let me first discuss some approaches |
772 change disappear, but it won't have the consequences you want. The | 772 %that probably won't work. |
773 change will still be present in the remote repository, so it will | 773 |
774 reappear in your local repository the next time you pull. | 774 $BCc?'$N;fB^%3%_%C%H!JCc?'$N;fB^$rF,$KHo$j$?$$$0$i$$%P%D$N0-$$%3%_%C%H!K$K(B |
775 | 775 $B;H$($k%*%W%7%g%s$K$D$$$F5DO@$9$kA0$K!$$$$/$D$+$N$&$^$/9T$+$J$$%"%W%m!<%A(B |
776 If a situation like this arises, and you know which repositories your | 776 $B$r=R$Y$?$$!%(B |
777 bad change has propagated into, you can \emph{try} to get rid of the | 777 |
778 changeefrom \emph{every} one of those repositories. This is, of | 778 %Since Mercurial treats history as accumulative---every change builds |
779 course, not a satisfactory solution: if you miss even a single | 779 %on top of all changes that preceded it---you generally can't just make |
780 repository while you're expunging, the change is still ``in the | 780 %disastrous changes disappear. The one exception is when you've just |
781 wild'', and could propagate further. | 781 %committed a change, and it hasn't been pushed or pulled into another |
782 | 782 %repository. That's when you can safely use the \hgcmd{rollback} |
783 If you've committed one or more changes \emph{after} the change that | 783 %command, as I detailed in section~\ref{sec:undo:rollback}. |
784 you'd like to see disappear, your options are further reduced. | 784 |
785 Mercurial doesn't provide a way to ``punch a hole'' in history, | 785 Mercurial$B$OMzNr$rN_@QE*$J$b$N$H$7$F07$&!%A4$F$NJQ99$O$=$l$K@hN)$DA4$F$NJQ(B |
786 leaving changesets intact. | 786 $B99$N>e$K$J$j$?$C$F$$$k!%0lHLE*$K8@$C$FGK2uE*$JJQ99$r2sHr$9$k$3$H$O$G$-$J(B |
787 | 787 $B$$!%$?$C$?0l$D$NNc30$O%3%_%C%H$r9T$J$C$?D>8e$G!$B>$N%j%]%8%H%j$K%W%C%7%e(B |
788 XXX This needs filling out. The \texttt{hg-replay} script in the | 788 $B$b%W%k$b$5$l$F$$$J$$>l9g$G$"$k!%$=$N>l9g!$(B\ref{sec:undo:rollback}$B$N%;%/%7%g(B |
789 \texttt{examples} directory works, but doesn't handle merge | 789 $B%s$G>\$7$/?($l$?$h$&$K!$0BA4$K(B\hgcmd{rollback}$B$r<B9T$9$k$3$H$,$G$-$k!%(B |
790 changesets. Kind of an important omission. | 790 |
791 | 791 %After you've pushed a bad change to another repository, you \emph{could} |
792 \subsection{Protect yourself from ``escaped'' changes} | 792 %still use \hgcmd{rollback} to make your local copy of the change |
793 | 793 %disappear, but it won't have the consequences you want. The change will |
794 If you've committed some changes to your local repository and they've | 794 %still be present in the remote repository, so it will reappear in your |
795 been pushed or pulled somewhere else, this isn't necessarily a | 795 %local repository the next time you pull. |
796 disaster. You can protect yourself ahead of time against some classes | 796 |
797 of bad changeset. This is particularly easy if your team usually | 797 $B4V0c$C$?JQ99$rB>$N%j%]%8%H%j$K%W%C%7%e$7$?8e$G$b%m!<%+(B |
798 pulls changes from a central repository. | 798 $B%k%3%T!<$NJQ99$r<h$j>C$9$?$a$K0MA3$H$7$F(B\hgcmd{rollback}$B$r;H$&$3$H$,(B |
799 | 799 \emph{$B$G$-$k(B}$B$,!$$3$l$O0U?^$7$?$h$&$J7k2L$K$O$J$i$J$$!%JQ99$O0MA3$H$7$F(B |
800 By configuring some hooks on that repository to validate incoming | 800 $B%j%b!<%H$N%j%]%8%H%j$K$O$=$s$6$$$7$F$*$j!$<!$K%W%k$7$?;~$K$O%m!<%+%k%j%](B |
801 changesets (see chapter~\ref{chap:hook}), you can automatically | 801 $B%8%H%j$K$b8=$l$k!%(B |
802 prevent some kinds of bad changeset from being pushed to the central | 802 |
803 repository at all. With such a configuration in place, some kinds of | 803 %If a situation like this arises, and you know which repositories your |
804 bad changeset will naturally tend to ``die out'' because they can't | 804 %bad change has propagated into, you can \emph{try} to get rid of the |
805 propagate into the central repository. Better yet, this happens | 805 %changee from \emph{every} one of those repositories. This is, of |
806 without any need for explicit intervention. | 806 %course, not a satisfactory solution: if you miss even a single |
807 | 807 %repository while you're expunging, the change is still ``in the |
808 For instance, an incoming change hook that verifies that a changeset | 808 %wild'', and could propagate further. |
809 will actually compile can prevent people from inadvertantly ``breaking | 809 |
810 the build''. | 810 $B$3$N$h$&$J>u67$K$J$C$?;~!$$b$7$I$N%j%]%8%H%j$K$3$N4V0c$C$?JQ99$,GH5Z$7$F(B |
811 $B$$$k$N$+$,L@$i$+$G$"$l$P!$$=$l$i$N%j%]%8%H%j$N0l$D0l$D$+$i!$JQ99$r<h$j=|(B | |
812 $B$/$3$H$r;n$_$k$3$H$,$G$-$k!%$3$l$O$b$A$m$sK~B-$N$$$/2r7hK!$G$O$J$$!%$b$7(B | |
813 $B0l$D$G$b>C5n$rK:$l$l$P!$JQ99$OLnJ|$7$K$J$C$F$*$j!$$5$i$K3H$,$jF@$k!%(B | |
814 | |
815 %If you've committed one or more changes \emph{after} the change that | |
816 %you'd like to see disappear, your options are further reduced. | |
817 %Mercurial doesn't provide a way to ``punch a hole'' in history, | |
818 %leaving changesets intact. | |
819 | |
820 $B$b$7(B1$B$D0J>e$N?7$?$JJQ99$r!$>C$7$?$$$H;W$C$F$$$kJQ99$N8e$K%3%_%C%H$7$F$$(B | |
821 $B$?$H$9$l$P!$;H$($k%*%W%7%g%s$O$5$i$K>/$J$/$J$k!%(BMercurial$B$O%A%'%s%8%;%C(B | |
822 $B%H$r$=$N$^$^$KMzNr$K7j$r3+$1$k$h$&$JJ}K!$rDs6!$7$F$$$J$$!%(B | |
823 | |
824 %XXX This needs filling out. The \texttt{hg-replay} script in the | |
825 %\texttt{examples} directory works, but doesn't handle merge | |
826 %changesets. Kind of an important omission. | |
827 | |
828 XXX $BDI5-$NI,MW@-$"$j!%(B\texttt{examples}$B%G%#%l%/%H%jFb$N(B | |
829 \texttt{hg-replay}$B%9%/%j%W%H$O5!G=$9$k$,!$%A%'%s%8%;%C%H$N%^!<%8$r07$o$J(B | |
830 $B$$!%=EMW$J@)8B$G$"$k!%(B | |
831 | |
832 | |
833 %\subsection{Protect yourself from ``escaped'' changes} | |
834 \subsection{$B0oC&$7$?JQ99$+$i<+J,<+?H$r<i$k(B} | |
835 | |
836 %If you've committed some changes to your local repository and they've | |
837 %been pushed or pulled somewhere else, this isn't necessarily a | |
838 %disaster. You can protect yourself ahead of time against some classes | |
839 %of bad changeset. This is particularly easy if your team usually | |
840 %pulls changes from a central repository. | |
841 | |
842 $B%m!<%+%k%j%]%8%H%j$K$$$/$D$+$NJQ99$r%3%_%C%H$7!$$=$l$i$,JL$N=j$K%W%C%7%e(B | |
843 $B$^$?$O%W%k$5$l$F$$$F!$I,$:$7$bBg:R32$H$O8@$($J$$!%$"$J$?$O$$$/$D$+$N%/%i(B | |
844 $B%9$N4V0c$C$?JQ99$+$i<+J,<+?H$G$_$r<i$k$3$H$,$G$-$k!%$3$l$O$"$J$?$N%A!<%`(B | |
845 $B$,Cf1{$N%j%]%8%H%j$+$iJQ99$r%W%k$7$F$$$k>l9g$OFC$K4JC1$G$"$k!%(B | |
846 | |
847 %By configuring some hooks on that repository to validate incoming | |
848 %changesets (see chapter~\ref{chap:hook}), you can automatically | |
849 %prevent some kinds of bad changeset from being pushed to the central | |
850 %repository at all. With such a configuration in place, some kinds of | |
851 %bad changeset will naturally tend to ``die out'' because they can't | |
852 %propagate into the central repository. | |
853 %Better yet, this happens without any need for explicit intervention. | |
854 | |
855 $BCf1{%j%]%8%H%j$N>e$G!$JQ99E~Ce$K%U%C%/$r@_Dj$9$k!J(B\ref{chap:hook}$B$r;2>H!K(B | |
856 $B$3$H$G!$$"$k<o$N8m$C$?%A%'%s%8%;%C%H$,Cf1{%j%]%8%H%j$K%3%_%C%H$5$l$k$N$r(B | |
857 $B<+F0E*$KKI$0$3$H$,$G$-$k!%(B | |
858 $B$=$N$h$&$J@_Dj$r9T$&$3$H$G!$$"$k<o$N8m$C$?%A%'%s%8%;%C%H$O%;%s%H%i%k%j%](B | |
859 $B%8%H%j$KGH5Z$9$k$3$H$,$G$-$:!$;`LG$7$F$$$/798~$,$"$k!%$5$i$KNI$$$3$H$H$7(B | |
860 $B$F$O!$$3$l$OL@<(E*$K2pF~$;$:$KH/@8$5$;$k$3$H$,$G$-$k$3$H$,$"$k!%(B | |
861 | |
862 %For instance, an incoming change hook that verifies that a changeset | |
863 %will actually compile can prevent people from inadvertantly ``breaking | |
864 %the build''. | |
865 | |
866 $BNc$($P!$%A%'%s%8%;%C%H$r<B:]$K%3%s%Q%$%k$9$kJQ99E~Ce%U%C%/$O!$ITCm0U$K$h(B | |
867 $B$k%S%k%IITG=$rKI$0$3$H$,$G$-$k!%(B | |
811 | 868 |
812 \section{Finding the source of a bug} | 869 \section{Finding the source of a bug} |
813 \label{sec:undo:bisect} | 870 \label{sec:undo:bisect} |
814 | 871 |
815 While it's all very well to be able to back out a changeset that | 872 While it's all very well to be able to back out a changeset that |