~bzr-loom-devs/bzr-loom/trunk

42 by Robert Collins
Add a HOWTO.
1
Loom, a plugin for bzr to assist in developing focused patches.
2
Copyright (C) 2006 Canonical Limited.
3
4
This program is free software; you can redistribute it and/or modify
65 by Robert Collins
GPL Version 2.
5
it under the terms of the GNU General Public License version 2 as published
6
by the Free Software Foundation.
42 by Robert Collins
Add a HOWTO.
7
8
This program is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
GNU General Public License for more details.
12
13
You should have received a copy of the GNU General Public License
14
along with this program; if not, write to the Free Software
15
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
16
17
18
A quick guide to using looms
19
++++++++++++++++++++++++++++
20
21
Overview
22
========
23
138.1.2 by Gary Wilson Jr.
Replaced the overview text with the text from the launchpad site, which is a better description of what loom is.
24
Loom is a Bazaar plugin to assist in developing focused patches. It adds a
25
'loom' to a bzr branch. A loom allows the development of multiple patches at
26
once, while still giving each patch a branch of its own.
42 by Robert Collins
Add a HOWTO.
27
28
29
Installation
30
============
31
32
Loom is most easily installed by symlinking its source directory to
138.1.3 by Gary Wilson Jr.
Fixes to the HOWTO:
33
``~/.bazaar/plugins/loom``. Alternatively, you can install it for the entire
34
machine using ``python setup.py --install``.
42 by Robert Collins
Add a HOWTO.
35
138.1.1 by Gary Wilson Jr.
Added and corrected several inline and block literal text markers.
36
You can verify that loom is installed by running ``bzr plugins`` and looking
73 by Robert Collins
Better grammar in HOW.
37
for loom in the output.
42 by Robert Collins
Add a HOWTO.
38
39
40
Getting Started
41
===============
42
138.1.3 by Gary Wilson Jr.
Fixes to the HOWTO:
43
1. First, convert an upstream version branch into a loom. In this example, I
44
   call the upstream branch ``upstream``. In your upstream branch, run::
45
46
       % bzr nick upstream
47
       % bzr loomify
48
49
   This will convert your branch to a loom - from this point forward the loom
50
   plugin is required to work on this branch. It will also create a thread
51
   called ``upstream``, which will act as a pristine branch to track the
52
   upstream code.
53
54
   The ``bzr nick`` is used to index into the threads in the loom. The current
55
   thread is the bzr nick for the branch and is recorded in commits as such.
56
   You can use ``bzr nick newname`` to change the name of a thread.
57
58
   If you ``bzr push`` to a new branch now, it will make the remote branch a
59
   loom, as well. However, if you push to an existing, normal bzr branch, then
60
   the current thread of your loom is what will be pushed. You can use this to
61
   publish individual threads for people that do not have the loom plugin.
62
63
2. Now you can create another thread, which will represent the first patch you
64
   are building on top of the upstream code::
65
66
       % bzr create-thread "demo-patch"
67
68
   This creates a new thread, named ``demo-patch``, above your current thread
69
   and switches you onto the new thread. You can see which thread you are
70
   currently on using the ``show-loom`` command::
71
72
       % bzr show-loom
73
       =>demo-patch
74
       upstream
75
76
   The output represents a stack of threads, with the ``=>`` marker indicating
77
   the current thread. At the top of the thread stack is the thread you are
78
   working towards, below that are the threads that it depends upon, and at the
79
   bottom is the thread that represents the upstream code being built upon.
80
42 by Robert Collins
Add a HOWTO.
81
82
Working with the loom
83
=====================
84
85
You can now work with the thread you are in just like a normal bzr branch -
86
you can pull work from a normal branch into it, perform commits, uncommits,
138.1.3 by Gary Wilson Jr.
Fixes to the HOWTO:
87
look at bzr log, etc. There are, however, additional commands that the loom
88
plugin provides - they are covered in the following sections. For more
89
information on them, use ``bzr help command-name``.
42 by Robert Collins
Add a HOWTO.
90
91
92
Starting a new patch
93
--------------------
94
95
When you make a new patch, you need to decide where in the loom it should go.
96
Best practice is to put the thread for this new patch as close to the upstream
138.1.3 by Gary Wilson Jr.
Fixes to the HOWTO:
97
as makes sense. For instance, if you are a Debian maintainer with the following
98
loom::
99
100
    =>debian
