/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 breezy/__init__.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-21 19:09:26 UTC
  • mfrom: (6622.1.36 breezy)
  • Revision ID: jelmer@jelmer.uk-20170521190926-5vtz8xaf0e9ylrpc
Merge rename to breezy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""All of bzr.
18
18
 
19
 
Developer documentation is available at
20
 
http://doc.bazaar.canonical.com/bzr.dev/developers/
21
 
 
22
 
The project website is at http://bazaar.canonical.com/
23
 
 
24
 
Some particularly interesting things in bzrlib are:
25
 
 
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.
 
22
 
 
23
Some particularly interesting things in breezy are:
 
24
 
 
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
29
 
31
30
We hope you enjoy this library.
32
31
"""
35
34
 
36
35
import time
37
36
 
38
 
# Keep track of when bzrlib was first imported, so that we can give rough
39
 
# timestamps relative to program start in the log file kept by bzrlib.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.
40
39
_start_time = time.time()
41
40
 
42
41
import codecs
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.
57
56
 
58
 
version_info = (2, 8, 0, 'dev', 1)
 
57
version_info = (3, 0, 0, 'dev', 1)
59
58
 
60
59
# API compatibility version
61
 
api_minimum_version = (2, 4, 0)
 
60
api_minimum_version = (3, 0, 0)
62
61
 
63
62
 
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()
132
131
 
133
132
 
134
133
__version__ = _format_version_tuple(version_info)
159
158
    return new_enc
160
159
 
161
160
 
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"
171
170
else:
172
171
    _fs_enc = codecs.lookup(_fs_enc).name
173
172
 
174
173
 
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
188
187
 
189
188
 
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.
192
191
 
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.
195
194
 
196
195
    More options may be added in future so callers should use named arguments.
197
196
 
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.
203
202
 
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
206
205
        the caller.
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.
213
212
    """
214
 
    from bzrlib import library_state, trace
 
213
    from breezy import library_state, trace
215
214
    if setup_ui:
216
 
        import bzrlib.ui
 
215
        import breezy.ui
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)
221
220
    else:
222
221
        ui_factory = None
223
222
    tracer = trace.DefaultConfig()