20
20
http://doc.bazaar.canonical.com/bzr.dev/developers/,
21
21
it should mostly also apply to Breezy.
23
Some particularly interesting things in brzlib are:
23
Some particularly interesting things in breezy are:
25
* brzlib.initialize -- setup the library for use
26
* brzlib.plugin.load_plugins -- load all installed plugins
27
* brzlib.branch.Branch.open -- open a branch
28
* brzlib.workingtree.WorkingTree.open -- open a working tree
25
* breezy.initialize -- setup the library for use
26
* breezy.plugin.load_plugins -- load all installed plugins
27
* breezy.branch.Branch.open -- open a branch
28
* breezy.workingtree.WorkingTree.open -- open a working tree
30
30
We hope you enjoy this library.
37
# Keep track of when brzlib was first imported, so that we can give rough
38
# timestamps relative to program start in the log file kept by brzlib.trace.
37
# Keep track of when breezy was first imported, so that we can give rough
38
# timestamps relative to program start in the log file kept by breezy.trace.
39
39
_start_time = time.time()
161
161
# When running under the brz script, override bad filesystem default encoding.
162
# This is not safe to do for all users of brzlib, other scripts should instead
162
# This is not safe to do for all users of breezy, other scripts should instead
163
163
# just ensure a usable locale is set via the $LANG variable on posix systems.
164
164
_fs_enc = sys.getfilesystemencoding()
165
165
if getattr(sys, "_brz_default_fs_enc", None) is not None:
181
181
# global variable.
182
182
# If using this variable by looking it up (because it can't be easily obtained)
183
183
# it is important to store the reference you get, rather than looking it up
184
# repeatedly; that way your code will behave properly in the brzlib test suite
184
# repeatedly; that way your code will behave properly in the breezy test suite
185
185
# and from programs that do use multiple library contexts.
186
186
global_state = None
189
189
def initialize(setup_ui=True, stdin=None, stdout=None, stderr=None):
190
"""Set up everything needed for normal use of brzlib.
190
"""Set up everything needed for normal use of breezy.
192
Most applications that embed brzlib, including brz itself, should call
192
Most applications that embed breezy, including brz itself, should call
193
193
this function to initialize various subsystems.
195
195
More options may be added in future so callers should use named arguments.
197
197
The object returned by this function can be used as a contex manager
198
198
through the 'with' statement to automatically shut down when the process
199
is finished with brzlib. However it's not necessary to
200
separately enter the context as well as starting brz: brzlib is ready to
199
is finished with breezy. However it's not necessary to
200
separately enter the context as well as starting brz: breezy is ready to
201
201
go when this function returns.
203
203
:param setup_ui: If true (default) use a terminal UI; otherwise
204
some other ui_factory must be assigned to `brzlib.ui.ui_factory` by
204
some other ui_factory must be assigned to `breezy.ui.ui_factory` by
206
206
:param stdin, stdout, stderr: If provided, use these for terminal IO;
207
207
otherwise use the files in `sys`.
208
:return: A context manager for the use of brzlib. The __exit__
208
:return: A context manager for the use of breezy. The __exit__
209
209
should be called by the caller before exiting their process or
210
otherwise stopping use of brzlib. Advanced callers can use
210
otherwise stopping use of breezy. Advanced callers can use
211
211
BzrLibraryState directly.
213
from brzlib import library_state, trace
213
from breezy import library_state, trace
216
216
stdin = stdin or sys.stdin
217
217
stdout = stdout or sys.stdout
218
218
stderr = stderr or sys.stderr
219
ui_factory = brzlib.ui.make_ui_for_terminal(stdin, stdout, stderr)
219
ui_factory = breezy.ui.make_ui_for_terminal(stdin, stdout, stderr)
221
221
ui_factory = None
222
222
tracer = trace.DefaultConfig()