[bug] unlock branch if we fail to lock repo

John Arbash Meinel john at arbash-meinel.com
Fri Jun 30 19:19:03 BST 2006


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

Robert Collins wrote:
> On Fri, 2006-06-30 at 10:20 -0500, John Arbash Meinel wrote:

...

>> 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

Okay, I'll go ahead and do a once over to make sure we are doing the
right thing.

Is there a good way to test two-phase without doing fake objects? Right
now the easiest way to test it is to create a Branch, but override
.repository with an instrumented one that forces the lock_write to fail.

Also, should we be asserting that this works across all branch formats?

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEpWsXJdeBCYSNAAMRAsbJAJ9NlZxz0fHciTsSK6jTPmYD1bkJlACgyLFJ
lbEYzZ9cyQBaIOm/WiI6V1U=
=9T9E
-----END PGP SIGNATURE-----




More information about the bazaar mailing list