Rev 6315: (gz) Restore global_state correctly and clean up imports in in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/

Patch Queue Manager pqm at pqm.ubuntu.com
Mon Nov 28 14:19:56 UTC 2011


At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 6315 [merge]
revision-id: pqm at pqm.ubuntu.com-20111128141956-yl7aefec4py39k12
parent: pqm at pqm.ubuntu.com-20111128135433-xoddhlxx9qgi4u5k
parent: martin.packman at canonical.com-20111128114507-o2ra8tpwjthztf19
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2011-11-28 14:19:56 +0000
message:
  (gz) Restore global_state correctly and clean up imports in
   bzrlib.library_state (Martin Packman)
modified:
  bzrlib/library_state.py        library_state.py-20100625053036-962zdkiik8k6m5jx-1
=== modified file 'bzrlib/library_state.py'
--- a/bzrlib/library_state.py	2011-11-16 15:57:14 +0000
+++ b/bzrlib/library_state.py	2011-11-28 11:45:07 +0000
@@ -25,7 +25,14 @@
 import bzrlib
 from bzrlib.lazy_import import lazy_import
 lazy_import(globals(), """
-from bzrlib import config
+from bzrlib import (
+    cleanup,
+    config,
+    osutils,
+    symbol_versioning,
+    trace,
+    ui,
+    )
 """)
 
 
@@ -81,17 +88,12 @@
         # isolation within the same interpreter.  It's not reached on normal
         # in-process run_bzr calls.  If it's broken, we expect that
         # TestRunBzrSubprocess may fail.
-        import bzrlib
+        self.cleanups = cleanup.ObjectWithCleanups()
+
         if bzrlib.version_info[3] == 'final':
-            from bzrlib.symbol_versioning import suppress_deprecation_warnings
-            warning_cleanup = suppress_deprecation_warnings(override=True)
-        else:
-            warning_cleanup = None
+            self.cleanups.add_cleanup(
+                symbol_versioning.suppress_deprecation_warnings(override=True))
 
-        import bzrlib.cleanup
-        self.cleanups = bzrlib.cleanup.ObjectWithCleanups()
-        if warning_cleanup:
-            self.cleanups.add_cleanup(warning_cleanup)
         self._trace.__enter__()
 
         self._orig_ui = bzrlib.ui.ui_factory
@@ -104,14 +106,11 @@
 
     def __exit__(self, exc_type, exc_val, exc_tb):
         self.cleanups.cleanup_now()
-        import bzrlib.ui
-        bzrlib.trace._flush_stdout_stderr()
-        bzrlib.trace._flush_trace()
-        import bzrlib.osutils
-        bzrlib.osutils.report_extension_load_failures()
+        trace._flush_stdout_stderr()
+        trace._flush_trace()
+        osutils.report_extension_load_failures()
         self._ui.__exit__(None, None, None)
         self._trace.__exit__(None, None, None)
-        bzrlib.ui.ui_factory = self._orig_ui
-        global global_state
-        global_state = self.saved_state
+        ui.ui_factory = self._orig_ui
+        bzrlib.global_state = self.saved_state
         return False # propogate exceptions.




More information about the bazaar-commits mailing list