~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to doc/developers/integration.txt

  • Committer: Martin Pool
  • Date: 2010-06-02 05:03:31 UTC
  • mto: This revision was merged to the branch mainline in revision 5279.
  • Revision ID: mbp@canonical.com-20100602050331-n2p1qt8hfsahspnv
Correct more sloppy use of the term 'Linux'

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
Starting with bzrlib
15
15
====================
16
16
 
17
 
Within bzr
18
 
----------
19
 
 
20
 
When using bzrlib within the ``bzr`` program (for instance as a bzr
21
 
plugin), bzrlib's global state is already available for use.
22
 
 
23
 
From outside bzr
24
 
----------------
25
 
 
26
 
To use bzrlib outside of ``bzr`` some global state needs to be setup.
27
 
bzrlib needs ways to handle user input, passwords, a place to emit
28
 
progress bars, logging setup appropriately for your program. The easiest
29
 
way to set all this up in the same fashion ``bzr`` does is to call
30
 
``bzrlib.initialize``. This returns a context manager within which bzrlib
31
 
functions will work correctly. See the pydoc for ``bzrlib.initialize`` for
32
 
more information. In Python 2.4 the ``with`` keyword is not supported and
33
 
so you need to use the context manager manually::
34
 
 
35
 
  # This sets up your ~/.bzr.log, ui factory and so on and so forth. It is
36
 
  # not safe to use as a doctest.
37
 
  library_state = bzrlib.initialize()
38
 
  library_state.__enter__()
39
 
  try:
40
 
      pass
41
 
      # do stuff here
42
 
  finally:
43
 
      library_state.__exit__(None, None, None)
 
17
Before doing anything else with bzrlib, you should run `bzrlib.initialize`
 
18
which sets up some global state.  
44
19
 
45
20
 
46
21
Running bzr commands
68
43
 
69
44
 
70
45
This gives us a WorkingTree object, which has various methods spread over
71
 
itself, and its parent classes MutableTree and Tree - it's worth having a
 
46
itself, and its parent classes MutableTree and Tree - its worth having a
72
47
look through these three files (workingtree.py, mutabletree.py and tree.py)
73
48
to see which methods are available.
74
49