comparison ja/mq.tex @ 329:d520107e32e7

more mq.tex
author Yoshiki Yazawa <yaz@cc.rim.or.jp>
date Sun, 30 Mar 2008 03:34:33 +0900
parents 8bdd9bc948d4
children cadfd8bf5f15
comparison
equal deleted inserted replaced
328:8bdd9bc948d4 329:d520107e32e7
86 86
87 87
88 88
89 89
90 90
91 Maintaining a single patch against an upstream tree is a little 91 %Maintaining a single patch against an upstream tree is a little
92 tedious and error-prone, but not difficult. However, the complexity 92 %tedious and error-prone, but not difficult. However, the complexity
93 of the problem grows rapidly as the number of patches you have to 93 %of the problem grows rapidly as the number of patches you have to
94 maintain increases. With more than a tiny number of patches in hand, 94 %maintain increases.With more than a tiny number of patches in hand,
95 understanding which ones you have applied and maintaining them moves 95 %understanding which ones you have applied and maintaining them moves
96 from messy to overwhelming. 96 %from messy to overwhelming.
97 97
98 Fortunately, Mercurial includes a powerful extension, Mercurial Queues 98 $BC10l$N%Q%C%A$r%"%C%W%9%H%j!<%`$N%D%j!<$KBP$7$F%a%s%F%J%s%9$9$k$3$H$O$d$d(B
99 (or simply ``MQ''), that massively simplifies the patch management 99 $BLLE]$G!$4V0c$$$N85$K$J$j$,$A$G$"$k$,!$Fq$7$/$O$J$$!%$7$+$7!$%a%s%F%J%s%9(B
100 problem. 100 $B$9$k%Q%C%A$N?t$,A}$($k$K=>$C$FLdBj$NJ#;($5$,5^B.$KA}$7$F$$$/!%%Q%C%A$N?t(B
101 $B$,$"$kDxEY0J>eB?$/$J$k$H!$$I$N%Q%C%A$rE,MQ$7$?$+!$$I$N%Q%C%A$r4IM}$7$F$$(B
102 $B$k$N$+$NM}2r$,!$Lq2p$H$$$&>uBV$+$i05E]$5$l$k$F$$$k>uBV$K$J$k!%(B
103
104 %Fortunately, Mercurial includes a powerful extension, Mercurial Queues
105 %(or simply ``MQ''), that massively simplifies the patch management
106 %problem.
107
108 $B9,$$$K$b!$(BMercurial$B$O(BMercurial Queues$B!J$"$k$$$OC1$K(BMQ$B!K$H$$$&6/NO$J%(%/%9(B
109 $B%F%s%7%g%s$r$b$C$F$*$j!$%Q%C%A4IM}$NLdBj$rBgI}$KC1=c2=$9$k!%(B
110
101 111
102 %\section{The prehistory of Mercurial Queues} 112 %\section{The prehistory of Mercurial Queues}
103 \section{Mercurial Queues$BA0;K(B} 113 \section{Mercurial Queues$BA0;K(B}
104 \label{sec:mq:history} 114 \label{sec:mq:history}
105 115
309 % commands} 319 % commands}
310 \caption{\command{diff}$B%3%^%s%I$H(B\command{patch}$B%3%^%s%I$NC1=c$J;HMQNc(B} 320 \caption{\command{diff}$B%3%^%s%I$H(B\command{patch}$B%3%^%s%I$NC1=c$J;HMQNc(B}
311 \label{ex:mq:diff} 321 \label{ex:mq:diff}
312 \end{figure} 322 \end{figure}
313 323
314 The type of file that \command{diff} generates (and \command{patch} 324 %The type of file that \command{diff} generates (and \command{patch}
315 takes as input) is called a ``patch'' or a ``diff''; there is no 325 %takes as input) is called a ``patch'' or a ``diff''; there is no
316 difference between a patch and a diff. (We'll use the term ``patch'', 326 %difference between a patch and a diff. (We'll use the term ``patch'',
317 since it's more commonly used.) 327 %since it's more commonly used.)
318 328
319 329 \command{diff}$B$,@8@.$9$k!J$^$?(B\command{patch}$B$,F~NO$K<h$k!K%U%!%$%k$N<o(B
320 330 $BN`$O(B``patch''$B$^$?$O(B``diff''$B$H8F$P$l!$$3$l$i$N4V$K$O0c$$$O$J$$!%!J0J2<$G(B
321 331 $B$O!$$h$jB?$/;H$o$l$F$$$k(B``patch''$B$H$$$&8@MU$r;H$&$3$H$K$9$k!%!K(B
322 A patch file can start with arbitrary text; the \command{patch} 332
323 command ignores this text, but MQ uses it as the commit message when 333 %A patch file can start with arbitrary text; the \command{patch}
324 creating changesets. To find the beginning of the patch content, 334 %command ignores this text, but MQ uses it as the commit message when
325 \command{patch} searches for the first line that starts with the 335 %creating changesets. To find the beginning of the patch content,
326 string ``\texttt{diff~-}''. 336 %\command{patch} searches for the first line that starts with the
327 337 %string ``\texttt{diff~-}''.
328 MQ works with \emph{unified} diffs (\command{patch} can accept several 338
329 other diff formats, but MQ doesn't). A unified diff contains two 339 $B%Q%C%A%U%!%$%k$OG$0U$N%F%-%9%H$G;O$^$k!%(B\command{patch}$B%3%^%s%I$O$3$N%F(B
330 kinds of header. The \emph{file header} describes the file being 340 $B%-%9%H$rL5;k$9$k$,!$(BMQ$B$O%A%'%s%8%;%C%H$r:n$k:]$N%3%_%C%H%a%C%;!<%8$H$7$F(B
331 modified; it contains the name of the file to modify. When 341 $BMxMQ$9$k!%%Q%C%AFbMF$N@hF,$r8+$D$1$k$?$a$K(B\command{patch}$B$O(B
332 \command{patch} sees a new file header, it looks for a file with that 342 ``\texttt{diff~-}''$B$G;O$^$k:G=i$N9T$r%5!<%A$9$k!%(B
333 name to start modifying. 343
334 344 %MQ works with \emph{unified} diffs (\command{patch} can accept several
335 After the file header comes a series of \emph{hunks}. Each hunk 345 %other diff formats, but MQ doesn't). A unified diff contains two
336 starts with a header; this identifies the range of line numbers within 346 %kinds of header. The \emph{file header} describes the file being
337 the file that the hunk should modify. Following the header, a hunk 347 %modified; it contains the name of the file to modify. When
338 starts and ends with a few (usually three) lines of text from the 348 %\command{patch} sees a new file header, it looks for a file with that
339 unmodified file; these are called the \emph{context} for the hunk. If 349 %name to start modifying.
340 there's only a small amount of context between successive hunks, 350
341 \command{diff} doesn't print a new hunk header; it just runs the hunks 351 MQ\emph{unified} diffs$B7A<0$r;H$&!%!J(B\command{patch}$B%3%^%s%I$O$3$l0J30$K2?(B
342 together, with a few lines of context between modifications. 352 $B<oN`$+$N(Bdiff$B%U%)!<%^%C%H$r<u$1IU$1$k$,!$(BMQ$B$G$OMxMQ$G$-$J$$!%!K(Bunified
343 353 diff$B$O(B2$B<oN`$N%X%C%@$r;}$D!%(B\emph{file $B%X%C%@(B}$B$OJQ99$5$l$F$$$k%U%!%$%k$r5-(B
344 Each line of context begins with a space character. Within the hunk, 354 $B=R$9$k!%(B\command{patch}$B%3%^%s%I$O!$?7$7$$%U%!%$%k%X%C%@$r8+$D$1$k$H!$$=$3(B
345 a line that begins with ``\texttt{-}'' means ``remove this line,'' 355 $B$K5-=R$5$l$F$$$k%U%!%$%kL>$r;}$D%U%!%$%k$rC5$9!%(B
346 while a line that begins with ``\texttt{+}'' means ``insert this 356
347 line.'' For example, a line that is modified is represented by one 357 %After the file header comes a series of \emph{hunks}. Each hunk starts
348 deletion and one insertion. 358 %with a header; this identifies the range of line numbers within the file
349 359 %that the hunk should modify. Following the header, a hunk starts and
350 We will return to some of the more subtle aspects of patches later (in 360 %ends with a few (usually three) lines of text from the unmodified file;
351 section~\ref{sec:mq:adv-patch}), but you should have enough information 361 %these are called the \emph{context} for the hunk.If
352 now to use MQ. 362 %there's only a small amount of context between successive hunks,
363 %\command{diff} doesn't print a new hunk header; it just runs the hunks
364 %together, with a few lines of context between modifications.
365
366 $B%U%!%$%k%X%C%@$N8e$K$O0lO"$N(B\emph{hunks}$B$,B3$/!%3F!9$N(Bhunk$B$O%X%C%@$G;O$^(B
367 $B$k!%$3$N%X%C%@$O%U%!%$%kFb$G(Bhunk$B$,2~JQ$9$Y$-9THV9f$NHO0O$r<1JL$9$k$N$K;H(B
368 $B$o$l$k!%%X%C%@$KB3$-!$(Bhunk$B$O?t9T!JDL>o(B3$B!K$N2~JQ$5$l$F$$$J$$%U%!%$%k$+$i$N(B
369 $B9T$,$"$k!%$3$l$i$O(Bhunk$B$N(B\emph{$B%3%s%F%-%9%H(B}$B$H8F$P$l$k!%$b$7O"B3$9$k(Bhunk$B$N(B
370 $B4V$K%3%s%F%-%9%H$,>/$7$7$+$J$1$l$P!$(B\command{diff}$B$O?7$?$J(Bhunk$B%X%C%@$r=P(B
371 $BNO$;$:!$3F!9$N(Bhunk$B$H4V$N%3%s%F%-%9%H$r9g$o$;$F=PNO$9$k!%(B
372
373 %Each line of context begins with a space character. Within the hunk,
374 %a line that begins with ``\texttt{-}'' means ``remove this line,''
375 %while a line that begins with ``\texttt{+}'' means ``insert this
376 %line.'' For example, a line that is modified is represented by one
377 %deletion and one insertion.
378
379 $B%3%s%F%-%9%H$N3F9T$O!$6uGrJ8;z$G;O$^$k!%(Bhunk$BFb$G$O9T$O(B``\texttt{-}''$B$G;O(B
380 $B$^$k!%$3$l$O(B``$B$3$N9T$r:o=|$;$h(B''$B$r0UL#$9$k!%(B
381 $B0lJ}!$(B``\texttt{+}''$B$G;O$^$k9T$O!$(B``$B$3$N9T$rA^F~$;$h(B''$B$r0UL#$9$k!%Nc$r5s(B
382 $B$2$k$H!$JQ99$5$l$?9T$O(B1$B$D$N:o=|$H(B1$B$D$NA^F~$GI=$5$l$k!%(B
383
384 %We will return to some of the more subtle aspects of patches later (in
385 %section~\ref{sec:mq:adv-patch}), but you should have enough information
386 %now to use MQ.
387
388 $B%Q%C%A$N:3:Y$JE@$K$D$$$F$O8e$G!J(B~\ref{sec:mq:adv-patch}$B!K$^$??($l$k$,!$(B
389 $B$3$l$^$G$G!$(BMQ$B$r;H$&$N$K==J,$J>pJs$O=R$Y$?!%(B
353 390
354 %\section{Getting started with Mercurial Queues} 391 %\section{Getting started with Mercurial Queues}
355 \section{Mercurial Queues$B$r;H$C$F$_$k(B} 392 \section{Mercurial Queues$B$r;H$C$F$_$k(B}
356 \label{sec:mq:start} 393 \label{sec:mq:start}
357 394