/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 18:10:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6623.
  • Revision ID: jelmer@jelmer.uk-20170521181028-zn04pdfw0od9hfj3
Rename brzlib => breezy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
http://doc.bazaar.canonical.com/bzr.dev/developers/,
21
21
it should mostly also apply to Breezy.
22
22
 
23
 
Some particularly interesting things in brzlib are:
 
23
Some particularly interesting things in breezy are:
24
24
 
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
29
29
 
30
30
We hope you enjoy this library.
31
31
"""
34
34
 
35
35
import time
36
36
 
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()
40
40
 
41
41
import codecs
126
126
    # hack as soon as possible so that as much of the standard library can
127
127
    # benefit, including the 'string' module.
128
128
    del sys._brz_lazy_regex
129
 
    import brzlib.lazy_regex
130
 
    brzlib.lazy_regex.install_lazy_compile()
 
129
    import breezy.lazy_regex
 
130
    breezy.lazy_regex.install_lazy_compile()
131
131
 
132
132
 
133
133
__version__ = _format_version_tuple(version_info)
159
159
 
160
160
 
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
187
187
 
188
188
 
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.
191
191
 
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.
194
194
 
195
195
    More options may be added in future so callers should use named arguments.
196
196
 
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.
202
202
 
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
205
205
        the caller.
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.
212
212
    """
213
 
    from brzlib import library_state, trace
 
213
    from breezy import library_state, trace
214
214
    if setup_ui:
215
 
        import brzlib.ui
 
215
        import breezy.ui
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)
220
220
    else:
221
221
        ui_factory = None
222
222
    tracer = trace.DefaultConfig()