Merge lp:~mbp/bzr/733136-lock_url into lp:bzr/2.3

Proposed by Martin Pool
Status: Merged
Approved by: Martin Pool
Approved revision: no longer in the source branch.
Merged at revision: 5634
Proposed branch: lp:~mbp/bzr/733136-lock_url
Merge into: lp:bzr/2.3
Diff against target: 58 lines (+16/-7)
2 files modified
bzrlib/lockdir.py (+12/-7)
doc/en/release-notes/bzr-2.3.txt (+4/-0)
To merge this branch: bzr merge lp:~mbp/bzr/733136-lock_url
Reviewer Review Type Date Requested Status
Martin Pool Approve
John A Meinel Pending
Review via email: mp+55706@code.launchpad.net

This proposal supersedes a proposal from 2011-03-31.

Commit message

avoid UnboundLocal error when locking fails (bug 733136)

Description of the change

This fixes bug 733136 by just moving the variable declaration to a place it will definitely be seen.

To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote : Posted in a previous version of this proposal

The fix isn't especially shallow, but I am for not writing a test for it. If people feel I should, I can.

Revision history for this message
John A Meinel (jameinel) wrote : Posted in a previous version of this proposal

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 3/31/2011 7:42 AM, Martin Pool wrote:
> Martin Pool has proposed merging lp:~mbp/bzr/733136-lock_url into lp:bzr.
>
> Requested reviews:
> bzr-core (bzr-core)
> Related bugs:
> Bug #733136 in Bazaar: "UnboundLocalError: local variable 'lock_url' in wait_lock"
> https://bugs.launchpad.net/bzr/+bug/733136
>
> For more details, see:
> https://code.launchpad.net/~mbp/bzr/733136-lock_url/+merge/55682
>
> This does a kind of shallow fix for bug 733136 by just moving the variable declaration to a place it will definitely be seen.

What if we pull this out into a helper function, so we don't clutter the
function itself?

Note that if this is getting triggered, there is another bug. Which is
that QBzr is being unable to get write-access to the config when it
wants to set its values. So it sounds like a lock-race or lock
confusion. (bzr is locking and qbzr is locking on top of it.)

Anyway, the fix seems fine, just cleaner in a helper. Would you want to
target 2.3 instead?

John
=:->

 merge: approve
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2UKn8ACgkQJdeBCYSNAAPlDQCgq+DWQ/GdJ3d/pykjYOPrCbQ+
9wkAoK68su5hgMw2Xg8iE7OVCuzOOjsv
=OyWm
-----END PGP SIGNATURE-----

review: Approve
Revision history for this message
Martin Pool (mbp) wrote :

rebase to 2.3

review: Approve
Revision history for this message
Martin Pool (mbp) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/lockdir.py'
2--- bzrlib/lockdir.py 2011-01-12 20:31:15 +0000
3+++ bzrlib/lockdir.py 2011-03-31 09:08:48 +0000
4@@ -537,6 +537,17 @@
5 hook(hook_result)
6 return result
7
8+ def lock_url_for_display(self):
9+ """Give a nicely-printable representation of the URL of this lock."""
10+ # As local lock urls are correct we display them.
11+ # We avoid displaying remote lock urls.
12+ lock_url = self.transport.abspath(self.path)
13+ if lock_url.startswith('file://'):
14+ lock_url = lock_url.split('.bzr/')[0]
15+ else:
16+ lock_url = ''
17+ return lock_url
18+
19 def wait_lock(self, timeout=None, poll=None, max_attempts=None):
20 """Wait a certain period for a lock.
21
22@@ -566,6 +577,7 @@
23 deadline_str = None
24 last_info = None
25 attempt_count = 0
26+ lock_url = self.lock_url_for_display()
27 while True:
28 attempt_count += 1
29 try:
30@@ -590,13 +602,6 @@
31 if deadline_str is None:
32 deadline_str = time.strftime('%H:%M:%S',
33 time.localtime(deadline))
34- # As local lock urls are correct we display them.
35- # We avoid displaying remote lock urls.
36- lock_url = self.transport.abspath(self.path)
37- if lock_url.startswith('file://'):
38- lock_url = lock_url.split('.bzr/')[0]
39- else:
40- lock_url = ''
41 user, hostname, pid, time_ago = formatted_info
42 msg = ('%s lock %s ' # lock_url
43 'held by ' # start
44
45=== modified file 'doc/en/release-notes/bzr-2.3.txt'
46--- doc/en/release-notes/bzr-2.3.txt 2011-03-23 11:07:49 +0000
47+++ doc/en/release-notes/bzr-2.3.txt 2011-03-31 09:08:48 +0000
48@@ -44,6 +44,10 @@
49 ancestry of the source branch, like it does in all other cases.
50 (John Arbash Meinel, #465517)
51
52+* Fix ``UnboundLocalError: local variable 'lock_url' in wait_lock`` error,
53+ especially while trying to save configuration from QBzr.
54+ (Martin Pool, #733136)
55+
56 * Fix "Unable to obtain lock" error when pushing to a bound branch if tags
57 had changed. Bazaar was attempting to open and lock the master branch
58 twice in this case. (Andrew Bennetts, #733350)

Subscribers

People subscribed via source and target branches