annotate ja/mq-collab.tex @ 349:84ae26ab0ac3

started mq-collab.tex
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Sat, 16 Aug 2008 12:45:25 +0900
parents 3b1291f24c0d
children 5a5419eeab70
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
349
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
1 %\chapter{Advanced uses of Mercurial Queues}
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
2 \chapter{Mercurial Queues$B$N9bEY$J;H$$J}(B}
224
34943a3d50d6 Start writing up extensions. Begin with inotify.
Bryan O'Sullivan <bos@serpentine.com>
parents: 107
diff changeset
3 \label{chap:mq-collab}
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
4
349
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
5 %While it's easy to pick up straightforward uses of Mercurial Queues,
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
6 %use of a little discipline and some of MQ's less frequently used
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
7 %capabilities makes it possible to work in complicated development
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
8 %environments.
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
9
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
10 Mercurial Queues$B$NC1=c$J;H$$J}$r<h$j>e$2$?0lJ}!$>/!9$NE}@)$H(BMQ$B$N$"$^$jMQ(B
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
11 $B$$$i$l$J$$5!G=$rMQ$$$k$3$H$GJ#;($J3+H/4D6-$G$N:n6H$,2DG=$H$J$k!%(B
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
12
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
13 %In this chapter, I will use as an example a technique I have used to
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
14 %manage the development of an Infiniband device driver for the Linux
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
15 %kernel. The driver in question is large (at least as drivers go),
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
16 %with 25,000 lines of code spread across 35 source files. It is
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
17 %maintained by a small team of developers.
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
18
349
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
19 $B$3$N>O$G$O!$(BLinux$B%+!<%M%kMQ(BInfiniband$B%G%P%$%9%I%i%$%P$N3+H/$r4IM}$9$k$N$K(B
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
20 $BMQ$$$?%F%/%K%C%/$rNc$H$7$FMQ$$$k!%$3$N%I%i%$%P$O!J%I%i%$%P$H$7$F$O!KBg5,(B
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
21 $BLO$G!$(B35$B$N%=!<%9%U%!%$%k$K$o$?$k(B25000$B9T$+$i$J$k!%$3$N%=!<%9$O>.5,LO$J3+H/(B
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
22 $B<T$N%A!<%`$K$h$C$F$$;~4IM}$5$l$F$$$k!%(B
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
23
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
24 %While much of the material in this chapter is specific to Linux, the
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
25 %same principles apply to any code base for which you're not the
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
26 %primary owner, and upon which you need to do a lot of development.
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
27
349
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
28 $B$3$N>O$G$NAG:`$O(BLinux$B$KFC2=$7$F$$$k$,!$F1$886B'$O$$$+$J$k%3!<%I%Y!<%9$KBP(B
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
29 $B$7$F$bE,MQ2DG=$G!$<+J,<+?H$G=jM-$7$F$$$J$$$,!$B?$/$N3+H/$r9T$&I,MW$N$"$k(B
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
30 $B%3!<%I$J$I$K$bE,MQ$G$-$k!%(B
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
31
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
32
349
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
33 %\section{The problem of many targets}
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
34 \section{$B%?!<%2%C%H$,J#?t$"$k$H$$$&LdBj(B}
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
35
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
36 %The Linux kernel changes rapidly, and has never been internally
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
37 %stable; developers frequently make drastic changes between releases.
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
38 %This means that a version of the driver that works well with a
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
39 %particular released version of the kernel will not even \emph{compile}
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
40 %correctly against, typically, any other version.
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
41
349
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
42 Linux$B%+!<%M%k$O5^B.$KJQ2=$7!$$=$NFbIt$O7h$7$F0lDj$G$O$J$$!%3+H/<T$?$A$OIQ(B
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
43 $BHK$K%j%j!<%94V$G7`E*$JJQ99$r9T$&!%$3$N$?$a!$FCDj$N%j%j!<%9%P!<%8%g%s$GNI(B
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
44 $B$/F0$$$?%I%i%$%P$,!$Nc$($PJL$N%P!<%8%g%s$G$O@5$7$/%3%s%Q%$%k$9$k$3$H$9$i(B
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
45 $B$G$-$J$/$J$k$H$$$&$3$H$r0UL#$9$k!%(B
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
46
349
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
47 %To maintain a driver, we have to keep a number of distinct versions of
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
48 %Linux in mind.
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
49
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
50 $B%I%i%$%P$r0];}$9$k$?$a$K!$3+H/<T$O$$$/$D$b$NJL$N%P!<%8%g%s$N(BLinux$B$rA[Dj(B
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
51 $B$7$J$1$l$P$J$i$J$$!%(B
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
52 \begin{itemize}
349
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
53 %\item One target is the main Linux kernel development tree.
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
54
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
55 % Maintenance of the code is in this case partly shared by other
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
56 % developers in the kernel community, who make ``drive-by''
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
57 % modifications to the driver as they develop and refine kernel
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
58 % subsystems.
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
59 \item $B0l$D$N%?!<%2%C%H$O(BLinux$B%+!<%M%k$N3+H/%D%j!<$G$"$k!%$3$N>l9g!$%3!<%I(B
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
60 $B$N0];}4IM}$O%+!<%M%k%3%_%e%K%F%#$NB>$N3+H/<T!J$3$l$O%+!<%M%k$N%5%V(B
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
61 $B%7%9%F%`$r2~NI$9$k$?$a$K%I%i%$%P$r(B``$BDI$$N)$F$k(B''$BJQ99$r9T$&3+H/<T$G(B
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
62 $B$"$k!K$HItJ,E*$K6&M-$5$l$F$$$k!%(B
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
63 %\item We also maintain a number of ``backports'' to older versions of
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
64 % the Linux kernel, to support the needs of customers who are running
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
65 % older Linux distributions that do not incorporate our drivers. (To
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
66 % \emph{backport} a piece of code is to modify it to work in an older
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
67 % version of its target environment than the version it was developed
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
68 % for.)
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
69 \item $B3+H/<T$O2f!9$N%I%i%$%P$,AH$_9~$^$l$F$$$J$$8E$$(BLinux$B%G%#%9%H%j%S%e!<(B
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
70 $B%7%g%s$r;H$C$F$$$k8\5R$r%5%]!<%H$9$k$?$a$K!$8E$$%P!<%8%g%s$N(BLinux$B%+!<(B
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
71 $B%M%k$X$N(B``$B%P%C%/%]!<%H(B''$B$rJz$($F$$$k!%%3!<%I$N0lIt$r(B\emph{$B%P%C%/%]!<(B
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
72 $B%H(B}$B$9$k$3$H$O!$%I%i%$%P$,3+H/$5$l$?%P!<%8%g%s$h$j$b8E$$%P!<%8%g%s(B
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
73 $B$N4D6-$GF0$/$h$&$K$9$k$3$H$r0UL#$9$k!%(B
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
74 %\item Finally, we make software releases on a schedule that is
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
75 % necessarily not aligned with those used by Linux distributors and
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
76 % kernel developers, so that we can deliver new features to customers
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
77 % without forcing them to upgrade their entire kernels or
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
78 % distributions.
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
79 \item $B:G=*E*$K(BLinux$B%G%#%9%H%j%S%e!<%?$d%+!<%M%k3+H/<T$rBT$?$;$k$3$H$J$/%9(B
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
80 $B%1%8%e!<%kDL$j$K%=%U%H%&%'%"$r%j%j!<%9$9$k$3$H$,I,MW$G$"$j!$$3$l$K$h$C$F(B
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
81 $B8\5R$K%+!<%M%k$d%G%#%9%H%j%S%e!<%7%g%sA4BN$r%"%C%W%0%l!<%I$5$;$k$3$H$J$/(B
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
82 $B?75!G=$r8\5R$KFO$1$i$l$k!%(B
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
83 \end{itemize}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
84
349
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
85 %\subsection{Tempting approaches that don't work well}
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
86 \subsection{$B$d$C$F$7$^$$$,$A$J4V0c$C$?J}K!(B}
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
87
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
88 There are two ``standard'' ways to maintain a piece of software that
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
89 has to target many different environments.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
90
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
91 The first is to maintain a number of branches, each intended for a
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
92 single target. The trouble with this approach is that you must
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
93 maintain iron discipline in the flow of changes between repositories.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
94 A new feature or bug fix must start life in a ``pristine'' repository,
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
95 then percolate out to every backport repository. Backport changes are
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
96 more limited in the branches they should propagate to; a backport
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
97 change that is applied to a branch where it doesn't belong will
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
98 probably stop the driver from compiling.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
99
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
100 The second is to maintain a single source tree filled with conditional
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
101 statements that turn chunks of code on or off depending on the
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
102 intended target. Because these ``ifdefs'' are not allowed in the
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
103 Linux kernel tree, a manual or automatic process must be followed to
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
104 strip them out and yield a clean tree. A code base maintained in this
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
105 fashion rapidly becomes a rat's nest of conditional blocks that are
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
106 difficult to understand and maintain.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
107
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
108 Neither of these approaches is well suited to a situation where you
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
109 don't ``own'' the canonical copy of a source tree. In the case of a
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
110 Linux driver that is distributed with the standard kernel, Linus's
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
111 tree contains the copy of the code that will be treated by the world
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
112 as canonical. The upstream version of ``my'' driver can be modified
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
113 by people I don't know, without me even finding out about it until
349
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
114 after the changes show up in Linus's tree.
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
115
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
116 These approaches have the added weakness of making it difficult to
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
117 generate well-formed patches to submit upstream.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
118
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
119 In principle, Mercurial Queues seems like a good candidate to manage a
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
120 development scenario such as the above. While this is indeed the
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
121 case, MQ contains a few added features that make the job more
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
122 pleasant.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
123
349
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
124 %\section{Conditionally applying patches with guards}
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
125 \section{$B%,!<%I$r;H$C$?%Q%C%A$N>r7oE*$JE,MQ(B}
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
126
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
127 Perhaps the best way to maintain sanity with so many targets is to be
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
128 able to choose specific patches to apply for a given situation. MQ
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
129 provides a feature called ``guards'' (which originates with quilt's
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
130 \texttt{guards} command) that does just this. To start off, let's
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
131 create a simple repository for experimenting in.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
132 \interaction{mq.guards.init}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
133 This gives us a tiny repository that contains two patches that don't
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
134 have any dependencies on each other, because they touch different files.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
135
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
136 The idea behind conditional application is that you can ``tag'' a
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
137 patch with a \emph{guard}, which is simply a text string of your
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
138 choosing, then tell MQ to select specific guards to use when applying
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
139 patches. MQ will then either apply, or skip over, a guarded patch,
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
140 depending on the guards that you have selected.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
141
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
142 A patch can have an arbitrary number of guards;
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
143 each one is \emph{positive} (``apply this patch if this guard is
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
144 selected'') or \emph{negative} (``skip this patch if this guard is
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
145 selected''). A patch with no guards is always applied.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
146
349
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
147 %\section{Controlling the guards on a patch}
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
148 \section{$B%Q%C%AFb$N%,!<%I$rA`:n$9$k(B}
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
149
233
696b1e0c01df Tag all MQ commands as belonging to the mq extension.
Bryan O'Sullivan <bos@serpentine.com>
parents: 224
diff changeset
150 The \hgxcmd{mq}{qguard} command lets you determine which guards should
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
151 apply to a patch, or display the guards that are already in effect.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
152 Without any arguments, it displays the guards on the current topmost
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
153 patch.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
154 \interaction{mq.guards.qguard}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
155 To set a positive guard on a patch, prefix the name of the guard with
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
156 a ``\texttt{+}''.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
157 \interaction{mq.guards.qguard.pos}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
158 To set a negative guard on a patch, prefix the name of the guard with
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
159 a ``\texttt{-}''.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
160 \interaction{mq.guards.qguard.neg}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
161
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
162 \begin{note}
233
696b1e0c01df Tag all MQ commands as belonging to the mq extension.
Bryan O'Sullivan <bos@serpentine.com>
parents: 224
diff changeset
163 The \hgxcmd{mq}{qguard} command \emph{sets} the guards on a patch; it
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
164 doesn't \emph{modify} them. What this means is that if you run
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
165 \hgcmdargs{qguard}{+a +b} on a patch, then \hgcmdargs{qguard}{+c} on
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
166 the same patch, the \emph{only} guard that will be set on it
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
167 afterwards is \texttt{+c}.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
168 \end{note}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
169
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
170 Mercurial stores guards in the \sfilename{series} file; the form in
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
171 which they are stored is easy both to understand and to edit by hand.
233
696b1e0c01df Tag all MQ commands as belonging to the mq extension.
Bryan O'Sullivan <bos@serpentine.com>
parents: 224
diff changeset
172 (In other words, you don't have to use the \hgxcmd{mq}{qguard} command if
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
173 you don't want to; it's okay to simply edit the \sfilename{series}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
174 file.)
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
175 \interaction{mq.guards.series}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
176
349
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
177 %\section{Selecting the guards to use}
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
178 \section{$B;HMQ$9$k%,!<%I$rA*$V(B}
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
179
233
696b1e0c01df Tag all MQ commands as belonging to the mq extension.
Bryan O'Sullivan <bos@serpentine.com>
parents: 224
diff changeset
180 The \hgxcmd{mq}{qselect} command determines which guards are active at a
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
181 given time. The effect of this is to determine which patches MQ will
233
696b1e0c01df Tag all MQ commands as belonging to the mq extension.
Bryan O'Sullivan <bos@serpentine.com>
parents: 224
diff changeset
182 apply the next time you run \hgxcmd{mq}{qpush}. It has no other effect; in
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
183 particular, it doesn't do anything to patches that are already
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
184 applied.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
185
233
696b1e0c01df Tag all MQ commands as belonging to the mq extension.
Bryan O'Sullivan <bos@serpentine.com>
parents: 224
diff changeset
186 With no arguments, the \hgxcmd{mq}{qselect} command lists the guards
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
187 currently in effect, one per line of output. Each argument is treated
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
188 as the name of a guard to apply.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
189 \interaction{mq.guards.qselect.foo}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
190 In case you're interested, the currently selected guards are stored in
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
191 the \sfilename{guards} file.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
192 \interaction{mq.guards.qselect.cat}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
193 We can see the effect the selected guards have when we run
233
696b1e0c01df Tag all MQ commands as belonging to the mq extension.
Bryan O'Sullivan <bos@serpentine.com>
parents: 224
diff changeset
194 \hgxcmd{mq}{qpush}.
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
195 \interaction{mq.guards.qselect.qpush}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
196
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
197 A guard cannot start with a ``\texttt{+}'' or ``\texttt{-}''
106
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
198 character. The name of a guard must not contain white space, but most
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
199 othter characters are acceptable. If you try to use a guard with an
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
200 invalid name, MQ will complain:
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
201 \interaction{mq.guards.qselect.error}
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
202 Changing the selected guards changes the patches that are applied.
106
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
203 \interaction{mq.guards.qselect.quux}
105
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
204 You can see in the example below that negative guards take precedence
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
205 over positive guards.
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
206 \interaction{mq.guards.qselect.foobar}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
207
349
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
208 %\section{MQ's rules for applying patches}
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
209 \section{MQ$B$N%Q%C%AE,MQ%k!<%k(B}
105
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
210
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
211 The rules that MQ uses when deciding whether to apply a patch
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
212 are as follows.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
213 \begin{itemize}
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
214 \item A patch that has no guards is always applied.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
215 \item If the patch has any negative guard that matches any currently
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
216 selected guard, the patch is skipped.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
217 \item If the patch has any positive guard that matches any currently
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
218 selected guard, the patch is applied.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
219 \item If the patch has positive or negative guards, but none matches
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
220 any currently selected guard, the patch is skipped.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
221 \end{itemize}
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
222
349
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
223 %\section{Trimming the work environment}
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
224 \section{$B:n6H4D6-$r=L>.$9$k(B}
105
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
225
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
226 In working on the device driver I mentioned earlier, I don't apply the
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
227 patches to a normal Linux kernel tree. Instead, I use a repository
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
228 that contains only a snapshot of the source files and headers that are
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
229 relevant to Infiniband development. This repository is~1\% the size
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
230 of a kernel repository, so it's easier to work with.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
231
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
232 I then choose a ``base'' version on top of which the patches are
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
233 applied. This is a snapshot of the Linux kernel tree as of a revision
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
234 of my choosing. When I take the snapshot, I record the changeset ID
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
235 from the kernel repository in the commit message. Since the snapshot
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
236 preserves the ``shape'' and content of the relevant parts of the
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
237 kernel tree, I can apply my patches on top of either my tiny
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
238 repository or a normal kernel tree.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
239
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
240 Normally, the base tree atop which the patches apply should be a
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
241 snapshot of a very recent upstream tree. This best facilitates the
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
242 development of patches that can easily be submitted upstream with few
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
243 or no modifications.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
244
349
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
245 %\section{Dividing up the \sfilename{series} file}
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
246 \section{\sfilename{series}$B%U%!%$%k$X%@%$%V$9$k(B}
105
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
247
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
248 I categorise the patches in the \sfilename{series} file into a number
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
249 of logical groups. Each section of like patches begins with a block
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
250 of comments that describes the purpose of the patches that follow.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
251
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
252 The sequence of patch groups that I maintain follows. The ordering of
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
253 these groups is important; I'll describe why after I introduce the
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
254 groups.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
255 \begin{itemize}
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
256 \item The ``accepted'' group. Patches that the development team has
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
257 submitted to the maintainer of the Infiniband subsystem, and which
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
258 he has accepted, but which are not present in the snapshot that the
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
259 tiny repository is based on. These are ``read only'' patches,
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
260 present only to transform the tree into a similar state as it is in
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
261 the upstream maintainer's repository.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
262 \item The ``rework'' group. Patches that I have submitted, but that
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
263 the upstream maintainer has requested modifications to before he
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
264 will accept them.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
265 \item The ``pending'' group. Patches that I have not yet submitted to
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
266 the upstream maintainer, but which we have finished working on.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
267 These will be ``read only'' for a while. If the upstream maintainer
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
268 accepts them upon submission, I'll move them to the end of the
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
269 ``accepted'' group. If he requests that I modify any, I'll move
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
270 them to the beginning of the ``rework'' group.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
271 \item The ``in progress'' group. Patches that are actively being
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
272 developed, and should not be submitted anywhere yet.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
273 \item The ``backport'' group. Patches that adapt the source tree to
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
274 older versions of the kernel tree.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
275 \item The ``do not ship'' group. Patches that for some reason should
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
276 never be submitted upstream. For example, one such patch might
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
277 change embedded driver identification strings to make it easier to
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
278 distinguish, in the field, between an out-of-tree version of the
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
279 driver and a version shipped by a distribution vendor.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
280 \end{itemize}
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
281
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
282 Now to return to the reasons for ordering groups of patches in this
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
283 way. We would like the lowest patches in the stack to be as stable as
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
284 possible, so that we will not need to rework higher patches due to
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
285 changes in context. Putting patches that will never be changed first
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
286 in the \sfilename{series} file serves this purpose.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
287
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
288 We would also like the patches that we know we'll need to modify to be
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
289 applied on top of a source tree that resembles the upstream tree as
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
290 closely as possible. This is why we keep accepted patches around for
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
291 a while.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
292
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
293 The ``backport'' and ``do not ship'' patches float at the end of the
106
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
294 \sfilename{series} file. The backport patches must be applied on top
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
295 of all other patches, and the ``do not ship'' patches might as well
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
296 stay out of harm's way.
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
297
349
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
298 %\section{Maintaining the patch series}
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
299 \section{$B%Q%C%A%7%j!<%:$r4IM}$9$k(B}
106
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
300
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
301 In my work, I use a number of guards to control which patches are to
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
302 be applied.
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
303
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
304 \begin{itemize}
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
305 \item ``Accepted'' patches are guarded with \texttt{accepted}. I
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
306 enable this guard most of the time. When I'm applying the patches
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
307 on top of a tree where the patches are already present, I can turn
271
8627f718517a Fix typo "paptches"
Max Vozeler <max@nusquama.org>
parents: 240
diff changeset
308 this patch off, and the patches that follow it will apply cleanly.
106
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
309 \item Patches that are ``finished'', but not yet submitted, have no
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
310 guards. If I'm applying the patch stack to a copy of the upstream
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
311 tree, I don't need to enable any guards in order to get a reasonably
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
312 safe source tree.
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
313 \item Those patches that need reworking before being resubmitted are
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
314 guarded with \texttt{rework}.
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
315 \item For those patches that are still under development, I use
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
316 \texttt{devel}.
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
317 \item A backport patch may have several guards, one for each version
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
318 of the kernel to which it applies. For example, a patch that
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
319 backports a piece of code to~2.6.9 will have a~\texttt{2.6.9} guard.
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
320 \end{itemize}
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
321 This variety of guards gives me considerable flexibility in
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
322 qdetermining what kind of source tree I want to end up with. For most
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
323 situations, the selection of appropriate guards is automated during
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
324 the build process, but I can manually tune the guards to use for less
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
325 common circumstances.
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
326
349
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
327 %\subsection{The art of writing backport patches}
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
328 \subsection{$B%P%C%/%]!<%H%Q%C%A$r=q$/5;=Q(B}
106
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
329
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
330 Using MQ, writing a backport patch is a simple process. All such a
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
331 patch has to do is modify a piece of code that uses a kernel feature
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
332 not present in the older version of the kernel, so that the driver
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
333 continues to work correctly under that older version.
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
334
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
335 A useful goal when writing a good backport patch is to make your code
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
336 look as if it was written for the older version of the kernel you're
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
337 targeting. The less obtrusive the patch, the easier it will be to
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
338 understand and maintain. If you're writing a collection of backport
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
339 patches to avoid the ``rat's nest'' effect of lots of
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
340 \texttt{\#ifdef}s (hunks of source code that are only used
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
341 conditionally) in your code, don't introduce version-dependent
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
342 \texttt{\#ifdef}s into the patches. Instead, write several patches,
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
343 each of which makes unconditional changes, and control their
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
344 application using guards.
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
345
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
346 There are two reasons to divide backport patches into a distinct
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
347 group, away from the ``regular'' patches whose effects they modify.
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
348 The first is that intermingling the two makes it more difficult to use
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
349 a tool like the \hgext{patchbomb} extension to automate the process of
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
350 submitting the patches to an upstream maintainer. The second is that
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
351 a backport patch could perturb the context in which a subsequent
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
352 regular patch is applied, making it impossible to apply the regular
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
353 patch cleanly \emph{without} the earlier backport patch already being
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
354 applied.
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
355
349
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
356 %\section{Useful tips for developing with MQ}
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
357 \section{MQ$B$K$h$k3+H/$N(Btips}
106
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
358
349
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
359 %\subsection{Organising patches in directories}
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
360 \subsection{$B%G%#%l%/%H%jFb$G%Q%C%A$r4IM}$9$k(B}
106
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
361
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
362 If you're working on a substantial project with MQ, it's not difficult
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
363 to accumulate a large number of patches. For example, I have one
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
364 patch repository that contains over 250 patches.
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
365
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
366 If you can group these patches into separate logical categories, you
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
367 can if you like store them in different directories; MQ has no
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
368 problems with patch names that contain path separators.
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
369
349
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
370 %\subsection{Viewing the history of a patch}
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
371 \subsection{$B%Q%C%A$N%R%9%H%j$r8+$k(B}
106
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
372 \label{mq-collab:tips:interdiff}
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
373
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
374 If you're developing a set of patches over a long time, it's a good
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
375 idea to maintain them in a repository, as discussed in
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
376 section~\ref{sec:mq:repo}. If you do so, you'll quickly discover that
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
377 using the \hgcmd{diff} command to look at the history of changes to a
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
378 patch is unworkable. This is in part because you're looking at the
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
379 second derivative of the real code (a diff of a diff), but also
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
380 because MQ adds noise to the process by modifying time stamps and
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
381 directory names when it updates a patch.
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
382
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
383 However, you can use the \hgext{extdiff} extension, which is bundled
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
384 with Mercurial, to turn a diff of two versions of a patch into
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
385 something readable. To do this, you will need a third-party package
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
386 called \package{patchutils}~\cite{web:patchutils}. This provides a
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
387 command named \command{interdiff}, which shows the differences between
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
388 two diffs as a diff. Used on two versions of the same diff, it
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
389 generates a diff that represents the diff from the first to the second
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
390 version.
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
391
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
392 You can enable the \hgext{extdiff} extension in the usual way, by
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
393 adding a line to the \rcsection{extensions} section of your \hgrc.
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
394 \begin{codesample2}
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
395 [extensions]
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
396 extdiff =
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
397 \end{codesample2}
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
398 The \command{interdiff} command expects to be passed the names of two
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
399 files, but the \hgext{extdiff} extension passes the program it runs a
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
400 pair of directories, each of which can contain an arbitrary number of
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
401 files. We thus need a small program that will run \command{interdiff}
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
402 on each pair of files in these two directories. This program is
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
403 available as \sfilename{hg-interdiff} in the \dirname{examples}
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
404 directory of the source code repository that accompanies this book.
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
405 \excode{hg-interdiff}
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
406
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
407 With the \sfilename{hg-interdiff} program in your shell's search path,
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
408 you can run it as follows, from inside an MQ patch directory:
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
409 \begin{codesample2}
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
410 hg extdiff -p hg-interdiff -r A:B my-change.patch
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
411 \end{codesample2}
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
412 Since you'll probably want to use this long-winded command a lot, you
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
413 can get \hgext{hgext} to make it available as a normal Mercurial
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
414 command, again by editing your \hgrc.
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
415 \begin{codesample2}
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
416 [extdiff]
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
417 cmd.interdiff = hg-interdiff
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
418 \end{codesample2}
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
419 This directs \hgext{hgext} to make an \texttt{interdiff} command
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
420 available, so you can now shorten the previous invocation of
238
4b315189e01f Fix typo.
Bryan O'Sullivan <bos@serpentine.com>
parents: 233
diff changeset
421 \hgxcmd{extdiff}{extdiff} to something a little more wieldy.
106
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
422 \begin{codesample2}
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
423 hg interdiff -r A:B my-change.patch
9cbc5d0db542 Finish off advanced MQ chapter (maybe).
Bryan O'Sullivan <bos@serpentine.com>
parents: 105
diff changeset
424 \end{codesample2}
105
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
425
107
a0d7e11db169 A brief note on interdiff.
Bryan O'Sullivan <bos@serpentine.com>
parents: 106
diff changeset
426 \begin{note}
a0d7e11db169 A brief note on interdiff.
Bryan O'Sullivan <bos@serpentine.com>
parents: 106
diff changeset
427 The \command{interdiff} command works well only if the underlying
a0d7e11db169 A brief note on interdiff.
Bryan O'Sullivan <bos@serpentine.com>
parents: 106
diff changeset
428 files against which versions of a patch are generated remain the
a0d7e11db169 A brief note on interdiff.
Bryan O'Sullivan <bos@serpentine.com>
parents: 106
diff changeset
429 same. If you create a patch, modify the underlying files, and then
a0d7e11db169 A brief note on interdiff.
Bryan O'Sullivan <bos@serpentine.com>
parents: 106
diff changeset
430 regenerate the patch, \command{interdiff} may not produce useful
a0d7e11db169 A brief note on interdiff.
Bryan O'Sullivan <bos@serpentine.com>
parents: 106
diff changeset
431 output.
a0d7e11db169 A brief note on interdiff.
Bryan O'Sullivan <bos@serpentine.com>
parents: 106
diff changeset
432 \end{note}
a0d7e11db169 A brief note on interdiff.
Bryan O'Sullivan <bos@serpentine.com>
parents: 106
diff changeset
433
240
4119e57679f7 Twiddle wording trivially.
Bryan O'Sullivan <bos@serpentine.com>
parents: 239
diff changeset
434 The \hgext{extdiff} extension is useful for more than merely improving
239
fe8598eb99c4 Refer to main coverage of extdiff extension.
Bryan O'Sullivan <bos@serpentine.com>
parents: 238
diff changeset
435 the presentation of MQ~patches. To read more about it, go to
fe8598eb99c4 Refer to main coverage of extdiff extension.
Bryan O'Sullivan <bos@serpentine.com>
parents: 238
diff changeset
436 section~\ref{sec:hgext:extdiff}.
fe8598eb99c4 Refer to main coverage of extdiff extension.
Bryan O'Sullivan <bos@serpentine.com>
parents: 238
diff changeset
437
349
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
438 %%% Local Variables:
293
3b1291f24c0d - replaved latex-mode to yatex-mode
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 290
diff changeset
439 %%% mode: yatex
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
440 %%% TeX-master: "00book"
349
84ae26ab0ac3 started mq-collab.tex
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 293
diff changeset
441 %%% End: