~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to doc/en/developer-guide/HACKING.txt

  • Committer: John Ferlito
  • Date: 2009-09-02 04:31:45 UTC
  • mto: (4665.7.1 serve-init)
  • mto: This revision was merged to the branch mainline in revision 4913.
  • Revision ID: johnf@inodes.org-20090902043145-gxdsfw03ilcwbyn5
Add a debian init script for bzr --serve

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
document, send a merge request or new text to the mailing list.
13
13
 
14
14
The current version of this document is available in the file 
15
 
``doc/developers/HACKING.txt`` in the source tree, or at
 
15
``doc/en/developer-guide/HACKING.txt`` in the source tree, or at
16
16
http://doc.bazaar-vcs.org/bzr.dev/en/developer-guide/HACKING.html
17
17
 
18
18
See also:
46
46
If nothing else, perhaps you'll find inspiration in how other developers
47
47
have solved their challenges.
48
48
 
 
49
Finding Something To Do
 
50
=======================
 
51
 
 
52
Ad-hoc performance work can also be done. One useful tool is the 'evil' debug
 
53
flag. For instance running ``bzr -Devil commit -m "test"`` will log a backtrace
 
54
to the bzr log file for every method call which triggers a slow or non-scalable
 
55
part of the bzr library. So checking that a given command with ``-Devil`` has
 
56
no backtraces logged to the log file is a good way to find problem function
 
57
calls that might be nested deep in the code base.
49
58
 
50
59
Planning and Discussing Changes
51
60
===============================
73
82
Bazaar Development in a Nutshell
74
83
================================
75
84
 
76
 
Looking for a 10 minute introduction to submitting a change?
77
 
See http://bazaar-vcs.org/BzrGivingBack.
78
 
 
79
 
TODO: Merge that Wiki page into this document.
 
85
.. was from bazaar-vcs.org/BzrGivingBack
 
86
 
 
87
One of the fun things about working on a version control system like Bazaar is
 
88
that the users have a high level of proficiency in contributing back into
 
89
the tool.  Consider the following very brief introduction to contributing back
 
90
to Bazaar.  More detailed instructions are in the following sections.
 
91
 
 
92
Making the change
 
93
-----------------
 
94
 
 
95
First, get a local copy of the development mainline (See `Why make a local
 
96
copy of bzr.dev?`_.) 
 
97
::
 
98
 
 
99
 $ bzr init-repo ~/bzr
 
100
 $ cd ~/bzr
 
101
 $ bzr branch http://bazaar-vcs.org/bzr/bzr.dev/ bzr.dev
 
102
 
 
103
Now make your own branch::
 
104
 
 
105
 $ bzr branch bzr.dev 123456-my-bugfix
 
106
 
 
107
This will give you a branch called "123456-my-bugfix" that you can work on
 
108
and commit in. Here, you can study the code, make a fix or a new feature.
 
