[bug] unlock branch if we fail to lock repo

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


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

Robert Collins wrote:
> On Fri, 2006-06-30 at 13:19 -0500, John Arbash Meinel wrote:
> 
> 
>> 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.
> 
> yes, lock the repository for write, then lock the branch. *boom*.
> i.e.
> b = self.make_branch()
> b.repository.lock_write()
> b.lock_write()
> 
> should trigger an exception.

I don't think so, because lock_write() is re-entrant safe. It keeps a
counter.
Now, we can't call lock_write() if we are currently in readonly mode. So
doing:

b = self.make_branch()
b.repository.lock_read()
b.lock_write()

Would work, but we can't test lock_read() in the same way. (because
lock_read() when you have a write lock is also allowed).

> 
>> Also, should we be asserting that this works across all branch formats?
> 
> Yes.
> 
> Rob

Anyway, I'm writing a simple wrapper object that can record what
lock_read/write/unlock calls are called, so we can assert that
everything is being done in the right order.

John
=:->

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

iD8DBQFEpXJFJdeBCYSNAAMRAv4kAJ0ZxtAAr69Dd+k8nu6RkRKFwG6jXgCfQ3/4
1ODyuJUWDwALsqQxvP/OLyo=
=Q5Fw
-----END PGP SIGNATURE-----




More information about the bazaar mailing list