Rev 6535: Always means always. Full test suite revealed a possible further simplication. in file:///home/vila/src/bzr/bugs/1020007-branchformat4-lock/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Mon Jul 2 10:42:23 UTC 2012
At file:///home/vila/src/bzr/bugs/1020007-branchformat4-lock/
------------------------------------------------------------
revno: 6535
revision-id: v.ladeuil+lp at free.fr-20120702104223-1cm6c2rjg96iz9u9
parent: v.ladeuil+lp at free.fr-20120702093422-izgrn2ponj81wu69
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 1020007-branchformat4-lock
timestamp: Mon 2012-07-02 12:42:23 +0200
message:
Always means always. Full test suite revealed a possible further simplication.
-------------- next part --------------
=== modified file 'bzrlib/plugins/weave_fmt/branch.py'
--- a/bzrlib/plugins/weave_fmt/branch.py 2012-06-30 06:34:22 +0000
+++ b/bzrlib/plugins/weave_fmt/branch.py 2012-07-02 10:42:23 +0000
@@ -50,18 +50,14 @@
"""
if not self.is_locked():
self._note_lock('w')
- # All-in-one needs to always unlock/lock.
- self.repository._warn_if_deprecated(self)
- self.repository.lock_write()
- took_lock = True
- else:
- took_lock = False
+ # All-in-one needs to always unlock/lock.
+ self.repository._warn_if_deprecated(self)
+ self.repository.lock_write()
try:
return BranchWriteLockResult(self.unlock,
self.control_files.lock_write(token=token))
except:
- if took_lock:
- self.repository.unlock()
+ self.repository.unlock()
raise
def lock_read(self):
@@ -71,18 +67,14 @@
"""
if not self.is_locked():
self._note_lock('r')
- # All-in-one needs to always unlock/lock.
- self.repository._warn_if_deprecated(self)
- self.repository.lock_read()
- took_lock = True
- else:
- took_lock = False
+ # All-in-one needs to always unlock/lock.
+ self.repository._warn_if_deprecated(self)
+ self.repository.lock_read()
try:
self.control_files.lock_read()
return LogicalLockResult(self.unlock)
except:
- if took_lock:
- self.repository.unlock()
+ self.repository.unlock()
raise
@only_raises(errors.LockNotHeld, errors.LockBroken)
More information about the bazaar-commits
mailing list