19
Developer documentation is available at
20
http://doc.bazaar.canonical.com/bzr.dev/developers/
22
The project website is at http://bazaar.canonical.com/
24
Some particularly interesting things in bzrlib are:
26
* bzrlib.initialize -- setup the library for use
27
* bzrlib.plugin.load_plugins -- load all installed plugins
28
* bzrlib.branch.Branch.open -- open a branch
29
* bzrlib.workingtree.WorkingTree.open -- open a working tree
19
Developer documentation for Bazaar is available at
20
http://doc.bazaar.canonical.com/bzr.dev/developers/,
21
it should mostly also apply to Breezy.
23
Some particularly interesting things in breezy are:
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
31
30
We hope you enjoy this library.
55
54
# Python version 2.0 is (2, 0, 0, 'final', 0)." Additionally we use a
56
55
# releaselevel of 'dev' for unreleased under-development code.
58
version_info = (2, 8, 0, 'dev', 1)
57
version_info = (3, 0, 0, 'dev', 1)
60
59
# API compatibility version
61
api_minimum_version = (2, 4, 0)
60
api_minimum_version = (3, 0, 0)
64
63
def _format_version_tuple(version_info):
122
121
# lazy_regex import must be done after _format_version_tuple definition
123
122
# to avoid "no attribute '_format_version_tuple'" error when using
124
123
# deprecated_function in the lazy_regex module.
125
if getattr(sys, '_bzr_lazy_regex', False):
126
# The 'bzr' executable sets _bzr_lazy_regex. We install the lazy regex
124
if getattr(sys, '_brz_lazy_regex', False):
125
# The 'brz' executable sets _brz_lazy_regex. We install the lazy regex
127
126
# hack as soon as possible so that as much of the standard library can
128
127
# benefit, including the 'string' module.
129
del sys._bzr_lazy_regex
130
import bzrlib.lazy_regex
131
bzrlib.lazy_regex.install_lazy_compile()
128
del sys._brz_lazy_regex
129
import breezy.lazy_regex
130
breezy.lazy_regex.install_lazy_compile()
134
133
__version__ = _format_version_tuple(version_info)
162
# When running under the bzr script, override bad filesystem default encoding.
163
# This is not safe to do for all users of bzrlib, other scripts should instead
161
# When running under the brz script, override bad filesystem default encoding.
162
# This is not safe to do for all users of breezy, other scripts should instead
164
163
# just ensure a usable locale is set via the $LANG variable on posix systems.
165
164
_fs_enc = sys.getfilesystemencoding()
166
if getattr(sys, "_bzr_default_fs_enc", None) is not None:
165
if getattr(sys, "_brz_default_fs_enc", None) is not None:
167
166
if (_fs_enc is None or codecs.lookup(_fs_enc).name == "ascii"):
168
_fs_enc = _patch_filesystem_default_encoding(sys._bzr_default_fs_enc)
167
_fs_enc = _patch_filesystem_default_encoding(sys._brz_default_fs_enc)
169
168
if _fs_enc is None:
170
169
_fs_enc = "ascii"
172
171
_fs_enc = codecs.lookup(_fs_enc).name
175
# bzr has various bits of global state that are slowly being eliminated.
174
# brz has various bits of global state that are slowly being eliminated.
176
175
# This variable is intended to permit any new state-like things to be attached
177
176
# to a library_state.BzrLibraryState object rather than getting new global
178
177
# variables that need to be hunted down. Accessing the current BzrLibraryState
182
181
# global variable.
183
182
# If using this variable by looking it up (because it can't be easily obtained)
184
183
# it is important to store the reference you get, rather than looking it up
185
# repeatedly; that way your code will behave properly in the bzrlib test suite
184
# repeatedly; that way your code will behave properly in the breezy test suite
186
185
# and from programs that do use multiple library contexts.
187
186
global_state = None
190
189
def initialize(setup_ui=True, stdin=None, stdout=None, stderr=None):
191
"""Set up everything needed for normal use of bzrlib.
190
"""Set up everything needed for normal use of breezy.
193
Most applications that embed bzrlib, including bzr itself, should call
194
this function to initialize various subsystems.
192
Most applications that embed breezy, including brz itself, should call
193
this function to initialize various subsystems.
196
195
More options may be added in future so callers should use named arguments.
198
197
The object returned by this function can be used as a contex manager
199
198
through the 'with' statement to automatically shut down when the process
200
is finished with bzrlib. However (from bzr 2.4) it's not necessary to
201
separately enter the context as well as starting bzr: bzrlib 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
202
201
go when this function returns.
204
:param setup_ui: If true (default) use a terminal UI; otherwise
205
some other ui_factory must be assigned to `bzrlib.ui.ui_factory` by
203
:param setup_ui: If true (default) use a terminal UI; otherwise
204
some other ui_factory must be assigned to `breezy.ui.ui_factory` by
207
206
:param stdin, stdout, stderr: If provided, use these for terminal IO;
208
207
otherwise use the files in `sys`.
209
:return: A context manager for the use of bzrlib. The __exit__
208
:return: A context manager for the use of breezy. The __exit__
210
209
should be called by the caller before exiting their process or
211
otherwise stopping use of bzrlib. Advanced callers can use
210
otherwise stopping use of breezy. Advanced callers can use
212
211
BzrLibraryState directly.
214
from bzrlib import library_state, trace
213
from breezy import library_state, trace
217
216
stdin = stdin or sys.stdin
218
217
stdout = stdout or sys.stdout
219
218
stderr = stderr or sys.stderr
220
ui_factory = bzrlib.ui.make_ui_for_terminal(stdin, stdout, stderr)
219
ui_factory = breezy.ui.make_ui_for_terminal(stdin, stdout, stderr)
222
221
ui_factory = None
223
222
tracer = trace.DefaultConfig()