annotate en/mq-collab.tex @ 105:ecacb6b4c9fd

Grouping patches in the series file.
author Bryan O'Sullivan <bos@serpentine.com>
date Sat, 21 Oct 2006 11:05:51 -0700
parents 32bf9a5f22c0
children 9cbc5d0db542
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1 \chapter{Advanced uses of Mercurial Queues}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
3 While it's easy to pick up straightforward uses of Mercurial Queues,
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
4 use of a little discipline and some of MQ's less frequently used
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
5 capabilities makes it possible to work in complicated development
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
6 environments.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
7
105
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
8 In this chapter, I will use as an example a technique I have used to
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
9 manage the development of an Infiniband device driver for the Linux
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
10 kernel. The driver in question is large (at least as drivers go),
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
11 with 25,000 lines of code spread across 35 source files. It is
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
12 maintained by a small team of developers.
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
13
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
14 While much of the material in this chapter is specific to Linux, the
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
15 same principles apply to any code base for which you're not the
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
16 primary owner, and upon which you need to do a lot of development.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
17
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
18 \section{The problem of many targets}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
19
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
20 The Linux kernel changes rapidly, and has never been internally
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
21 stable; developers frequently make drastic changes between releases.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
22 This means that a version of the driver that works well with a
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
23 particular released version of the kernel will not even \emph{compile}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
24 correctly against, typically, any other version.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
25
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
26 To maintain a driver, we have to keep a number of distinct versions of
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
27 Linux in mind.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
28 \begin{itemize}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
29 \item One target is the main Linux kernel development tree.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
30 Maintenance of the code is in this case partly shared by other
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
31 developers in the kernel community, who make ``drive-by''
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
32 modifications to the driver as they develop and refine kernel
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
33 subsystems.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
34 \item We also maintain a number of ``backports'' to older versions of
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
35 the Linux kernel, to support the needs of customers who are running
105
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
36 older Linux distributions that do not incorporate our drivers. (To
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
37 \emph{backport} a piece of code is to modify it to work in an older
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
38 version of its target environment than the version it was developed
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
39 for.)
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
40 \item Finally, we make software releases on a schedule that is
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
41 necessarily not aligned with those used by Linux distributors and
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
42 kernel developers, so that we can deliver new features to customers
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
43 without forcing them to upgrade their entire kernels or
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
44 distributions.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
45 \end{itemize}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
46
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
47 \subsection{Tempting approaches that don't work well}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
48
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
49 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
50 has to target many different environments.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
51
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
52 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
53 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
54 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
55 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
56 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
57 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
58 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
59 probably stop the driver from compiling.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
60
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
61 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
62 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
63 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
64 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
65 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
66 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
67 difficult to understand and maintain.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
68
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
69 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
70 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
71 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
72 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
73 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
74 by people I don't know, without me even finding out about it until
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
75 after the changes show up in Linus's tree.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
76
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
77 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
78 generate well-formed patches to submit upstream.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
79
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
80 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
81 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
82 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
83 pleasant.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
84
105
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
85 \section{Conditionally applying patches with
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
86 guards}
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 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
89 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
90 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
91 \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
92 create a simple repository for experimenting in.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
93 \interaction{mq.guards.init}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
94 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
95 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
96
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
97 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
98 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
99 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
100 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
101 depending on the guards that you have selected.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
102
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
103 A patch can have an arbitrary number of guards;
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
104 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
105 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
106 selected''). A patch with no guards is always applied.
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 \section{Controlling the guards on a patch}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
109
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
110 The \hgcmd{qguard} command lets you determine which guards should
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
111 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
112 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
113 patch.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
114 \interaction{mq.guards.qguard}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
115 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
116 a ``\texttt{+}''.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
117 \interaction{mq.guards.qguard.pos}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
118 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
119 a ``\texttt{-}''.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
120 \interaction{mq.guards.qguard.neg}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
121
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
122 \begin{note}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
123 The \hgcmd{qguard} command \emph{sets} the guards on a patch; it
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
124 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
125 \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
126 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
127 afterwards is \texttt{+c}.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
128 \end{note}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
129
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
130 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
131 which they are stored is easy both to understand and to edit by hand.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
132 (In other words, you don't have to use the \hgcmd{qguard} command if
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
133 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
134 file.)
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
135 \interaction{mq.guards.series}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
136
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
137 \section{Selecting the guards to use}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
138
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
139 The \hgcmd{qselect} command determines which guards are active at a
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
140 given time. The effect of this is to determine which patches MQ will
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
141 apply the next time you run \hgcmd{qpush}. It has no other effect; in
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
142 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
143 applied.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
144
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
145 With no arguments, the \hgcmd{qselect} command lists the guards
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
146 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
147 as the name of a guard to apply.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
148 \interaction{mq.guards.qselect.foo}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
149 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
150 the \sfilename{guards} file.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
151 \interaction{mq.guards.qselect.cat}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
152 We can see the effect the selected guards have when we run
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
153 \hgcmd{qpush}.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
154 \interaction{mq.guards.qselect.qpush}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
155
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
156 A guard cannot start with a ``\texttt{+}'' or ``\texttt{-}''
105
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
157 character. The name of a guard must start with an alphabetic
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
158 character (upper or lower case) or an underscore. The rest of the
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
159 guard's name can contain any of these characters, or a digit. These
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
160 rules are similar to those used for variable naming in most popular
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
161 programming languages. If you try to use a guard with an invalid
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
162 name, MQ will complain:
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
163 \interaction{mq.guards.qselect.error}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
164 Changing the selected guards changes the patches that are applied.
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
165 \interaction{mq.guards.qselect.quux}
105
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
166 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
167 over positive guards.
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
168 \interaction{mq.guards.qselect.foobar}
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
169
105
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
170 \section{MQ's rules for applying patches}
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
171
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
172 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
173 are as follows.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
174 \begin{itemize}
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
175 \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
176 \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
177 selected guard, the patch is skipped.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
178 \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
179 selected guard, the patch is applied.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
180 \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
181 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
182 \end{itemize}
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
183
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
184 \section{Trimming the work environment}
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
185
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
186 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
187 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
188 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
189 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
190 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
191
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
192 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
193 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
194 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
195 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
196 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
197 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
198 repository or a normal kernel tree.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
199
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
200 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
201 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
202 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
203 or no modifications.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
204
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
205 \section{Dividing up the \sfilename{series} file}
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
206
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
207 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
208 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
209 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
210
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
211 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
212 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
213 groups.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
214 \begin{itemize}
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
215 \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
216 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
217 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
218 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
219 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
220 the upstream maintainer's repository.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
221 \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
222 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
223 will accept them.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
224 \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
225 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
226 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
227 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
228 ``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
229 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
230 \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
231 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
232 \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
233 older versions of the kernel tree.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
234 \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
235 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
236 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
237 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
238 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
239 \end{itemize}
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
240
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
241 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
242 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
243 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
244 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
245 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
246
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
247 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
248 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
249 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
250 a while.
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 ``backport'' and ``do not ship'' patches float at the end of the
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
253 \sfilename{series} file in part because they'll never be shipped
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
254 upstream. Additionally, the backport patches must be applied on top
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
255 of all other patches.
ecacb6b4c9fd Grouping patches in the series file.
Bryan O'Sullivan <bos@serpentine.com>
parents: 104
diff changeset
256
104
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
257 %%% Local Variables:
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
258 %%% mode: latex
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
259 %%% TeX-master: "00book"
32bf9a5f22c0 Refactor MQ chapter into three.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
260 %%% End: