Mercurial > hgbook
annotate ja/tour-merge.tex @ 837:b775f963b18c
Clean up chapter 8, and add content
propagate 7226e5e750a6
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Tue, 15 Sep 2009 22:32:03 +0900 |
parents | 8a3041e6f3cb |
children |
rev | line source |
---|---|
365 | 1 %\chapter{A tour of Mercurial: merging work} |
2 \chapter{Mercurial$B%D%"!<(B: $B%^!<%8(B} | |
95
47ea206351d5
Split tour into two sections.
Bryan O'Sullivan <bos@serpentine.com>
parents:
94
diff
changeset
|
3 \label{chap:tour-merge} |
94 | 4 |
365 | 5 %We've now covered cloning a repository, making changes in a |
6 %repository, and pulling or pushing changes from one repository into | |
7 %another. Our next step is \emph{merging} changes from separate | |
8 %repositories. | |
9 | |
10 $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 | |
11 $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 | |
12 $B%8%H%j$+$iJQ99$r(B\emph{$B%^!<%8(B}$B$9$k$3$H$G$"$k!%(B | |
94 | 13 |
365 | 14 %\section{Merging streams of work} |
15 \section{$BJ#?t$N:n6H7k2L$r%^!<%8$9$k(B} | |
16 | |
17 %Merging is a fundamental part of working with a distributed revision | |
18 %control tool. | |
19 | |
20 $B%^!<%8$OJ,;6%j%S%8%g%s%3%s%H%m!<%k%D!<%k$G$N:n6H$K$*$$$FIT2D7g$NItJ,$G$"(B | |
21 $B$k!%(B | |
95
47ea206351d5
Split tour into two sections.
Bryan O'Sullivan <bos@serpentine.com>
parents:
94
diff
changeset
|
22 |
94 | 23 \begin{itemize} |
365 | 24 %\item Alice and Bob each have a personal copy of a repository for a |
25 | |
26 % project they're collaborating on. Alice fixes a bug in her | |
27 % repository; Bob adds a new feature in his. They want the shared | |
28 % repository to contain both the bug fix and the new feature. | |
29 \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 | |
30 $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 | |
31 $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 | |
32 $B$?$$$H9M$($F$$$k!%(B | |
33 | |
34 %\item I frequently work on several different tasks for a single | |
35 % project at once, each safely isolated in its own repository. | |
36 % Working this way means that I often need to merge one piece of my | |
37 % own work with another. | |
38 \item $B;d$O0l$D$N%W%m%8%'%/%H$NJL!9$N%?%9%/$KBP$7$FF1;~$K:n6H$r9T$&$3$H$r(B | |
39 $B$h$/9T$C$F$$$k!%$3$N$h$&$J:n6H%9%?%$%k$G$O!$<+J,$N:n6H$N0l$D$+$iJL(B | |
40 $B$N:n6H$N0l$D$X7k2L$r%^!<%8$7$?$$$H;W$&$3$H$,$7$P$7$P$"$k!%(B | |
41 | |
94 | 42 \end{itemize} |
43 | |
365 | 44 %Because merging is such a common thing to need to do, Mercurial makes |
45 %it easy. Let's walk through the process. We'll begin by cloning yet | |
46 %another repository (see how often they spring up?) and making a change | |
47 %in it. | |
48 | |
49 $B>e$G=R$Y$?$h$&$K%^!<%8$r9T$$$?$$>u67$O$H$F$bB?$$$?$a!$(B Mercurial$B$G$O%^!<(B | |
50 $B%8$r4JC1$K9T$($k$h$&$K$J$C$F$$$k!%$^$:JL$N%j%]%8%H%j$r%/%m!<%s$7!$JQ99$r(B | |
51 $B2C$($k$H$3$m$+$i;O$a$h$&!%(B | |
94 | 52 \interaction{tour.merge.clone} |
365 | 53 |
54 %We should now have two copies of \filename{hello.c} with different | |
55 %contents. The histories of the two repositories have also diverged, | |
56 %as illustrated in figure~\ref{fig:tour-merge:sep-repos}. | |
57 | |
58 $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 | |
59 $B?^(B~\ref{fig:tour-merge:sep-repos}$B$K<($9$h$&$KJ,$+$l$F$$$k!%(B | |
94 | 60 \interaction{tour.merge.cat} |
61 | |
99 | 62 \begin{figure}[ht] |
63 \centering | |
64 \grafix{tour-merge-sep-repos} | |
365 | 65 % \caption{Divergent recent histories of the \dirname{my-hello} and |
66 % \dirname{my-new-hello} repositories} | |
67 \caption{\dirname{my-hello}$B%j%]%8%H%j$H(B\dirname{my-new-hello}$B%j%]%8%H(B | |
68 $B%j$NMzNr$N:90[(B} | |
99 | 69 \label{fig:tour-merge:sep-repos} |
70 \end{figure} | |
71 | |
365 | 72 %We already know that pulling changes from our \dirname{my-hello} |
73 %repository will have no effect on the working directory. | |
74 $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 | |
75 $B1F6A$bM?$($J$$$3$H$r3X$s$@!%(B | |
94 | 76 \interaction{tour.merge.pull} |
365 | 77 %However, the \hgcmd{pull} command says something about ``heads''. |
78 $B$7$+$7(B\hgcmd{pull}$B%3%^%s%I$O(B``heads''$B$K$D$$$F%a%C%;!<%8$rI=<($9$k!%(B | |
94 | 79 |
365 | 80 %\subsection{Head changesets} |
81 \subsection{Head$B%A%'%s%8%;%C%H(B} | |
102 | 82 |
365 | 83 %A head is a change that has no descendants, or children, as they're |
84 %also known. The tip revision is thus a head, because the newest | |
85 %revision in a repository doesn't have any children, but a repository | |
86 %can contain more than one head. | |
835
8a3041e6f3cb
reflect comments by Hiroshi Someya.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
799
diff
changeset
|
87 head$B$O;R$d$=$N;RB9$r;}$?$J$$JQ99$G$"$k!%%j%]%8%H%j$N:G?7$N%j%S%8%g%s$O;R(B |
8a3041e6f3cb
reflect comments by Hiroshi Someya.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
799
diff
changeset
|
88 $B$r;}$?$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(B |
8a3041e6f3cb
reflect comments by Hiroshi Someya.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
799
diff
changeset
|
89 $B$N(Bhead$B$r;}$AF@$k!%(B |
99 | 90 |
91 \begin{figure}[ht] | |
92 \centering | |
93 \grafix{tour-merge-pull} | |
365 | 94 % \caption{Repository contents after pulling from \dirname{my-hello} into |
95 % \dirname{my-new-hello}} | |
96 \caption{\dirname{my-hello}$B$+$i(B\dirname{my-new-hello}$B$X(Bpull$B$7$?$"$H$N(B | |
97 $B%j%]%8%H%j$NFbMF(B} | |
99 | 98 \label{fig:tour-merge:pull} |
99 \end{figure} | |
100 | |
365 | 101 %In figure~\ref{fig:tour-merge:pull}, you can see the effect of the |
102 %pull from \dirname{my-hello} into \dirname{my-new-hello}. The history | |
103 %that was already present in \dirname{my-new-hello} is untouched, but a | |
104 %new revision has been added. By referring to | |
105 %figure~\ref{fig:tour-merge:sep-repos}, we can see that the | |
106 %\emph{changeset ID} remains the same in the new repository, but the | |
107 %\emph{revision number} has changed. (This, incidentally, is a fine | |
108 %example of why it's not safe to use revision numbers when discussing | |
109 %changesets.) We can view the heads in a repository using the | |
110 %\hgcmd{heads} command. | |
111 %\interaction{tour.merge.heads} | |
112 | |
113 $B?^(B~\ref{fig:tour-merge:pull}$B$K(B\dirname{my-hello}$B$+$i(B | |
114 \dirname{my-new-hello}$B$X(Bpull$B$r9T$C$?8z2L$r<($9!%(B \dirname{my-new-hello}$B$K(B | |
115 $B4{$KB8:_$7$?MzNr$OJQ99$5$l$:!$?7$?$K%j%S%8%g%s$,DI2C$5$l$k!%(B | |
116 figure~\ref{fig:tour-merge:sep-repos}$B$r8+$k$H!$?7$7$$%j%]%8%H%j$K$b(B | |
117 \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 | |
118 $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 | |
119 $BHV9f$rMQ$$$k$N$,0BA4$G$J$$$3$H$NNc$K$J$C$F$$$k!%!K%j%]%8%H%jFb$K$"$k(Bhead | |
120 $B$O(B\hgcmd{heads}$B$K$h$C$F8+$k$3$H$,$G$-$k!%(B | |
94 | 121 \interaction{tour.merge.heads} |
102 | 122 |
365 | 123 %\subsection{Performing the merge} |
124 \subsection{$B%^!<%8$r<B9T$9$k(B} | |
102 | 125 |
365 | 126 %What happens if we try to use the normal \hgcmd{update} command to |
127 %update to the new tip? | |
128 %\interaction{tour.merge.update} | |
129 | |
130 $B?7$7$$(Btip$B$X99?7$9$k$?$a$K(B\hgcmd{update}$B$r;H$C$?>l9g2?$,5/$-$k$+!)(B | |
94 | 131 \interaction{tour.merge.update} |
365 | 132 |
133 %Mercurial is telling us that the \hgcmd{update} command won't do a | |
134 %merge; it won't update the working directory when it thinks we might | |
799 | 135 %want to do a merge, unless we force it to do so. Instead, we |
365 | 136 %use the \hgcmd{merge} command to merge the two heads. |
137 %\interaction{tour.merge.merge} | |
138 | |
139 Mercurial$B$O(B\hgcmd{update}$B%3%^%s%I$,%^!<%8$r9T$o$J$$$H%a%C%;!<%8$rI=<($9(B | |
140 $B$k!%(B \hgcmd{update}$B%3%^%s%I$O!$%^!<%8$,I,MW$H9M$($i$l$k>l9g$O!$%f!<%6$,(B | |
141 $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 | |
142 $B0lJ}!$(B\hgcmd{merge}$B%3%^%s%I$O(B2$B$D$N%X%C%I$N%^!<%8$r9T$&!%(B | |
94 | 143 \interaction{tour.merge.merge} |
100
272146fab009
Add yet another illustration of the merge process.
Bryan O'Sullivan <bos@serpentine.com>
parents:
99
diff
changeset
|
144 |
365 | 145 %This updates the working directory so that it contains changes from |
146 %\emph{both} heads, which is reflected in both the output of | |
147 %\hgcmd{parents} and the contents of \filename{hello.c}. | |
148 %\interaction{tour.merge.parents} | |
149 | |
150 $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 | |
151 \emph{$BAPJ}$N(B}head$B$+$i$NJQ99$r4^$`$h$&$K%o!<%-%s%0%G%#%l%/%H%j$,99?7$5$l$k!%(B | |
102 | 152 |
365 | 153 %\subsection{Committing the results of the merge} |
154 \subsection{$B%^!<%87k2L$r%3%_%C%H$9$k(B} | |
102 | 155 |
365 | 156 %Whenever we've done a merge, \hgcmd{parents} will display two parents |
157 %until we \hgcmd{commit} the results of the merge. | |
158 %\interaction{tour.merge.commit} | |
159 | |
835
8a3041e6f3cb
reflect comments by Hiroshi Someya.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
799
diff
changeset
|
160 $B%^!<%8$r9T$&$H!$%^!<%8$N7k2L$r(B\hgcmd{commit}$B$9$k$^$G!$(B\hgcmd{parents}$B$O(B |
8a3041e6f3cb
reflect comments by Hiroshi Someya.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
799
diff
changeset
|
161 $B?F(B2$B$D$rI=<($9$k!%(B |
94 | 162 \interaction{tour.merge.commit} |
365 | 163 |
164 %We now have a new tip revision; notice that it has \emph{both} of | |
165 %our former heads as its parents. These are the same revisions that | |
166 %were previously displayed by \hgcmd{parents}. | |
167 %\interaction{tour.merge.tip} | |
168 | |
169 $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 | |
170 \hgcmd{parents}$B%3%^%s%I$GI=<($7$?$N$HF1$8%j%S%8%g%s$G$"$k!%(B | |
94 | 171 \interaction{tour.merge.tip} |
365 | 172 |
173 %In figure~\ref{fig:tour-merge:merge}, you can see a representation of | |
174 %what happens to the working directory during the merge, and how this | |
175 %affects the repository when the commit happens. During the merge, the | |
176 %working directory has two parent changesets, and these become the | |
177 %parents of the new changeset. | |
94 | 178 |
365 | 179 $B?^(B~\ref{fig:tour-merge:merge}$B$G!$%^!<%8$N4V$K%o!<%-%s%0%G%#%l%/%H%j$K2?$,(B |
180 $B5/$-!$%3%_%C%H$7$?;~$K%j%]%8%H%j$K$I$&1F6A$9$k$N$+$r8+$k$3$H$,$G$-$k!%(B | |
181 $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 | |
182 $B?7$7$$%A%'%s%8%;%C%H$NN>?F$H$J$k!%(B | |
183 | |
799 | 184 \begin{figure}[ht] |
185 \centering | |
186 \grafix{tour-merge-merge} | |
187 % \caption{Working directory and repository during merge, and | |
188 % following commit} | |
189 \caption{$B%^!<%8Cf$N%o!<%-%s%0%G%#%l%/%H%j$H%j%]%8%H%j$*$h$S8eB3$N%3%_%C(B | |
190 $B%H(B} | |
191 \label{fig:tour-merge:merge} | |
192 \end{figure} | |
193 | |
194 %We sometimes talk about a merge having \emph{sides}: the left side is | |
195 %the first parent in the output of \hgcmd{parents}, and the right side is | |
196 %the second. If the working directory was at e.g. revision 5 before we | |
197 %began a merge, that revision will become the left side of the merge. | |
198 | |
199 $B%^!<%8$K$h$j(B\emph{$B%5%$%I(B}$B$,$G$-$k$3$H$,$"$k!%:8$N%5%$%I$O(B\hgcmd{parents} | |
200 $B$N=PNO$N:G=i$N?F$G!$1&$N%5%$%I$,(B2$BHVL\$N?F$G$"$k!%Nc$($P!$%^!<%8A0$K%o!<%-(B | |
201 $B%s%0%G%#%l%/%H%j$,%j%S%8%g%s(B5$B$G$"$C$?$H$9$k$H!$%^!<%8$N:8$N%5%$%I$,$3$N(B | |
202 $B%j%S%8%g%s$K$J$k!%(B | |
203 | |
365 | 204 %\section{Merging conflicting changes} |
205 \section{$B%3%s%U%j%/%H$N$"$kJQ99$r%^!<%8$9$k(B} | |
102 | 206 |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
207 %Most merges are simple affairs, but sometimes you'll find yourself |
799 | 208 %merging changes where each side modifies the same portions of the same |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
209 %files. Unless both modifications are identical, this results in a |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
210 %\emph{conflict}, where you have to decide how to reconcile the |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
211 %different changes into something coherent. |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
212 |
799 | 213 $BBgH>$N%^!<%8$O%7%s%W%k$J$b$N$@$,!$F1$8%U%!%$%k$NF1$82U=j$rJQ99$9$k%A%'%s(B |
214 $B%8%;%C%H$r%^!<%8$7$J$1$l$P$J$i$J$$$3$H$b$"$k!%3F!9$NJQ99$,F1$8FbMF$G$J$$(B | |
215 $B8B$j!$7k2L$O(B\emph{conflict}$B$H$J$k$?$a!$JQ99$r@09g$5$;$k$h$&$K=$@5$9$kI,MW(B | |
216 $B$,$"$k!%(B | |
103 | 217 |
218 \begin{figure}[ht] | |
219 \centering | |
220 \grafix{tour-merge-conflict} | |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
221 % \caption{Conflicting changes to a document} |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
222 \caption{$B%3%s%U%j%/%H$7$?%A%'%s%8%;%C%H(B} |
103 | 223 \label{fig:tour-merge:conflict} |
224 \end{figure} | |
225 | |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
226 %Figure~\ref{fig:tour-merge:conflict} illustrates an instance of two |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
227 %conflicting changes to a document. We started with a single version |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
228 %of the file; then we made some changes; while someone else made |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
229 %different changes to the same text. Our task in resolving the |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
230 %conflicting changes is to decide what the file should look like. |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
231 |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
232 1$B$D$N%I%-%e%a%s%H$KBP$7$F(B2$B$D$N%A%'%s%8%;%C%H$,%3%s%U%j%/%H$7$?MM;R$r(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
233 $B?^(B~\ref{fig:tour-merge:conflict}$B$K<($9!%(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
234 |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
235 $B$3$3$G$O!$$"$k(B1$B$D$N%P!<%8%g%s$N%U%!%$%k$K$$$/$D$+$NJQ99$r2C$(!$F1;~$KJL$N(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
236 $B?M$,JL$NJQ99$rF1$8%F%-%9%H$KBP$7$F2C$($F$$$k!%%A%'%s%8%;%C%H$N%3%s%U%j%/(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
237 $B%H$r2r7h$9$k$?$a!$%U%!%$%k$,$I$&$"$k$Y$-$+$rL@$i$+$K$7$h$&!%(B |
103 | 238 |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
239 %Mercurial doesn't have a built-in facility for handling conflicts. |
799 | 240 %Instead, it runs an external program, usually one that displays some |
241 %kind of graphical conflict resolution interface. By default, Mercurial | |
242 %tries to find one of several different merging tools that are likely to | |
243 %be installed on your system. It first tries a few fully automatic | |
244 %merging tools; if these don't succeed (because the resolution process | |
245 %requires human guidance) or aren't present, it tries a few different | |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
246 %graphical merging tools. |
103 | 247 |
799 | 248 Mercurial$B$OFbB"$N%3%s%U%j%/%H2r7h5!9=$r;}$?$J$$!%$=$NBe$o$j!$2?$i$+$N%0%i(B |
249 $B%U%#%+%k$J%3%s%U%j%/%H2r7h%$%s%?%U%'!<%9$rI=<($9$k30It%3%^%s%I$r5/F0$9(B | |
250 $B$k!%%G%U%)%k%H$G(BMercurial$B$O%7%9%F%`$K%$%s%9%H!<%k$5$l$F$$$k2DG=@-$N9b$$$$(B | |
251 $B$/$D$+$N%^!<%8%D!<%k$rA\$9!%(BMercurial$B$O:G=i$K(B2,3$B$NA4<+F0$N%^!<%8%D!<%k$r(B | |
252 $B;n$9!%$3$l$G$&$^$/$$$+$J$$>l9g!J2r7h%W%m%;%9$K?M$N%,%$%I$,I,MW$J>l9g!K$d(B | |
253 $B%D!<%k$,B8:_$7$J$$>l9g!$%9%/%j%W%H$OJL$N(B2,3$B$N%0%i%U%#%+%k%^!<%8%D!<%k$r;n(B | |
254 $B$9!%(B | |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
255 |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
256 %It's also possible to get Mercurial to run another program or script |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
257 %instead of \command{hgmerge}, by setting the \envar{HGMERGE} |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
258 %environment variable to the name of your preferred program. |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
259 |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
260 $B4D6-JQ?t(B\envar{HGMERGE}$B$K9%$_$N%W%m%0%i%`L>$r$r@_Dj$9$k$3$H$G!$(BMercurial |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
261 $B$,(B\command{hgmerge}$B0J30$N%9%/%j%W%H$r5/F0$9$k$h$&$K$9$k$3$H$b2DG=$G$"$k!%(B |
103 | 262 |
365 | 263 %\subsection{Using a graphical merge tool} |
264 \subsection{$B%0%i%U%#%+%k%^!<%8%D!<%k$N;HMQ(B} | |
103 | 265 |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
266 %My preferred graphical merge tool is \command{kdiff3}, which I'll use |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
267 %to describe the features that are common to graphical file merging |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
268 %tools. You can see a screenshot of \command{kdiff3} in action in |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
269 %figure~\ref{fig:tour-merge:kdiff3}. The kind of merge it is |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
270 %performing is called a \emph{three-way merge}, because there are three |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
271 %different versions of the file of interest to us. The tool thus |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
272 %splits the upper portion of the window into three panes: |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
273 |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
274 $BI.<T$N9%$_$N%0%i%U%#%+%k%^!<%8%D!<%k$O(B\command{kdiff3}$B$J$N$G!$$3$l$r;H$C(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
275 $B$F%0%i%U%#%+%k%U%!%$%k%^!<%8%D!<%k$N5!G=$r@bL@$9$k!%(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
276 $B?^(B~\ref{fig:tour-merge:kdiff3}$B$K(B\command{kdiff3}$B$N<B:]$NF0:n$N%9%/%j!<%s(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
277 $B%7%g%C%H$r<($9!%:#CmL\$7$F$$$k%U%!%$%k$K$O(B3$B$D$N0[$J$C$?%P!<%8%g%s$,$"$k$?(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
278 $B$a!$$3$3$G<B9T$5$l$F$$$k$N$O(B\emph{3way$B%^!<%8(B}$B$G$"$k!%%D!<%k$O%&%#%s%I%&$N(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
279 $B>eIt$r(B3$B$D$N%Z!<%s$KJ,3d$7$F$$$k!%(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
280 |
103 | 281 \begin{itemize} |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
282 %\item At the left is the \emph{base} version of the file, i.e.~the |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
283 % most recent version from which the two versions we're trying to |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
284 % merge are descended. |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
285 \item $B:8$K$"$k$N$O%U%!%$%k$N(B\emph{$B%Y!<%9(B}$B%P!<%8%g%s$G$"$k!%$3$l$O$3$l$+(B |
835
8a3041e6f3cb
reflect comments by Hiroshi Someya.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
799
diff
changeset
|
286 $B$i%^!<%8$7$h$&$H$9$k(B2$B$D$N%P!<%8%g%s$N?F$H$J$k:G$b?7$7$$%P!<%8%g%s(B |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
287 $B$G$"$k!%(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
288 |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
289 %\item In the middle is ``our'' version of the file, with the contents |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
290 % that we modified. |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
291 \item $BCf1{$K$"$k$N$O2f!9$,JQ99$r2C$($?%P!<%8%g%s$G$"$k!%(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
292 |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
293 %\item On the right is ``their'' version of the file, the one that |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
294 % from the changeset that we're trying to merge with. |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
295 \item $B1&$K$"$k$N$OB>$N?M$,JQ99$r2C$($?%P!<%8%g%s$G!$$3$l$+$i%^!<%8$7$h(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
296 $B$&$H$9$k$b$N$G$"$k!%(B |
103 | 297 \end{itemize} |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
298 |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
299 %In the pane below these is the current \emph{result} of the merge. |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
300 %Our task is to replace all of the red text, which indicates unresolved |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
301 %conflicts, with some sensible merger of the ``ours'' and ``theirs'' |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
302 %versions of the file. |
103 | 303 |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
304 $B$3$N2<$N%Z!<%s$K$O%^!<%8$N(B\emph{$B7k2L(B}$B$,$"$k!%@V;z$N9T$O%3%s%U%j%/%H$r<($7(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
305 $B$F$*$j!$2f!9$N%P!<%8%g%s$HB>$N?M$N%P!<%8%g%s$rCm0U?<$/%^!<%8$7$?7k2L$rMQ(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
306 $B$$$F$3$l$i$r$9$Y$FCV$-49$($k!%(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
307 |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
308 %All four of these panes are \emph{locked together}; if we scroll |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
309 %vertically or horizontally in any of them, the others are updated to |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
310 %display the corresponding sections of their respective files. |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
311 |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
312 4$B$D$N%Z!<%s$9$Y$F$O(B\emph{$BF14|(B}$B$7$F$*$j!"$I$l$+$r?bD>$^$?$O?eJ?$K%9%/%m!<(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
313 $B%k$9$k$H!"B>$N(B3$B$D$bBP1~$9$k2U=j$rI=<($9$k$h$&$K99?7$5$l$k!#(B |
102 | 314 |
103 | 315 \begin{figure}[ht] |
316 \centering | |
317 \grafix{kdiff3} | |
365 | 318 % \caption{Using \command{kdiff3} to merge versions of a file} |
319 \caption{$B%U%!%$%k$NJ#?t%j%S%8%g%s$r(B\command{kdiff3}$B$r;H$C$F%^!<%8$9$k(B} | |
103 | 320 \label{fig:tour-merge:kdiff3} |
321 \end{figure} | |
322 | |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
323 %For each conflicting portion of the file, we can choose to resolve |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
324 %the conflict using some combination of text from the base version, |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
325 %ours, or theirs. We can also manually edit the merged file at any |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
326 %time, in case we need to make further modifications. |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
327 |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
328 $B%3%s%U%j%/%H$r2r7h$9$k$?$a$K!$%U%!%$%kCf$N%3%s%U%j%/%H$7$F$$$k$9$Y$F$NIt(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
329 $BJ,$KBP$7$F%Y!<%9%P!<%8%g%s!$2f!9$N%P!<%8%g%s!$JL$N?M!9$N%P!<%8%g%s$N%F%-(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
330 $B%9%H$rAH$_9g$o$;$FMQ$$$k!%$5$i$J$k=$@5$,I,MW$J>l9g$O!$%^!<%8$5$l$?%U%!%$(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
331 $B%k$r<jF0$GJT=8$9$k$3$H$b$G$-$k!%(B |
103 | 332 |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
333 %There are \emph{many} file merging tools available, too many to cover |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
334 %here. They vary in which platforms they are available for, and in |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
335 %their particular strengths and weaknesses. Most are tuned for merging |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
336 %files containing plain text, while a few are aimed at specialised file |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
337 %formats (generally XML). |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
338 |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
339 \emph{$B?t!9$N(B}$B%^!<%8%D!<%k$,MxMQ2DG=$G$"$j!$$=$l$i$r%+%P!<$9$k$3$H$O$G$-$J(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
340 $B$$!%$=$l$i$O!$MxMQ2DG=$J%W%i%C%H%U%)!<%`$,0[$J$j!$$=$l$>$lD9=j$H<eE@$,0[(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
341 $B$J$k!%$[$H$s$I$,%W%l!<%s%F%-%9%H$r%^!<%8$9$k$h$&$K:n$i$l$F$$$k$,!$FCJL$J(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
342 $B%U%!%$%k%U%)!<%^%C%H!J(BXML$B!K$KFC2=$7$F$$$k$b$N$b$"$k!%(B |
103 | 343 |
365 | 344 %\subsection{A worked example} |
345 \subsection{$B<B9TNc(B} | |
103 | 346 |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
347 %In this example, we will reproduce the file modification history of |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
348 %figure~\ref{fig:tour-merge:conflict} above. Let's begin by creating a |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
349 %repository with a base version of our document. |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
350 %\interaction{tour-merge-conflict.wife} |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
351 %We'll clone the repository and make a change to the file. |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
352 %\interaction{tour-merge-conflict.cousin} |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
353 %And another clone, to simulate someone else making a change to the |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
354 %file. (This hints at the idea that it's not all that unusual to merge |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
355 %with yourself when you isolate tasks in separate repositories, and |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
356 %indeed to find and resolve conflicts while doing so.) |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
357 %\interaction{tour-merge-conflict.son} |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
358 %Having created two different versions of the file, we'll set up an |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
359 %environment suitable for running our merge. |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
360 %\interaction{tour-merge-conflict.pull} |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
361 |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
362 $B$3$NNc$G$OA0=R$N?^(B~\ref{fig:tour-merge:conflict}$B$G$NJQ99MzNr$r:F8=$9$k!%(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
363 $BJ8=q$N%Y!<%9%P!<%8%g%s$r4^$`%j%]%8%H%j$r:n@.$9$k$3$H$+$i;O$a$k!%(B |
103 | 364 \interaction{tour-merge-conflict.wife} |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
365 $B%j%]%8%H%j$r%3%T!<$7!$%U%!%$%k$KJQ99$r9T$&!%(B |
103 | 366 \interaction{tour-merge-conflict.cousin} |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
367 $BJL$N?M$,JQ99$r9T$&$N$r%7%_%e%l!<%H$9$k$?$a$K$b$&0l$D$N%/%m!<%s$r:n@.$9(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
368 $B$k!%!JJL!9$N%j%]%8%H%j$K3VN%$7$F9T$C$?:n6H$N7k2L$r%^!<%8$7!$%3%s%U%j%/%H(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
369 $B$r2r>C$9$k$3$H$O>/$7$bDA$7$$$3$H$G$O$J$$$H$$$&;v$,$o$+$k$@$m$&!%(B $B!K(B |
103 | 370 \interaction{tour-merge-conflict.son} |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
371 $B%U%!%$%k$K(B2$B$D$NJL$N%P!<%8%g%s$r:n$j!$%^!<%8$r9T$&$N$KE*2<4D6-$r@_Dj$9$k!%(B |
103 | 372 \interaction{tour-merge-conflict.pull} |
373 | |
799 | 374 %In this example, I'll set \envar{HGMERGE} to tell Mercurial to use the |
375 %non-interactive \command{merge} command. This is bundled with many | |
376 %Unix-like systems. (If you're following this example on your computer, | |
377 %don't bother setting \envar{HGMERGE}.) | |
103 | 378 |
799 | 379 $B$3$NNc$G$O(B\envar{HGMERGE}$B$r@_Dj$7$F!$(BMercurial$B$KHsBPOCE*$J(B |
380 \command{merge}$B%3%^%s%I$r5/F0$5$;$k!%$3$l$OB?$/$N(BUnix$B7O%7%9%F%`$K%P%s%I%k(B | |
381 $B$5$l$F$$$k%3%^%s%I$G$"$k!%!J$3$NNc$r<j85$N%^%7%s$G<B9T$9$k;~$K$O(B | |
382 \envar{HGMERGE}$B$r@_Dj$9$kI,MW$O$J$$!%!K(B | |
103 | 383 |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
384 %Mercurial can tell from the way \command{merge} exits that it wasn't |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
385 %able to merge successfully, so it tells us what commands we'll need to |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
386 %run if we want to redo the merging operation. This could be useful |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
387 %if, for example, we were running a graphical merge tool and quit |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
388 %because we were confused or realised we had made a mistake. |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
389 |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
390 Mercurial$B$O(B\command{merge}$B%3%^%s%I$G@5$7$/%^!<%8$G$-$J$+$C$?>l9g!$$b$&0l(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
391 $BEY%^!<%8$r9T$&$?$a$K$I$N$h$&$K$9$l$P$$$$$N$+$rI=<($9$k!%$3$l$O!$%0%i%U%#(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
392 $B%+%k%^!<%8%D!<%k$N;HMQCf$K:.Mp$rMh$7$?$+4V0c$$$rHH$7$?$3$H$K5$IU$$$?$?$a(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
393 $B$K=*N;$7$?>l9g$J$I$KM-8z$G$"$m$&!%(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
394 |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
395 %If automatic or manual merges fail, there's nothing to prevent us from |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
396 %``fixing up'' the affected files ourselves, and committing the results |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
397 %of our merge: |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
398 %\interaction{tour-merge-conflict.commit} |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
399 |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
400 $B<+F0$^$?$O<jF0$K$h$k%^!<%8$,<:GT$7$?>l9g!$1F6A$r<u$1$k%U%!%$%k$r(B``$B=$@5(B'' |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
401 $B$7$F%^!<%8$N7k2L$r%3%_%C%H$7$J$1$l$P$J$i$J$$!%(B |
103 | 402 \interaction{tour-merge-conflict.commit} |
403 | |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
404 |
365 | 405 %\section{Simplifying the pull-merge-commit sequence} |
406 \section{pull-merge-commit$B<j=g$r4JC1$K$9$k(B} | |
224
34943a3d50d6
Start writing up extensions. Begin with inotify.
Bryan O'Sullivan <bos@serpentine.com>
parents:
103
diff
changeset
|
407 \label{sec:tour-merge:fetch} |
102 | 408 |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
409 %The process of merging changes as outlined above is straightforward, |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
410 %but requires running three commands in sequence. |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
411 $BA0@a$G35MW$r=R$Y$?%A%'%s%8%;%C%H$N%^!<%8%W%m%;%9$OC1=c$J$b$N$@$C$?$,!$(B3 |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
412 $B$D$N%3%^%s%I$r=g$KMQ$$$kI,MW$,$"$C$?!%(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
413 |
102 | 414 \begin{codesample2} |
799 | 415 hg pull -u |
102 | 416 hg merge |
417 hg commit -m 'Merged remote changes' | |
418 \end{codesample2} | |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
419 %In the case of the final commit, you also need to enter a commit |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
420 %message, which is almost always going to be a piece of uninteresting |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
421 %``boilerplate'' text. |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
422 $B:G8e$N%3%_%C%H$G$O!$$[$H$s$IB`6~$J%\%$%i!<%W%l!<%H%F%-%9%H$H8@$C$F$b$h$$(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
423 $B%3%_%C%H%a%C%;!<%8$NF~NO$bI,MW$G$"$C$?!%(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
424 |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
425 %It would be nice to reduce the number of steps needed, if this were |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
426 %possible. Indeed, Mercurial is distributed with an extension called |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
427 %\hgext{fetch} that does just this. |
102 | 428 |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
429 $B2DG=$G$"$l$PI,MW$J%9%F%C%W?t$r>/$J$/$9$k$3$H$,$G$-$k$H$h$$!%<B$O(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
430 Mercurial$B$O(B\hgext{fetch}$B$H$$$&!$$^$5$K$3$N$3$H$r9T$&%(%/%9%F%s%7%g%s$rF1(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
431 $B:-$7$F$$$k!%(B |
102 | 432 |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
433 %Mercurial provides a flexible extension mechanism that lets people |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
434 %extend its functionality, while keeping the core of Mercurial small |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
435 %and easy to deal with. Some extensions add new commands that you can |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
436 %use from the command line, while others work ``behind the scenes,'' |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
437 %for example adding capabilities to the server. |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
438 |
835
8a3041e6f3cb
reflect comments by Hiroshi Someya.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
799
diff
changeset
|
439 Mercurial$B$O%3%"$r>.$5$/!$07$$$d$9$/J]$C$?$^$^5!G=$r3HD%$G$-$k=@Fp$J%(%/%9(B |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
440 $B%F%s%7%g%s%a%+%K%:%`$rDs6!$7$F$$$k!%%3%^%s%I%i%$%s$+$iMxMQ$G$-$k?7$7$$%3(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
441 $B%^%s%I$rDI2C$9$k$h$&$J%(%/%9%F%s%7%g%s$b$"$l$P!$L\$K8+$($J$$$H$3$m$GNc$((B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
442 $B$P%5!<%P$K5!G=$rDI2C$9$k$h$&$J$b$N$b$"$k!%(B |
102 | 443 |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
444 %The \hgext{fetch} extension adds a new command called, not |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
445 %surprisingly, \hgcmd{fetch}. This extension acts as a combination of |
799 | 446 %\hgopt{pull}{-u}, \hgcmd{merge} and \hgcmd{commit}. It begins by pulling |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
447 %changes from another repository into the current repository. If it |
799 | 448 %finds that the changes added a new head to the repository, it |
449 %begins a merge, then (if the merge succeeded) commits the result | |
450 %of the merge with an automatically-generated commit message. If | |
451 %no new heads were added, it updates the working directory to the | |
452 %new tip changeset. | |
102 | 453 |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
454 \hgext{fetch}$B%(%/%9%F%s%7%g%s$O$=$NL>$NDL$j$N?7$7$$%3%^%s%I(B\hgcmd{fetch} |
799 | 455 $B$rDI2C$9$k!%$3$N%(%/%9%F%s%7%g%s$O(B\hgopt{pull}{-u}$B$H(B\hgcmd{merge}$B$*$h$S(B |
456 \hgcmd{commit}$B$rAH$_9g$o$;$?F/$-$r$9$k!%$3$N%(%/%9%F%s%7%g%s$O$^$:B>$N%j(B | |
457 $B%]%8%H%j$+$iJQ99$r(Bpull$B$7!$%j%]%8%H%j$K?7$7$$%X%C%I$,DI2C$5$l$?>l9g$O%^!<(B | |
458 $B%8$r9T$$!$!J%^!<%8$,@.8y$7$?>l9g!K%^!<%87k2L$r<+F0E*$K@8@.$5$l$?%3%_%C%H(B | |
459 $B%a%C%;!<%8$H6&$K%3%_%C%H$9$k!%?7$?$J%X%C%I$,DI2C$5$l$J$+$C$?>l9g$O?7$?$J(B | |
460 tip$B%A%'%s%8%;%C%H$X%o!<%-%s%0%G%#%l%/%H%j$r99?7$9$k!%(B | |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
461 |
799 | 462 %Enabling the \hgext{fetch} extension is easy. Edit the |
463 %\sfilename{.hgrc} in your home directory, and either go to the | |
464 %\rcsection{extensions} section or create an \rcsection{extensions} | |
465 %section. Then add a line that simply reads ``\Verb+fetch +''. | |
466 | |
467 \hgext{fetch}$B%(%/%9%F%s%7%g%s$O4JC1$KM-8z$K$9$k$3$H$,$G$-$k!%%[!<%`%G%#%l(B | |
468 $B%/%H%j$N(B\sfilename{.hgrc}$B%U%!%$%k$rJT=8$7!$(B\rcsection{extensions}$B%;%/%7%g(B | |
469 $B%s$K(B``\Verb+fetch +''$B$H$$$&9T$rDI2C$9$l$P$h$$!%(B | |
102 | 470 \begin{codesample2} |
471 [extensions] | |
472 fetch = | |
473 \end{codesample2} | |
799 | 474 %(Normally, the right-hand side of the ``\texttt{=}'' would indicate |
475 %where to find the extension, but since the \hgext{fetch} extension is in | |
476 %the standard distribution, Mercurial knows where to search for it.) | |
366
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
477 $B!JDL>o!$1&JU$N(B``\texttt{=}''$B$O%(%/%9%F%s%7%g%s$NCV$+$l$?>l=j$rI=$9(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
478 $B$,!$(B\hgext{fetch}$B%(%/%9%F%s%7%g%s$OI8=`G[I[J*$K4^$^$l$k$?$a!$(BMercurial$B$O(B |
4e746f46085c
finished tour-merge.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
365
diff
changeset
|
479 $B$=$N=j:_$r$9$G$KCN$C$F$$$k!%!K(B |
102 | 480 |
365 | 481 %%% Local Variables: |
293
3b1291f24c0d
- replaved latex-mode to yatex-mode
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
290
diff
changeset
|
482 %%% mode: yatex |
84 | 483 %%% TeX-master: "00book" |
365 | 484 %%% End: |