/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 bzrlib/library_state.py

  • Committer: Jelmer Vernooij
  • Date: 2011-11-28 15:59:39 UTC
  • mfrom: (6316 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6318.
  • Revision ID: jelmer@samba.org-20111128155939-709ll9ta5aqduig0
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
import bzrlib
26
26
from bzrlib.lazy_import import lazy_import
27
27
lazy_import(globals(), """
28
 
from bzrlib import config
 
28
from bzrlib import (
 
29
    cleanup,
 
30
    config,
 
31
    osutils,
 
32
    symbol_versioning,
 
33
    trace,
 
34
    ui,
 
35
    )
29
36
""")
30
37
 
31
38
 
81
88
        # isolation within the same interpreter.  It's not reached on normal
82
89
        # in-process run_bzr calls.  If it's broken, we expect that
83
90
        # TestRunBzrSubprocess may fail.
84
 
        import bzrlib
 
91
        self.cleanups = cleanup.ObjectWithCleanups()
 
92
 
85
93
        if bzrlib.version_info[3] == 'final':
86
 
            from bzrlib.symbol_versioning import suppress_deprecation_warnings
87
 
            warning_cleanup = suppress_deprecation_warnings(override=True)
88
 
        else:
89
 
            warning_cleanup = None
 
94
            self.cleanups.add_cleanup(
 
95
                symbol_versioning.suppress_deprecation_warnings(override=True))
90
96
 
91
 
        import bzrlib.cleanup
92
 
        self.cleanups = bzrlib.cleanup.ObjectWithCleanups()
93
 
        if warning_cleanup:
94
 
            self.cleanups.add_cleanup(warning_cleanup)
95
97
        self._trace.__enter__()
96
98
 
97
99
        self._orig_ui = bzrlib.ui.ui_factory
104
106
 
105
107
    def __exit__(self, exc_type, exc_val, exc_tb):
106
108
        self.cleanups.cleanup_now()
107
 
        import bzrlib.ui
108
 
        bzrlib.trace._flush_stdout_stderr()
109
 
        bzrlib.trace._flush_trace()
110
 
        import bzrlib.osutils
111
 
        bzrlib.osutils.report_extension_load_failures()
 
109
        trace._flush_stdout_stderr()
 
110
        trace._flush_trace()
 
111
        osutils.report_extension_load_failures()
112
112
        self._ui.__exit__(None, None, None)
113
113
        self._trace.__exit__(None, None, None)
114
 
        bzrlib.ui.ui_factory = self._orig_ui
115
 
        global global_state
116
 
        global_state = self.saved_state
 
114
        ui.ui_factory = self._orig_ui
 
115
        bzrlib.global_state = self.saved_state
117
116
        return False # propogate exceptions.