Rev 5312: (lifeless) Return self from the new context managers so that new objects in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Mon Jun 21 22:59:56 BST 2010


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5312 [merge]
revision-id: pqm at pqm.ubuntu.com-20100621215953-vfo3e4ubs1gjc6ez
parent: pqm at pqm.ubuntu.com-20100621092900-k5hq09vixq5peyqr
parent: robertc at robertcollins.net-20100621200323-cq4ue2try98gznq5
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2010-06-21 22:59:53 +0100
message:
  (lifeless) Return self from the new context managers so that new objects
   used with with statements are usable. (Robert Collins)
modified:
  bzrlib/__init__.py             __init__.py-20050309040759-33e65acf91bbcd5d
  bzrlib/ui/__init__.py          ui.py-20050824083933-8cf663c763ba53a9
=== modified file 'bzrlib/__init__.py'
--- a/bzrlib/__init__.py	2010-06-21 04:16:16 +0000
+++ b/bzrlib/__init__.py	2010-06-21 20:03:23 +0000
@@ -164,9 +164,10 @@
         More options may be added in future so callers should use named
         arguments.
 
-        BzrLibraryState implements the Python 2.5 Context Manager protocol, and
-        can be used with the with statement. Upon __enter__ the global
-        variables in use by bzr are set, and they are cleared on __exit__.
+        BzrLibraryState implements the Python 2.5 Context Manager protocol
+        PEP343, and can be used with the with statement. Upon __enter__ the
+        global variables in use by bzr are set, and they are cleared on
+        __exit__.
 
         :param setup_ui: If true (default) use a terminal UI; otherwise 
             some other ui_factory must be assigned to `bzrlib.ui.ui_factory` by
@@ -203,6 +204,7 @@
         global global_state
         self.saved_state = global_state
         global_state = self
+        return self # This is bound to the 'as' clause in a with statement.
 
     def __exit__(self, exc_type, exc_val, exc_tb):
         self.cleanups.cleanup_now()

=== modified file 'bzrlib/ui/__init__.py'
--- a/bzrlib/ui/__init__.py	2010-06-21 03:15:55 +0000
+++ b/bzrlib/ui/__init__.py	2010-06-21 20:03:23 +0000
@@ -132,6 +132,7 @@
         Override in a concrete factory class if initialisation before use is
         needed.
         """
+        return self # This is bound to the 'as' clause in a with statement.
 
     def __exit__(self, exc_type, exc_val, exc_tb):
         """Context manager exit support.




More information about the bazaar-commits mailing list