Rev 5634: (mbp) avoid UnboundLocal error when locking fails (bug 733136) (Martin Pool) in file:///home/pqm/archives/thelove/bzr/2.3/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Mar 31 10:02:49 UTC 2011


At file:///home/pqm/archives/thelove/bzr/2.3/

------------------------------------------------------------
revno: 5634 [merge]
revision-id: pqm at pqm.ubuntu.com-20110331100246-xi0z401lm15xrnr5
parent: pqm at pqm.ubuntu.com-20110331092432-lgbslvzkl06y12xk
parent: mbp at canonical.com-20110331090127-w6wqfh5kseeqjg0f
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.3
timestamp: Thu 2011-03-31 10:02:46 +0000
message:
  (mbp) avoid UnboundLocal error when locking fails (bug 733136) (Martin Pool)
modified:
  bzrlib/lockdir.py              lockdir.py-20060220222025-98258adf27fbdda3
  doc/en/release-notes/bzr-2.3.txt NEWS-20050323055033-4e00b5db738777ff
=== modified file 'bzrlib/lockdir.py'
--- a/bzrlib/lockdir.py	2011-01-12 20:31:15 +0000
+++ b/bzrlib/lockdir.py	2011-03-31 09:01:27 +0000
@@ -537,6 +537,17 @@
             hook(hook_result)
         return result
 
+    def lock_url_for_display(self):
+        """Give a nicely-printable representation of the URL of this lock."""
+        # As local lock urls are correct we display them.
+        # We avoid displaying remote lock urls.
+        lock_url = self.transport.abspath(self.path)
+        if lock_url.startswith('file://'):
+            lock_url = lock_url.split('.bzr/')[0]
+        else:
+            lock_url = ''
+        return lock_url
+
     def wait_lock(self, timeout=None, poll=None, max_attempts=None):
         """Wait a certain period for a lock.
 
@@ -566,6 +577,7 @@
         deadline_str = None
         last_info = None
         attempt_count = 0
+        lock_url = self.lock_url_for_display()
         while True:
             attempt_count += 1
             try:
@@ -590,13 +602,6 @@
                 if deadline_str is None:
                     deadline_str = time.strftime('%H:%M:%S',
                                                  time.localtime(deadline))
-                # As local lock urls are correct we display them.
-                # We avoid displaying remote lock urls.
-                lock_url = self.transport.abspath(self.path)
-                if lock_url.startswith('file://'):
-                    lock_url = lock_url.split('.bzr/')[0]
-                else:
-                    lock_url = ''
                 user, hostname, pid, time_ago = formatted_info
                 msg = ('%s lock %s '        # lock_url
                     'held by '              # start

=== modified file 'doc/en/release-notes/bzr-2.3.txt'
--- a/doc/en/release-notes/bzr-2.3.txt	2011-03-31 08:47:23 +0000
+++ b/doc/en/release-notes/bzr-2.3.txt	2011-03-31 10:02:46 +0000
@@ -48,6 +48,10 @@
   ancestry of the source branch, like it does in all other cases.
   (John Arbash Meinel, #465517)
 
+* Fix ``UnboundLocalError: local variable 'lock_url' in wait_lock`` error,
+  especially while trying to save configuration from QBzr.
+  (Martin Pool, #733136)
+
 * Fix "Unable to obtain lock" error when pushing to a bound branch if tags
   had changed.  Bazaar was attempting to open and lock the master branch
   twice in this case.  (Andrew Bennetts, #733350)




More information about the bazaar-commits mailing list