14
14
Starting with bzrlib
15
15
====================
17
Before doing anything else with bzrlib, you should run `bzrlib.initialize`
18
which sets up some global state.
20
When using bzrlib within the ``bzr`` program (for instance as a bzr
21
plugin), bzrlib's global state is already available for use.
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::
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__()
43
library_state.__exit__(None, None, None)
21
46
Running bzr commands