101
      configure-update
102
      compilation-fix
103
      upstream
104
105
...and you have received a bug report and patch that corrects a typographical
42 by Robert Collins
Add a HOWTO.
106
error in the manual, you could put this in one of the existing threads - but
138.1.1 by Gary Wilson Jr.
Added and corrected several inline and block literal text markers.
107
none fit that well. You could put it above the ``debian`` thread, but it does
138.1.3 by Gary Wilson Jr.
Fixes to the HOWTO:
108
not depend on the ``debian`` thread; however, the ``debian`` thread *does*
109
depend on it, because the ``debian`` thread represents what you will be
110
uploading to the distro. You could put it above ``configure-update``, above
111
``compilation-fix``, or right above ``upstream``.
42 by Robert Collins
Add a HOWTO.
112
138.1.3 by Gary Wilson Jr.
Fixes to the HOWTO:
113
So, where should you put this new thread?
42 by Robert Collins
Add a HOWTO.
114
115
If none of the threads are in the process of being merged into upstream, and
138.1.3 by Gary Wilson Jr.
Fixes to the HOWTO:
116
this is something you plan to send upstream immediately, then the best place
117
for this new thread is probably directly above ``upstream``. On the other hand,
118
if the ``compilation-fix`` and ``configure-update`` threads are already in the
119
process of being merged into upstream, then the best place for the new thread
120
is directly above the ``configure-update`` thread.
42 by Robert Collins
Add a HOWTO.
121
138.1.3 by Gary Wilson Jr.
Fixes to the HOWTO:
122
To create a new thread above the ``configure-update`` thread, use the
123
``down-thread`` command once to switch to the ``configure-update`` thread, and
124
then invoke ``create-thread``::
42 by Robert Collins
Add a HOWTO.
125
126
    % bzr down-thread
127
    % bzr create-thread documentation-fixes
128
129
Now you can apply the patch and commit it::
130
131
    % patch -0 < doco-fix.patch
138.1.3 by Gary Wilson Jr.
Fixes to the HOWTO:
132
    % bzr commit
42 by Robert Collins
Add a HOWTO.
133
134
135
Updating to a new upstream version
136
----------------------------------
137
138
When upstream makes a new release, you need to bring their changes into your
71.1.1 by Jelmer Vernooij
Spelling fixes.
139
baseline thread - the bottom thread, and then merge the changes up through your
138.1.3 by Gary Wilson Jr.
Fixes to the HOWTO:
140
loom to the top thread.
141
142
1. First, use ``down-thread`` repeatedly to move down to the bottom thread of
143
   the loom (this will be made easier in the future with an automatic mode of
144
   operation)::
145
146
       % bzr down-thread
147
       % bzr down-thread
148
       % bzr down-thread
149
       % bzr show-loom
150
         debian
151
         configure-update
152
         compilation-fix
153
       =>upstream
154
155
2. Next, pull the new upstream release. You can use ``bzr pull`` or ``bzr
156
   merge`` for this, depending on whether you want the ``upstream`` branch to
157
   be a clone of the upstream branch you are tracking, or to reflect the times
158
   that you have updated to upstream::
159
160
       % bzr pull UPSTREAM-URL
161
162
3. Now, integrate the changes from upstream into your loom by moving up through
138.1.4 by Gary Wilson Jr.
Updated the ``up-thread`` demo in the HOWTO to reflect changes to making the ``--auto`` option the default.
163
   your threads using the ``up-thread`` command.  ``up-thread`` will
164
   automatically perform a merge and commit for each thread in your loom,
165
   moving up one thread at a time and stopping after it has committed to the
166
   top thread::
138.1.3 by Gary Wilson Jr.
Fixes to the HOWTO:
167
168
       % bzr up-thread
169
       All changes applied successfully.
170
       Moved to thread 'compilation-fix'.
138.1.4 by Gary Wilson Jr.
Updated the ``up-thread`` demo in the HOWTO to reflect changes to making the ``--auto`` option the default.
171
       Committing to: /demo
172
       Committed revision 140.
173
       All changes applied successfully.
174
       Moved to thread 'configure-update'.
175
       Committing to: /demo
176
       Committed revision 141.
177
       All changes applied successfully.
178
       Moved to thread 'debian'.
179
       Committing to: /demo
180
       Committed revision 142.