109
Feel free to commit early and often (after all, it's your branch!). 
 
110
 
 
111
Documentation improvements are an easy place to get started giving back to the
 
112
Bazaar project.  The documentation is in the `doc/` subdirectory of the Bazaar
 
113
source tree.
 
114
 
 
115
When you are done, make sure that you commit your last set of changes as well!
 
116
Once you are happy with your changes, ask for them to be merged, as described
 
117
below.
 
118
 
 
119
Making a Merge Proposal
 
120
-----------------------
 
121
 
 
122
The Bazaar developers use Launchpad to further enable a truly distributed
 
123
style of development.  Anyone can propose a branch for merging into the Bazaar
 
124
trunk.  To start this process, you need to push your branch to Launchpad.  To
 
125
do this, you will need a Launchpad account and user name, e.g.
 
126
`your_lp_username`.  You can push your branch to Launchpad directly from
 
127
Bazaar::
 
128
 
 
129
  $ bzr push lp:~your_lp_username/bzr/giveback
 
130
 
 
131
After you have pushed your branch, you will need to propose it for merging to
 
132
the Bazaar trunk.  Go to <https://launchpad.net/your_lp_username/bzr/giveback>
 
133
and choose "Propose for merging into another branch".  Select "~bzr/bzr/trunk"
 
134
to hand your changes off to the Bazaar developers for review and merging.
 
135
 
 
136
Why make a local copy of bzr.dev?
 
137
---------------------------------
 
138
 
 
139
Making a local mirror of bzr.dev is not strictly necessary, but it means
 
140
 
 
141
- You can use that copy of bzr.dev as your main bzr executable, and keep it
 
142
  up-to-date using ``bzr pull``.  
 
143
- Certain operations are faster, and can be done when offline.  For example:
 
144
 
 
145
  - ``bzr bundle``
 
146
  - ``bzr diff -r ancestor:...``
 
147
  - ``bzr merge``
 
148
 
 
149
- When it's time to create your next branch, it's more convenient.  When you 
 
150
  have further contributions to make, you should do them in their own branch::
 
151
 
 
152
    $ cd ~/bzr
 
153
    $ bzr branch bzr.dev additional_fixes
 
154
    $ cd additional_fixes # hack, hack, hack
 
155
 
80
156
 
81
157
 
82
158
Understanding the Development Process
83
159
=====================================
84
160
 
85
 
The development team follows many best-practices including:
 
161
The development team follows many practices including:
86
162
 
87
163
* a public roadmap and planning process in which anyone can participate
88
164
 
108
184
For further information, see http://bazaar-vcs.org/BzrDevelopment.
109
185
 
110
186
 
111
 
A Closer Look at the Merge & Review Process
112
 
===========================================
113
 
 
114
 
If you'd like to propose a change, please post to the
115
 
bazaar@lists.canonical.com list with a bundle, patch, or link to a
116
 
branch. Put '[PATCH]' or '[MERGE]' in the subject so Bundle Buggy
117
 
can pick it out, and explain the change in the email message text.
118
 
Remember to update the NEWS file as part of your change if it makes any
119
 
changes visible to users or plugin developers. Please include a diff
120
 
against mainline if you're giving a link to a branch.
121
 
 
122
 
You can generate a bundle like this::
123
 
 
124
 
  bzr bundle > mybundle.patch
125
 
  
126
 
A .patch extension is recommended instead of .bundle as many mail clients
127
 
will send the latter as a binary file. If a bundle would be too long or your
128
 
mailer mangles whitespace (e.g. implicitly converts Unix newlines to DOS
129
 
newlines), use the merge-directive command instead like this::
130
 
 
131
 
  bzr merge-directive http://bazaar-vcs.org http://example.org/my_branch > my_directive.patch
132
 
 
133
 
See the help for details on the arguments to merge-directive.
134
 
 
135
 
Please do **NOT** put [PATCH] or [MERGE] in the subject line if you don't
136
 
want it to be merged. If you want comments from developers rather than
137
 
to be merged, you can put '[RFC]' in the subject line.
138
 
 
139
 
Anyone is welcome to review code.  There are broadly three gates for
140
 
code to get in:
141
 
 
142
 
 * Doesn't reduce test coverage: if it adds new methods or commands,
143
 
   there should be tests for them.  There is a good test framework
144
 
   and plenty of examples to crib from, but if you are having trouble
145
 
   working out how to test something feel free to post a draft patch
146
 
   and ask for help.
147
 
 
148
 
 * Doesn't reduce design clarity, such as by entangling objects
149
 
   we're trying to separate.  This is mostly something the more
150
 
   experienced reviewers need to help check.
151
 
 
152
 
 * Improves bugs, features, speed, or code simplicity.
153
 
 
154
 
Code that goes in should pass all three. The core developers take care
155
 
to keep the code quality high and understandable while recognising that
156
 
perfect is sometimes the enemy of good. (It is easy for reviews to make
157
 
people notice other things which should be fixed but those things should
158
 
not hold up the original fix being accepted. New things can easily be
159
 
recorded in the Bug Tracker instead.)
160
 
 
161
 
Anyone can "vote" on the mailing list. Core developers can also vote using
162
 
Bundle Buggy. Here are the voting codes and their explanations.
163
 
 
164
 
:approve:  Reviewer wants this submission merged.
165
 
:tweak:    Reviewer wants this submission merged with small changes. (No
166
 
  re-review required.)
167
 
:abstain:  Reviewer does not intend to vote on this patch.
168
 
:resubmit: Please make changes and resubmit for review.
169
 
:reject:   Reviewer doesn't want this kind of change merged.
170
 
:comment:  Not really a vote. Reviewer just wants to comment, for now.
171
 
 
172
 
If a change gets two approvals from core reviewers, and no rejections,
173
 
then it's OK to come in.  Any of the core developers can bring it into the
174
 
bzr.dev trunk and backport it to maintenance branches if required.  The
175
 
Release Manager will merge the change into the branch for a pending
176
 
release, if any. As a guideline, core developers usually merge their own
177
 
changes and volunteer to merge other contributions if they were the second
178
 
reviewer to agree to a change.
179
 
 
180
 
To track the progress of proposed changes, use Bundle Buggy. See
181
 
http://bundlebuggy.aaronbentley.com/help for a link to all the
182
 
outstanding merge requests together with an explanation of the columns.
183
 
Bundle Buggy will also mail you a link to track just your change.
184
187
 
185
188
 
186
189
Preparing a Sandbox for Making Changes to Bazaar
199
202
  
200
203
    bzr branch http://bazaar-vcs.org/bzr/bzr.dev/ bzr.dev
201
204
   
202
 
* keep your copy of bzr.dev prestine (by not developing in it) and keep
 
205
* keep your copy of bzr.dev pristine (by not developing in it) and keep
203
206
  it up to date (by using bzr pull)
204
207
 
205
208
* create a new branch off your local bzr.dev copy for each issue
207
210
 
208
211
This approach makes it easy to go back and make any required changes
209
212
after a code review. Resubmitting the change is then simple with no
210
 
risk of accidentially including edits related to other issues you may
 
213
risk of accidentally including edits related to other issues you may
211
214
be working on. After the changes for an issue are accepted and merged,
212
215
the associated branch can be deleted or archived as you wish.
213
216
 
255
258
    is in the ReStructuredText markup language.
256
259
 
257
260
doc/developers 
258
 
    Documentation specifically targetted at Bazaar and plugin developers.
 
261
    Documentation specifically targeted at Bazaar and plugin developers.
259
262
    (Including this document.)
260
263
    
261
264
        
262
265
 
263
266
Automatically-generated API reference information is available at 
264
267
<http://starship.python.net/crew/mwh/bzrlibapi/>.  
265
 
(There is an experimental editable version at 
266
 
<http://starship.python.net/crew/mwh/bzrlibapi-oe/>.)
267
 
See also the `Essential Domain Classes`_
268
 
section of this guide.
269
 
 
270
 
 
271
 
Essential Domain Classes
272
 
########################
273
 
 
274
 
Introducing the Object Model
 
268
 
 
269
See also the `Bazaar Architectural Overview  <../../developers/overview.html>`_.
 
270
 
 
271
 
 
272
The Code Review Process
 
273
#######################
 
274
 
 
275
All code changes coming in to Bazaar are reviewed by someone else.
 
276
Normally changes by core contributors are reviewed by one other core
 
277
developer, and changes from other people are reviewed by two core
 
278
developers.  Use intelligent discretion if the patch is trivial.
 
279
 
 
280
Good reviews do take time. They also regularly require a solid
 
281
understanding of the overall code base. In practice, this means a small
 
282
number of people often have a large review burden - with knowledge comes
 
283
responsibility. No one likes their merge requests sitting in a queue going
 
284
nowhere, so reviewing sooner rather than later is strongly encouraged.
 
285
 
 
286
 
 
287
 
 
288
 
 
289
 
 
290
Review cover letters
 
291
====================
 
292
 
 
293
Please put a "cover letter" on your merge request explaining:
 
294
 
 
295
* the reason **why** you're making this change
 
296
 
 
297
* **how** this change achieves this purpose
 
298
 
 
299
* anything else you may have fixed in passing 
 
300
 
 
301
* anything significant that you thought of doing, such as a more
 
302
  extensive fix or a different approach, but didn't or couldn't do now
 
303
 
 
304
A good cover letter makes reviewers' lives easier because they can decide
 
305
from the letter whether they agree with the purpose and approach, and then
 
306
assess whether the patch actually does what the cover letter says.
 
307
Explaining any "drive-by fixes" or roads not taken may also avoid queries
 
308
from the reviewer.  All in all this should give faster and better reviews.
 
309
Sometimes writing the cover letter helps the submitter realize something
 
310
else they need to do.  The size of the cover letter should be proportional
 
311
to the size and complexity of the patch.
 
312
 
 
313
 
 
314
Reviewing proposed changes
 
315
==========================
 
316
 
 
317
Anyone is welcome to review code, and reply to the thread with their
 
318
opinion or comments.
 
319
 
 
320
The simplest way to review a proposed change is to just read the patch on
 
321
the list or in Bundle Buggy.  For more complex changes it may be useful
 
322
to make a new working tree or branch from trunk, and merge the proposed
 
323
change into it, so you can experiment with the code or look at a wider
 
324
context.
 
325
 
 
326
There are three main requirements for code to get in:
 
327
 
 
328
* Doesn't reduce test coverage: if it adds new methods or commands,
 
329
  there should be tests for them.  There is a good test framework
 
330
  and plenty of examples to crib from, but if you are having trouble
 
331
  working out how to test something feel free to post a draft patch
 
332
  and ask for help.
 
333
 
 
334
* Doesn't reduce design clarity, such as by entangling objects
 
335
  we're trying to separate.  This is mostly something the more
 
336
  experienced reviewers need to help check.
 
337
 
 
338
* Improves bugs, features, speed, or code simplicity.
 
339
 
 
340
Code that goes in should not degrade any of these aspects.  Patches are
 
341
welcome that only cleanup the code without changing the external
 
342
behaviour.  The core developers take care to keep the code quality high
 
343
and understandable while recognising that perfect is sometimes the enemy
 
344
of good. 
 
345
 
 
346
It is easy for reviews to make people notice other things which should be
 
347
fixed but those things should not hold up the original fix being accepted.
 
348
New things can easily be recorded in the Bug Tracker instead.
 
349
 
 
350
It's normally much easier to review several smaller patches than one large
 
351
one.  You might want to use ``bzr-loom`` to maintain threads of related
 
352
work, or submit a preparatory patch that will make your "real" change
 
353
easier.
 
354
 
 
355
 
 
356
Checklist for reviewers
 
357
=======================
 
358
 
 
359
* Do you understand what the code's doing and why?
 
360
 
 
361
* Will it perform reasonably for large inputs, both in memory size and
 
362
  run time?  Are there some scenarios where performance should be
 
363
  measured?
 
364
 
 
365
* Is it tested, and are the tests at the right level?  Are there both
 
366
  blackbox (command-line level) and API-oriented tests?
 
367
 
 
368
* If this change will be visible to end users or API users, is it
 
369
  appropriately documented in NEWS?
 
370
 
 
371
* Does it meet the coding standards below?
 
372
 
 
373
* If it changes the user-visible behaviour, does it update the help
 
374
  strings and user documentation?
 
375
 
 
376
* If it adds a new major concept or standard practice, does it update the
 
377
  developer documentation?
 
378
 
 
379
* (your ideas here...)
 
380
 
 
381
 
 
382
Reviews on Launchpad
 
383
====================
 
384
 
 
385
From May 2009 on, we prefer people to propose code reviews through
 
386
Launchpad.  
 
387
 
 
388
 * <https://launchpad.net/+tour/code-review>
 
389
 
 
390
 * <https://help.launchpad.net/Code/Review>
 
391
 
 
392
Anyone can propose or comment on a merge proposal just by creating a
 
393
Launchpad account.
 
394
 
 
395
There are two ways to create a new merge proposal: through the web
 
396
interface or by email.
 
397
 
 
398
 
 
399
Proposing a merge through the web
 
400
---------------------------------
 
401
 
 
402
To create the proposal through the web, first push your branch to Launchpad.
 
403
For example, a branch dealing with documentation belonging to the Launchpad
 
404
User mbp could be pushed as ::
 
405
 
 
406
  bzr push lp:~mbp/bzr/doc
 
407
 
 
408
Then go to the branch's web page, which in this case would be
 
409
<https://code.launchpad.net/~mbp/bzr/doc>.  You can simplify this step by just
 
410
running ::
 
411
 
 
412
  bzr lp-open
 
413
 
 
414
You can then click "Propose for merging into another branch", and enter your
 
415
cover letter (see above) into the web form.  Typically you'll want to merge
 
416
into ``~bzr/bzr/trunk`` which will be the default; you might also want to
 
417
nominate merging into a release branch for a bug fix.  There is the option to
 
418
specify a specific reviewer or type of review, and you shouldn't normally
 
419
change those.
 
420
 
 
421
Submitting the form takes you to the new page about the merge proposal
 
422
containing the diff of the changes, comments by interested people, and
 
423
controls to comment or vote on the change.
 
424
 
 
425
Proposing a merge by mail
 
426
-------------------------
 
427
 
 
428
To propose a merge by mail, send a bundle to ``merge@code.launchpad.net``.
 
429
 
 
430
You can generate a merge request like this::
 
431
 
 
432
  bzr send -o bug-1234.diff
 
433
  
 
434
``bzr send`` can also send mail directly if you prefer; see the help.
 
435
 
 
436
Reviewing changes
 
437
-----------------
 
438
 
 
439
From <https://code.launchpad.net/bzr/+activereviews> you can see all
 
440
currently active reviews, and choose one to comment on.  This page also
 
441
shows proposals that are now approved and should be merged by someone with
 
442
PQM access.
 
443
 
 
444
 
 
445
Reviews through Bundle Buggy
275
446
============================
276
447
 
277
 
The core domain objects within the bazaar model are:
278
 
 
279
 
* Transport
280
 
 
281
 
* Branch
282
 
 
283
 
* Repository
284
 
 
285
 
* WorkingTree
286
 
 
287
 
Transports are explained below. See http://bazaar-vcs.org/Classes/
288
 
for an introduction to the other key classes.
289
 
 
290
 
Using Transports
291
 
================
292
 
 
293
 
The ``Transport`` layer handles access to local or remote directories.
294
 
Each Transport object acts like a logical connection to a particular
295
 
directory, and it allows various operations on files within it.  You can
296
 
*clone* a transport to get a new Transport connected to a subdirectory or
297
 
parent directory.
298
 
 
299
 
Transports are not used for access to the working tree.  At present
300
 
working trees are always local and they are accessed through the regular
301
 
Python file io mechanisms.
302
 
 
303
 
Filenames vs URLs
304
 
-----------------
305
 
 
306
 
Transports work in URLs.  Take note that URLs are by definition only
307
 
ASCII - the decision of how to encode a Unicode string into a URL must be
308
 
taken at a higher level, typically in the Store.  (Note that Stores also
309
 
escape filenames which cannot be safely stored on all filesystems, but
310
 
this is a different level.)
311
 
 
312
 
The main reason for this is that it's not possible to safely roundtrip a
313
 
URL into Unicode and then back into the same URL.  The URL standard
314
 
gives a way to represent non-ASCII bytes in ASCII (as %-escapes), but
315
 
doesn't say how those bytes represent non-ASCII characters.  (They're not
316
 
guaranteed to be UTF-8 -- that is common but doesn't happen everywhere.)
317
 
 
318
 
For example if the user enters the url ``http://example/%e0`` there's no
319
 
way to tell whether that character represents "latin small letter a with
320
 
grave" in iso-8859-1, or "latin small letter r with acute" in iso-8859-2
321
 
or malformed UTF-8.  So we can't convert their URL to Unicode reliably.
322
 
 
323
 
Equally problematic if we're given a url-like string containing non-ascii
324
 
characters (such as the accented a) we can't be sure how to convert that
325
 
to the correct URL, because we don't know what encoding the server expects
326
 
for those characters.  (Although this is not totally reliable we might still
327
 
accept these and assume they should be put into UTF-8.)
328
 
 
329
 
A similar edge case is that the url ``http://foo/sweet%2Fsour`` contains
330
 
one directory component whose name is "sweet/sour".  The escaped slash is
331
 
not a directory separator.  If we try to convert URLs to regular Unicode
332
 
paths this information will be lost.
333
 
 
334
 
This implies that Transports must natively deal with URLs; for simplicity
335
 
they *only* deal with URLs and conversion of other strings to URLs is done
336
 
elsewhere.  Information they return, such as from ``list_dir``, is also in
337
 
the form of URL components.
338
 
 
 
448
The Bundle Buggy tool used up to May 2009 is still available as a review
 
449
mechanism.
 
450
 
 
451
Sending patches for review
 
452
--------------------------
 
453
 
 
454
If you'd like to propose a change, please post to the
 
455
bazaar@lists.canonical.com list with a bundle, patch, or link to a
 
456
branch. Put ``[PATCH]`` or ``[MERGE]`` in the subject so Bundle Buggy
 
457
can pick it out, and explain the change in the email message text.
 
458
Remember to update the NEWS file as part of your change if it makes any
 
459
changes visible to users or plugin developers. Please include a diff
 
460
against mainline if you're giving a link to a branch.
 
461
 
 
462
You can generate a merge request like this::
 
463
 
 
464
  bzr send -o bug-1234.patch
 
465
  
 
466
A ``.patch`` extension is recommended instead of .bundle as many mail clients
 
467
will send the latter as a binary file.
 
468
 
 
469
``bzr send`` can also send mail directly if you prefer; see the help.
 
470
 
 
471
Please do **NOT** put [PATCH] or [MERGE] in the subject line if you don't
 
472
want it to be merged. If you want comments from developers rather than
 
473
to be merged, you can put ``[RFC]`` in the subject line.
 
474
 
 
475
If this change addresses a bug, please put the bug number in the subject
 
476
line too, in the form ``[#1]`` so that Bundle Buggy can recognize it.
 
477
 
 
478
If the change is intended for a particular release mark that in the
 
479
subject too, e.g. ``[1.6]``.
 
480
Anyone can "vote" on the mailing list by expressing an opinion. Core
 
481
developers can also vote using Bundle Buggy. Here are the voting codes and
 
482
their explanations.
 
483
 
 
484
:approve:  Reviewer wants this submission merged.
 
485
:tweak:    Reviewer wants this submission merged with small changes. (No
 
486
  re-review required.)
 
487
:abstain:  Reviewer does not intend to vote on this patch.
 
488
:resubmit: Please make changes and resubmit for review.
 
489
:reject:   Reviewer doesn't want this kind of change merged.
 
490
:comment:  Not really a vote. Reviewer just wants to comment, for now.
 
491
 
 
492
If a change gets two approvals from core reviewers, and no rejections,
 
493
then it's OK to come in.  Any of the core developers can bring it into the
 
494
bzr.dev trunk and backport it to maintenance branches if required.  The
 
495
Release Manager will merge the change into the branch for a pending
 
496
release, if any. As a guideline, core developers usually merge their own
 
497
changes and volunteer to merge other contributions if they were the second
 
498
reviewer to agree to a change.
 
499
 
 
500
To track the progress of proposed changes, use Bundle Buggy. See
 
501
http://bundlebuggy.aaronbentley.com/help for a link to all the
 
502
outstanding merge requests together with an explanation of the columns.
 
503
Bundle Buggy will also mail you a link to track just your change.
339
504
 
340
505
Coding Style Guidelines
341
506
#######################
362
527
We use 4 space indents for blocks, and never use tab characters.  (In vim,
363
528
``set expandtab``.)
364
529
 
 
530
Trailing white space should be avoided, but is allowed.
 
531
You should however not make lots of unrelated white space changes.
 
532
 
 
533
Unix style newlines (LF) are used.
 
534
 
 
535
Each file must have a newline at the end of it.
 
536
 
365
537
Lines should be no more than 79 characters if at all possible.
366
538
Lines that continue a long statement may be indented in either of 
367
539
two ways:
408
580
        marmalade,
409
581
        )
410
582
 
411
 
There should be spaces between function paramaters, but not between the
 
583
There should be spaces between function parameters, but not between the
412
584
keyword name and the value::
413
585
 
414
586
    call(1, 3, cheese=quark)
670
842
=============
671
843
 
672
844
All code should be exercised by the test suite.  See `Guide to Testing
673
 
Bazaar <testing.html>`_ for detailed information about writing tests.
 
845
Bazaar <../../developers/testing.html>`_ for detailed information about writing tests.
674
846
 
675
847
 
676
848
Core Topics
696
868
_function or ...) behind which forwards to the new API. See the
697
869
bzrlib.symbol_versioning module for decorators that take care of the
698
870
details for you - such as updating the docstring, and issuing a warning
699
 
when the old api is used.
 
871
when the old API is used.
700
872
 
701
873
For unsupported API's, it does not hurt to follow this discipline, but it's
702
874
not required. Minimally though, please try to rename things so that
795
967
should be only in the command-line tool.
796
968
 
797
969
 
 
970
Progress and Activity Indications
 
971
---------------------------------
 
972
 
 
973
bzrlib has a way for code to display to the user that stuff is happening
 
974
during a long operation.  There are two particular types: *activity* which
 
975
means that IO is happening on a Transport, and *progress* which means that
 
976
higher-level application work is occurring.  Both are drawn together by
 
977
the `ui_factory`.
 
978
 
 
979
Transport objects are responsible for calling `report_transport_activity`
 
980
when they do IO.
 
981
 
 
982
Progress uses a model/view pattern: application code acts on a
 
983
`ProgressTask` object, which notifies the UI when it needs to be
 
984
displayed.  Progress tasks form a stack.  To create a new progress task on
 
985
top of the stack, call `bzrlib.ui.ui_factory.nested_progress_bar()`, then
 
986
call `update()` on the returned ProgressTask.  It can be updated with just
 
987
a text description, with a numeric count, or with a numeric count and
 
988
expected total count.  If an expected total count is provided the view
 
989
can show the progress moving along towards the expected total.
 
990
 
 
991
The user should call `finish` on the `ProgressTask` when the logical
 
992
operation has finished, so it can be removed from the stack.
 
993
 
 
994
Progress tasks have a complex relationship with generators: it's a very
 
995
good place to use them, but because python2.4 does not allow ``finally``
 
996
blocks in generators it's hard to clean them up properly.  In this case
 
997
it's probably better to have the code calling the generator allocate a
 
998
progress task for its use and then call `finalize` when it's done, which
 
999
will close it if it was not already closed.  The generator should also
 
1000
finish the progress task when it exits, because it may otherwise be a long
 
1001
time until the finally block runs.
 
1002
 
798
1003
 
799
1004
Displaying help
800
1005
===============
861
1066
that exception specifically, or when it needs a substantially different
862
1067
format string.
863
1068
 
 
1069
#. If it is something that a caller can recover from, a custom exception
 
1070
   is reasonable. 
 
1071
 
 
1072
#. If it is a data consistency issue, using a builtin like
 
1073
   ``ValueError``/``TypeError`` is reasonable. 
 
1074
 
 
1075
#. If it is a programmer error (using an api incorrectly)
 
1076
   ``AssertionError`` is reasonable. 
 
1077
 
 
1078
#. Otherwise, use ``BzrError`` or ``InternalBzrError``.
 
1079
 
864
1080
Exception strings should start with a capital letter and should not have a
865
1081
final fullstop.  If long, they may contain newlines to break the text.
866
1082
 
1020
1236
then bzr will go into pdb post-mortem mode when an unhandled exception
1021
1237
occurs.
1022
1238
 
1023
 
If you send a SIGQUIT signal to bzr, which can be done by pressing
1024
 
Ctrl-\\ on Unix, bzr will go into the debugger immediately.  You can
1025
 
continue execution by typing ``c``.  This can be disabled if necessary
1026
 
by setting the environment variable ``BZR_SIGQUIT_PDB=0``.
 
1239
If you send a SIGQUIT or SIGBREAK signal to bzr then it will drop into the
 
1240
debugger immediately. SIGQUIT can be generated by pressing Ctrl-\\ on
 
1241
Unix.  SIGBREAK is generated with Ctrl-Pause on Windows (some laptops have
 
1242
this as Fn-Pause).  You can continue execution by typing ``c``.  This can
 
1243
be disabled if necessary by setting the environment variable
 
1244
``BZR_SIGQUIT_PDB=0``.
 
1245
 
 
1246
 
 
1247
Debug Flags
 
1248
===========
 
1249
 
 
1250
Bazaar accepts some global options starting with ``-D`` such as
 
1251
``-Dhpss``.  These set a value in `bzrlib.debug.debug_flags`, and
 
1252
typically cause more information to be written to the trace file.  Most
 
1253
`mutter` calls should be guarded by a check of those flags so that we
 
1254
don't write out too much information if it's not needed.
 
1255
 
 
1256
Debug flags may have effects other than just emitting trace messages.
 
1257
 
 
1258
Run ``bzr help global-options`` to see them all.
 
1259
 
 
1260
These flags may also be set as a comma-separated list in the
 
1261
``debug_flags`` option in e.g.  ``~/.bazaar/bazaar.conf``.  (Note that it
 
1262
must be in this global file, not in the branch or location configuration,
 
1263
because it's currently only loaded at startup time.)  For instance you may
 
1264
want to always record hpss traces and to see full error tracebacks::
 
1265
 
 
1266
    debug_flags = hpss, error
1027
1267
 
1028
1268
 
1029
1269
Jargon
1065
1305
    Attempting to print an unprintable character will cause a UnicodeError.
1066
1306
    This is for commands that are intended more as scripting support, rather
1067
1307
    than plain user review.
1068
 
    For exampl: ``bzr ls`` is designed to be used with shell scripting. One
1069
 
    use would be ``bzr ls --null --unknows | xargs -0 rm``.  If ``bzr``
 
1308
    For example: ``bzr ls`` is designed to be used with shell scripting. One
 
1309
    use would be ``bzr ls --null --unknowns | xargs -0 rm``.  If ``bzr``
1070
1310
    printed a filename with a '?', the wrong file could be deleted. (At the
1071
1311
    very least, the correct file would not be deleted). An error is used to
1072
1312
    indicate that the requested action could not be performed.
1206
1446
how to set it up and configure it.
1207
1447
 
1208
1448
 
1209
 
Reviewing Changes
1210
 
=================
1211
 
 
1212
 
Setting Up Your Workspace for Reviews
1213
 
-------------------------------------
1214
 
 
1215
 
TODO: Incorporate John Arbash Meinel's detailed email to Ian C on the
1216
 
numerous ways of setting up integration branches.
1217
 
 
1218
 
 
1219
 
The Review Checklist
1220
 
--------------------
1221
 
 
1222
 
See `A Closer Look at the Merge & Review Process`_
1223
 
for information on the gates used to decide whether code can be merged
1224
 
or not and details on how review results are recorded and communicated.
1225
 
 
1226
 
 
1227
 
The Importance of Timely Reviews
1228
 
--------------------------------
1229
 
 
1230
 
Good reviews do take time. They also regularly require a solid
1231
 
understanding of the overall code base. In practice, this means a small
1232
 
number of people often have a large review burden - with knowledge comes
1233
 
responsibility. No one like their merge requests sitting in a queue going
1234
 
nowhere, so reviewing sooner rather than later is strongly encouraged.
1235
 
 
1236
 
 
1237
1449
Submitting Changes
1238
1450
==================
1239
1451
 
1399
1611
https://blueprints.launchpad.net/bzr/. Once a blueprint for ready for
1400
1612
review, please announce it on the mailing list.
1401
1613
 
1402
 
Alternatively, send an email begining with [RFC] with the proposal to the
 
1614
Alternatively, send an email beginning with [RFC] with the proposal to the
1403
1615
list. In some cases, you may wish to attach proposed code  or a proposed
1404
1616
developer document if that best communicates the idea. Debate can then
1405
1617
proceed using the normal merge review processes.
1417
1629
Planning Releases
1418
1630
=================
1419
1631
 
1420
 
Roadmaps
1421
 
--------
1422
 
 
1423
 
As the two senior developers, Martin Pool and Robert Collins coordinate
1424
 
the overall Bazaar product development roadmap. Core developers provide
1425
 
input and review into this, particularly during sprints. It's totally
1426
 
expected that community members ought to be working on things that
1427
 
interest them the most. The roadmap is valuable though because it provides
1428
 
context for understanding where the product is going as a whole and why.
1429
 
 
1430
1632
 
1431
1633
Using Releases and Milestones in Launchpad
1432
1634
------------------------------------------