[MERGE] Makeing WorkingTree nicer to derive from.
Robert Collins
robertc at robertcollins.net
Fri Jul 21 11:18:01 BST 2006
On Fri, 2006-07-21 at 18:52 +1000, Martin Pool wrote:
> On 16 Jul 2006, Robert Collins <robertc at robertcollins.net> wrote:
> > + # manually unlock the branch, preparing a LockNotHeld error.
> > + wt.branch.unlock()
> > + # the branch *may* still be locked here, if its an all-in-one
> > + # implementation
> > + self.assertRaises(errors.LockNotHeld, wt.unlock)
>
> Uh, so if it's still held it won't raise the exception, will it
Right, thats why the assertion is on *wt* not on *branch* :). The
comment explains why there is no assertion about the branch lock
status :).
>
> > + def test_failing_to_lock_branch_does_not_lock(self):
> > + """If the branch cannot be locked, dont lock the tree."""
>
> I think you can afford to say _does_not_lock_tree, and similarly below. :-)
Sure.
> > + # Many implementations treat read-locks as non-blocking, but some
> > + # treat them as blocking with writes.. Accordingly we test this by
> > + # opening the branch twice, and locking the branch for write in the
> > + # second instance. Our lock contract requires separate instances to
> > + # mutually exclude if a lock is exclusive at all: If we get no error
> > + # locking, the test still passes.
> > + wt = self.make_branch_and_tree('.')
> > + branch_copy = branch.Branch.open('.')
> > + branch_copy.lock_write()
> > + try:
> > + try:
> > + wt.lock_read()
> > + except:
> > + # any error here means the locks are exclusive in some
> > + # manner
> > + self.assertFalse(wt.is_locked())
> > + self.assertFalse(wt.branch.is_locked())
> > + return
>
> Consider KeyboardInterrupt, and the rule against bare excepts. I think
> in every case we should get a LockError; if any of the classes allow a
> bare IOError up we should fix them.
fair comment. I'll change this to catch LockError.
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/20060721/b322daf2/attachment.pgp
More information about the bazaar
mailing list