/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to HACKING

Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
.. contents::
6
6
 
7
7
(The current version of this document is available in the file ``HACKING``
8
 
in the source tree, or at http://bazaar-ng.org/hacking.html)
 
8
in the source tree, or at http://doc.bazaar-vcs.org/current/hacking.html)
9
9
 
10
10
Overall
11
11
=======
38
38
  pipelines.
39
39
 
40
40
  Recommended values are 
41
 
    0- OK, 
42
 
    1- Conflicts in merge-like operations, or changes are present in
 
41
    0. OK, 
 
42
    1. Conflicts in merge-like operations, or changes are present in
43
43
       diff-like operations. 
44
 
    2- Unrepresentable diff changes (i.e. binary files that we cannot show 
 
44
    2. Unrepresentable diff changes (i.e. binary files that we cannot show 
45
45
       a diff of).
46
 
    3- An error or exception has occurred.
 
46
    3. An error or exception has occurred.
47
47
 
48
48
Evolving interfaces
49
49
-------------------
194
194
    may not catch every case but it's still useful sometimes.
195
195
 
196
196
 
 
197
Factories
 
198
---------
 
199
 
 
200
In some places we have variables which point to callables that construct
 
201
new instances.  That is to say, they can be used a lot like class objects,
 
202
but they shouldn't be *named* like classes:
 
203
 
 
204
> I think that things named FooBar should create instances of FooBar when
 
205
> called. Its plain confusing for them to do otherwise. When we have
 
206
> something that is going to be used as a class - that is, checked for via
 
207
> isinstance or other such idioms, them I would call it foo_class, so that
 
208
> it is clear that a callable is not sufficient. If it is only used as a
 
209
> factory, then yes, foo_factory is what I would use.
 
210
 
 
211
 
197
212
Writing output
198
213
==============
199
214
 
245
260
option, then you should be writing a UI test.  If you are both adding UI
246
261
functionality and library functionality, you will want to write tests for 
247
262
both the UI and the core behaviours.  We call UI tests 'blackbox' tests
248
 
and they are found in bzrlib/tests/blackbox/*.py. 
 
263
and they are found in ``bzrlib/tests/blackbox/*.py``. 
249
264
 
250
265
When writing blackbox tests please honour the following conventions:
251
266
 
267
282
    command changes it name or signature. Ideally only the tests for a
268
283
    given command are affected when a given command is changed.
269
284
 
 
285
Doctests
 
286
--------
 
287
 
 
288
We make selective use of doctests__.  In general they should provide 
 
289
*examples* within the API documentation which can incidentally be tested.  We 
 
290
don't try to test every important case using doctests -- regular Python
 
291
tests are generally a better solution.
 
292
 
 
293
Most of these are in ``bzrlib/doc/api``.  More additions are welcome.
 
294
 
 
295
  __ http://docs.python.org/lib/module-doctest.html
 
296
 
 
297
 
270
298
Running tests
271
299
=============
272
300
Currently, bzr selftest is used to invoke tests.
275
303
 
276
304
  ./bzr selftest -v blackbox
277
305
 
 
306
To skip a particular test (or set of tests), you need to use a negative
 
307
match, like so::
 
308
 
 
309
  ./bzr selftest '^(?!.*blackbox)'  
 
310
 
278
311
 
279
312
Errors and exceptions
280
313
=====================
294
327
    indexes into the branch's revision history.
295
328
 
296
329
 
 
330
Transport
 
331
=========
 
332
 
 
333
The ``Transport`` layer handles access to local or remote directories.
 
334
Each Transport object acts like a logical connection to a particular
 
335
directory, and it allows various operations on files within it.  You can
 
336
*clone* a transport to get a new Transport connected to a subdirectory or
 
337
parent directory.
 
338
 
 
339
Transports are not used for access to the working tree.  At present
 
340
working trees are always local and they are accessed through the regular
 
341
Python file io mechanisms.
 
342
 
 
343
filenames vs URLs
 
344
-----------------
 
345
 
 
346
Transports work in URLs.  Take note that URLs are by definition only
 
347
ASCII - the decision of how to encode a Unicode string into a URL must be
 
348
taken at a higher level, typically in the Store.  (Note that Stores also
 
349
escape filenames which cannot be safely stored on all filesystems, but
 
350
this is a different level.)
 
351
 
 
352
The main reason for this is that it's not possible to safely roundtrip a
 
353
URL into Unicode and then back into the same URL.  The URL standard
 
354
gives a way to represent non-ASCII bytes in ASCII (as %-escapes), but
 
355
doesn't say how those bytes represent non-ASCII characters.  (They're not
 
356
guaranteed to be UTF-8 -- that is common but doesn't happen everywhere.)
 
357
 
 
358
For example if the user enters the url ``http://example/%e0`` there's no
 
359
way to tell whether that character represents "latin small letter a with
 
360
grave" in iso-8859-1, or "latin small letter r with acute" in iso-8859-2
 
361
or malformed UTF-8.  So we can't convert their URL to Unicode reliably.
 
362
 
 
363
Equally problematic if we're given a url-like string containing non-ascii
 
364
characters (such as the accented a) we can't be sure how to convert that
 
365
to the correct URL, because we don't know what encoding the server expects
 
366
for those characters.  (Although this is not totally reliable we might still
 
367
accept these and assume they should be put into UTF-8.)
 
368
 
 
369
A similar edge case is that the url ``http://foo/sweet%2Fsour`` contains
 
370
one directory component whose name is "sweet/sour".  The escaped slash is
 
371
not a directory separator.  If we try to convert URLs to regular Unicode
 
372
paths this information will be lost.
 
373
 
 
374
This implies that Transports must natively deal with URLs; for simplicity
 
375
they *only* deal with URLs and conversion of other strings to URLs is done
 
376
elsewhere.  Information they return, such as from ``list_dir``, is also in
 
377
the form of URL components.
 
378
 
 
379
 
 
380
Unicode and Encoding Support
 
381
============================
 
382
 
 
383
This section discusses various techniques that Bazaar uses to handle
 
384
characters that are outside the ASCII set.
 
385
 
 
386
``Command.outf``
 
387
----------------
 
388
 
 
389
When a ``Command`` object is created, it is given a member variable
 
390
accessible by ``self.outf``.  This is a file-like object, which is bound to
 
391
``sys.stdout``, and should be used to write information to the screen,
 
392
rather than directly writing to ``sys.stdout`` or calling ``print``.
 
393
This file has the ability to translate Unicode objects into the correct
 
394
representation, based on the console encoding.  Also, the class attribute
 
395
``encoding_type`` will effect how unprintable characters will be
 
396
handled.  This parameter can take one of 3 values:
 
397
 
 
398
  replace
 
399
    Unprintable characters will be represented with a suitable replacement
 
400
    marker (typically '?'), and no exception will be raised. This is for
 
401
    any command which generates text for the user to review, rather than
 
402
    for automated processing.
 
403
    For example: ``bzr log`` should not fail if one of the entries has text
 
404
    that cannot be displayed.
 
405
  
 
406
  strict
 
407
    Attempting to print and unprintable character will cause a UnicodeError.
 
408
    This is for commands that are intended more as scripting support, rather
 
409
    than plain user review.
 
410
    For exampl: ``bzr ls`` is designed to be used with shell scripting. One
 
411
    use would be ``bzr ls --null --unknows | xargs -0 rm``.  If ``bzr``
 
412
    printed a filename with a '?', the wrong file could be deleted. (At the
 
413
    very least, the correct file would not be deleted). An error is used to
 
414
    indicate that the requested action could not be performed.
 
415
  
 
416
  exact
 
417
    Do not attempt to automatically convert Unicode strings. This is used
 
418
    for commands that must handle conversion themselves.
 
419
    For example: ``bzr diff`` needs to translate Unicode paths, but should
 
420
    not change the exact text of the contents of the files.
 
421
 
 
422
 
 
423
``bzrlib.urlutils.unescape_for_display``
 
424
----------------------------------------
 
425
 
 
426
Because Transports work in URLs (as defined earlier), printing the raw URL
 
427
to the user is usually less than optimal. Characters outside the standard
 
428
set are printed as escapes, rather than the real character, and local
 
429
paths would be printed as ``file://`` urls. The function
 
430
``unescape_for_display`` attempts to unescape a URL, such that anything
 
431
that cannot be printed in the current encoding stays an escaped URL, but
 
432
valid characters are generated where possible.
 
433
 
 
434
 
297
435
Merge/review process
298
436
====================
299
437
 
337
475
so, please reply and say so.)
338
476
 
339
477
 
340
 
:: vim:tw=74:ai
 
478
Making installers for OS Windows
 
479
================================
 
480
To build a win32 installer, see the instructions on the wiki page:
 
481
http://bazaar-vcs.org/BzrWin32Installer
 
482
 
 
483
 
 
484
:: vim: ft=rst tw=74 ai