~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/__init__.py

  • Committer: Robert Collins
  • Date: 2010-04-08 04:34:03 UTC
  • mfrom: (5138 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5139.
  • Revision ID: robertc@robertcollins.net-20100408043403-56z0d07vdqrx7f3t
Update bugfix for 528114 to trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
# Python version 2.0 is (2, 0, 0, 'final', 0)."  Additionally we use a
45
45
# releaselevel of 'dev' for unreleased under-development code.
46
46
 
47
 
version_info = (2, 1, 2, 'dev', 0)
 
47
version_info = (2, 2, 0, 'dev', 1)
48
48
 
49
 
# API compatibility version: bzrlib is currently API compatible with 1.15.
50
 
api_minimum_version = (2, 1, 0)
 
49
# API compatibility version
 
50
api_minimum_version = (2, 2, 0)
51
51
 
52
52
 
53
53
def _format_version_tuple(version_info):
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)