[bug] unlock branch if we fail to lock repo
Robert Collins
robertc at robertcollins.net
Fri Jun 30 19:55:40 BST 2006
On Fri, 2006-06-30 at 13:49 -0500, John Arbash Meinel wrote:
> -----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).
open the repository twice:
b = self.make_branch()
r = b.bzrdir.open_repository()
r.lock_write()
b.lock_write()
-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/d4312e67/attachment.pgp
More information about the bazaar
mailing list