181
182
   If you would prefer to commit the change to each thread yourself, instead of
183
   letting ``up-thread`` perform this automatically, just specify the
184
   ``--manual`` flag.  In this mode of operation, the merge will still happen
185
   automatically, but you'll have the opportunity to inspect the changes before
186
   committing them yourself.  Continue using ``up-thread`` and committing
187
   until you've reached the top, or drop the ``--manual`` flag to automatically
188
   perform the merge and commit on the remaining threads::
189
190
       % bzr up-thread --manual
191
       All changes applied successfully.
192
       Moved to thread 'compilation-fix'.
138.1.3 by Gary Wilson Jr.
Fixes to the HOWTO:
193
       % bzr diff
194
       % bzr st
195
       % bzr commit -m 'New upstream release.'
138.1.4 by Gary Wilson Jr.
Updated the ``up-thread`` demo in the HOWTO to reflect changes to making the ``--auto`` option the default.
196
       Committing to: /demo
197
       Committed revision 140.
198
       % bzr up-thread
199
       All changes applied successfully.
200
       Moved to thread 'configure-update'.
201
       Committing to: /demo
202
       Committed revision 141.
203
       All changes applied successfully.
204
       Moved to thread 'debian'.
205
       Committing to: /demo
206
       Committed revision 142.
138.1.3 by Gary Wilson Jr.
Fixes to the HOWTO:
207
138.1.4 by Gary Wilson Jr.
Updated the ``up-thread`` demo in the HOWTO to reflect changes to making the ``--auto`` option the default.
208
4. Once at the top, you are fully updated to upstream and you've adjusted every
209
   thread to the new release. This is a good time to record your loom, so that
210
   you can push a new release::
138.1.3 by Gary Wilson Jr.
Fixes to the HOWTO:
211
212
       % bzr record "Update to 1.2."
213
214
215
After upstream has merged your patch
216
------------------------------------
217
218
When you are performing an update to upstream and they have merged your patch,
219
your thread will suddenly lose all its changes. Lets say in the example above
220
that upstream has merged your changes in the ``configure-update`` thread. When
221
you update to that thread, a call to ``diff -r below:`` will show no changes::
222
223
    % bzr up-thread
224
    All changes applied successfully.
225
    Moved to thread 'configure-update'.
42 by Robert Collins
Add a HOWTO.
226
    % bzr diff -r thread:
227
228
Because there are no changes to the thread below, this thread has been fully
138.1.3 by Gary Wilson Jr.
Fixes to the HOWTO:
229
merged.  Unless you are planning further configure changes, you don't need it
230
in your stack anymore. You remove a thread using the ``combine-thread``
231
command. ``combine-thread`` is the reverse of ``create-thread`` - where
42 by Robert Collins
Add a HOWTO.
232
``create-thread`` makes a new thread above the current one, ``combine-thread``
138.1.3 by Gary Wilson Jr.
Fixes to the HOWTO:
233
combines the current thread into the one below it::
42 by Robert Collins
Add a HOWTO.
234
235
    % bzr show-loom
236
      debian
138.1.3 by Gary Wilson Jr.
Fixes to the HOWTO:
237
    =>configure-update
238
      compilation-fix
42 by Robert Collins
Add a HOWTO.
239
      upstream
240
    % bzr combine-thread
241
    % bzr show-loom
242
      debian
138.1.3 by Gary Wilson Jr.
Fixes to the HOWTO:
243
    =>compilation-fix
42 by Robert Collins
Add a HOWTO.
244
      upstream
120 by Robert Collins
A new revision specifier ``below:`` has been added. (Robert Collins, #195282)
245
246
247
Showing a single patch
248
----------------------
249
250
You can show a single patch without knowing the names of other threads by using
138.1.1 by Gary Wilson Jr.
Added and corrected several inline and block literal text markers.
251
the ``below:`` and ``thread:`` revision specifiers::
120 by Robert Collins
A new revision specifier ``below:`` has been added. (Robert Collins, #195282)
252
253
    % bzr show-loom
254
      debian
138.1.3 by Gary Wilson Jr.
Fixes to the HOWTO:
255
    =>configure-update
120 by Robert Collins
A new revision specifier ``below:`` has been added. (Robert Collins, #195282)
256
      upstream
138.1.3 by Gary Wilson Jr.
Fixes to the HOWTO:
257
    % bzr diff -r below:configure-update..thread:configure-update