~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/__init__.py

Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
IGNORE_FILENAME = ".bzrignore"
36
36
 
37
37
 
38
 
__copyright__ = "Copyright 2005-2010 Canonical Ltd."
 
38
__copyright__ = "Copyright 2005, 2006, 2007, 2008, 2009 Canonical Ltd."
39
39
 
40
40
# same format as sys.version_info: "A tuple containing the five components of
41
41
# the version number: major, minor, micro, releaselevel, and serial. All
46
46
 
47
47
version_info = (2, 2, 0, 'dev', 1)
48
48
 
49
 
# API compatibility version
 
49
# API compatibility version: bzrlib is currently API compatible with 1.15.
50
50
api_minimum_version = (2, 1, 0)
51
51
 
52
52
 
116
116
def test_suite():
117
117
    import tests
118
118
    return tests.test_suite()
119
 
 
120
 
 
121
 
def initialize(
122
 
    setup_ui=True,
123
 
    stdin=None, stdout=None, stderr=None):
124
 
    """Set up everything needed for normal use of bzrlib.
125
 
 
126
 
    Most applications that embed bzrlib, including bzr itself, should call
127
 
    this function to initialize various subsystems.  
128
 
 
129
 
    More options may be added in future so callers should use named arguments.
130
 
 
131
 
    :param setup_ui: If true (default) use a terminal UI; otherwise 
132
 
        something else must be put into `bzrlib.ui.ui_factory`.
133
 
    :param stdin, stdout, stderr: If provided, use these for terminal IO;
134
 
        otherwise use the files in `sys`.
135
 
    """
136
 
    # TODO: mention this in a guide to embedding bzrlib
137
 
    #
138
 
    # NB: This function tweaks so much global state it's hard to test it in
139
 
    # isolation within the same interpreter.  It's not reached on normal
140
 
    # in-process run_bzr calls.  If it's broken, we expect that
141
 
    # TestRunBzrSubprocess may fail.
142
 
    
143
 
    import atexit
144
 
    import bzrlib.trace
145
 
 
146
 
    bzrlib.trace.enable_default_logging()
147
 
    atexit.register(bzrlib.trace._flush_stdout_stderr)
148
 
    atexit.register(bzrlib.trace._flush_trace)
149
 
 
150
 
    import bzrlib.ui
151
 
    if stdin is None:
152
 
        stdin = sys.stdin
153
 
    if stdout is None:
154
 
        stdout = sys.stdout
155
 
    if stderr is None:
156
 
        stderr = sys.stderr
157
 
 
158
 
    if setup_ui:
159
 
        bzrlib.ui.ui_factory = bzrlib.ui.make_ui_for_terminal(
160
 
            stdin, stdout, stderr)
161
 
 
162
 
    if bzrlib.version_info[3] == 'final':
163
 
        from bzrlib.symbol_versioning import suppress_deprecation_warnings
164
 
        suppress_deprecation_warnings(override=True)
165
 
 
166
 
    import bzrlib.osutils
167
 
    atexit.register(osutils.report_extension_load_failures)