[RFC] bug in write lock?
Jan Balster
jan at merlinux.de
Thu Aug 3 11:01:33 BST 2006
Hi all,
yesterday I noticed a strange behavior of one of my scripts, which accesses a
bzr branch locally. The reason was that at the same time the branch was being
updated (a push) over sftp and both (script and sftp transport) could acquire a
write lock. After reading the code and some experiments I wrote this test:
=== modified file 'bzrlib/tests/test_sftp_transport.py'
--- bzrlib/tests/test_sftp_transport.py 2006-07-31 23:04:57 +0000
+++ bzrlib/tests/test_sftp_transport.py 2006-08-03 09:53:38 +0000
@@ -90,6 +90,24 @@
t2 = self.get_transport()
self.assertEquals(self.get_server().logs, [])
+ def test_compatibility_with_localtransport_lock(self):
+ from bzrlib.errors import LockError
+ b = self.make_branch('', format=bzrdir.BzrDirFormat6())
+ b = bzrlib.branch.Branch.open(self.get_url())
+
+ self.failIf(lexists('.bzr/branch-lock.write-lock'))
+ b.lock_write()
+ self.failUnlessExists('.bzr/branch-lock.write-lock')
+
+ # now access the branch locally
+ homedir = self.get_server()._homedir
+ local_branch = bzrlib.branch.Branch.open(homedir)
+ self.assertRaises(LockError, local_branch.lock_write)
+ local_branch.unlock()
+
+ b.unlock()
+ self.failIf(lexists('.bzr/branch-lock.write-lock'))
+
My question now is, is this behavior expected or is it a bug?
And if it's a feature how can i tell a script to wait until the branch is updated?
Jan
More information about the bazaar
mailing list