Rev 12: Add an unlock function to thunk to the LockDir object. in lp:~jameinel/+junk/file_locking
John Arbash Meinel
john at arbash-meinel.com
Mon Sep 21 16:43:53 BST 2009
At lp:~jameinel/+junk/file_locking
------------------------------------------------------------
revno: 12
revision-id: john at arbash-meinel.com-20090921154346-3ljog0d1w19r75gd
parent: john at arbash-meinel.com-20090921154143-4u6o17tdinepjvy6
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: file_locking
timestamp: Mon 2009-09-21 10:43:46 -0500
message:
Add an unlock function to thunk to the LockDir object.
-------------- next part --------------
=== modified file 'file_lock.py'
--- a/file_lock.py 2009-09-21 15:41:43 +0000
+++ b/file_lock.py 2009-09-21 15:43:46 +0000
@@ -195,6 +195,9 @@
locking_info = FileLockingInfo([])
s = FileLockingInfoSerializer()
bytes = s.to_bytes(locking_info)
+ # Instead of having a separate 'format' file, we put the data into
+ # the 'info' file. Which means that we have 1 less object to read
+ # from remote.
transport.put_bytes('info', bytes)
store = cls(transport, locking_info, lock)
except:
@@ -211,6 +214,9 @@
lock = lockdir.LockDir(transport, 'lock')
return cls(transport, locking_info, lock)
+ def unlock(self):
+ self._lock.unlock()
+
class FileLockManager(object):
"""This is the overall manager that tracks everything we need to know."""
=== modified file 'tests/test_file_lock.py'
--- a/tests/test_file_lock.py 2009-09-21 15:41:43 +0000
+++ b/tests/test_file_lock.py 2009-09-21 15:43:46 +0000
@@ -142,7 +142,7 @@
def test_initialize(self):
trans = self.get_transport('lock-store')
fls = file_lock.FileLockStore.initialize(trans)
- self.addCleanup(fls._lock.unlock)
+ self.addCleanup(fls.unlock)
self.assertIsInstance(fls, file_lock.FileLockStore)
self.assertEqual(trans, fls._transport)
self.assertEqual(['README.txt', 'info', 'lock'],
@@ -165,7 +165,7 @@
def test_open_trivial(self):
trans = self.get_transport('lock-store')
fls = file_lock.FileLockStore.initialize(trans)
- fls._lock.unlock()
+ fls.unlock()
fls = file_lock.FileLockStore.open(trans)
self.assertIsInstance(fls, file_lock.FileLockStore)
self.assertEqual(trans, fls._transport)
More information about the bazaar-commits
mailing list