[bug] unlock branch if we fail to lock repo
John Arbash Meinel
john at arbash-meinel.com
Fri Jun 30 16:20:04 BST 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
The current bzr code gives this error if you ask to update a branch
while another branch is being updated:
bzr: ERROR: Could not acquire lock
LockDir(file:///path/.bzr/repository/lock)
H:\dev\bzr\bzr.dev\bzrlib\lockable_files.py:110: UserWarning: file group
LockableFiles(<bzrlib.transport.local.LocalTransport
url=file:///path/.bzr/branch/>) was not explicitly unlocked
warn("file group %r was not explicitly unlocked" % self)
The reason is that locking the branch control files is succeeding, but
locking the repository is failing, and when the exception is raised, we
aren't doing any cleanup.
We are doing the right thing in WorkingTree.lock_write(), so I propose
we do the same in Branch.lock_write() with the following code:
def lock_write(self):
"""Lock both the branch and repository"""
self.control_files.lock_write()
try:
self.repository.lock_write()
except:
self.control_files.unlock()
raise
It is a small thing, but I think it gives better errors.
Should we be doing the same thing for 'lock_read()' even though it isn't
really locking anything?
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFEpUEkJdeBCYSNAAMRAqZUAJ9bP1NadQN1vPkw/cb8IFBiJb9DFACdEaxT
xMemO/wV0RfKqBK43QNXilc=
=BWHu
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list