[bug] unlock branch if we fail to lock repo

Robert Collins robertc at robertcollins.net
Fri Jun 30 19:08:43 BST 2006


On Fri, 2006-06-30 at 10:20 -0500, John Arbash Meinel wrote:
> -----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.

+1

> Should we be doing the same thing for 'lock_read()' even though it isn't
> really locking anything?

Yes, some repos etc do lock.

Rob
-- 
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060701/ddd7a774/attachment.pgp 


More information about the bazaar mailing list