Rev 2: start working on the basic groundwork for how the lock info is going to be managed. in http://bzr.arbash-meinel.com/plugins/file_locking
John Arbash Meinel
john at arbash-meinel.com
Fri Sep 18 18:18:24 BST 2009
At http://bzr.arbash-meinel.com/plugins/file_locking
------------------------------------------------------------
revno: 2
revision-id: john at arbash-meinel.com-20090918171816-ruoetqruopk9wjr1
parent: john at arbash-meinel.com-20090918164327-lzo8ftbyczdgvz5g
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: file_locking
timestamp: Fri 2009-09-18 12:18:16 -0500
message:
start working on the basic groundwork for how the lock info is going to be managed.
-------------- next part --------------
=== modified file 'file_lock.py'
--- a/file_lock.py 2009-09-18 16:43:27 +0000
+++ b/file_lock.py 2009-09-18 17:18:16 +0000
@@ -22,3 +22,16 @@
class LockingSerializer(object):
"""Keeps track of writing/reading the shared lock file."""
+
+class LockInfo(object):
+ """Info about one specific lock."""
+
+class LocksInfo(object):
+ """Info about currently held locks."""
+
+ @classmethod
+ def from_bytes(cls, bytes):
+ return cls()
+
+ def to_bytes(self):
+ return ''
=== modified file 'tests/__init__.py'
--- a/tests/__init__.py 2009-09-18 16:43:27 +0000
+++ b/tests/__init__.py 2009-09-18 17:18:16 +0000
@@ -20,6 +20,8 @@
def load_tests(standard_tests, module, loader):
standard_tests.addTests(loader.loadTestsFromModuleNames(
[__name__ + '.' + x for x in [
+ 'test_acceptance',
+ 'test_cli',
'test_file_lock',
]]))
return standard_tests
=== added file 'tests/test_acceptance.py'
--- a/tests/test_acceptance.py 1970-01-01 00:00:00 +0000
+++ b/tests/test_acceptance.py 2009-09-18 17:18:16 +0000
@@ -0,0 +1,54 @@
+# Copyright (C) 2009 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+"""Tests for basic functionality"""
+
+from bzrlib import tests
+
+
+class AcceptanceTests(tests.TestCaseWithTransport):
+
+ def fail_for_now(self):
+ # TODO: We fail early for now because the test setup is slightly
+ # expensive, and we don't want to wait for something we know
+ # fails
+ self.knownFailure('lock-file is not implemented yet')
+
+ def test_lock_and_unlock(self):
+ self.fail_for_now()
+ t = self.make_branch_and_tree('.')
+ self.build_tree(['a', 'b'])
+ t.add(['a', 'b'], ['a-id', 'b-id'])
+ t.commit('Creating initial work.')
+ self.expectFailure('lock-file not really implemented yet',
+ self.run_bzr, 'lock-file a')
+ self.run_bzr('lock-file a')
+ self.expectFailure('unlock-file not implemented yet',
+ self.run_bzr, 'unlock-file a')
+ self.run_bzr('unlock-file a')
+
+ def test_locking_blocks(self):
+ self.fail_for_now()
+ t = self.make_branch_and_tree('.')
+ self.build_tree(['a', 'b'])
+ t.add(['a', 'b'], ['a-id', 'b-id'])
+ t.commit('Creating initial work.')
+ self.expectFailure('lock-file not really implemented yet',
+ self.run_bzr, 'lock-file a')
+ self.run_bzr('lock-file a')
+ out, err = self.run_bzr('lock-file a', retcode=3)
+ self.assertEqualDiff('Cannot lock file a, it is already in use'
+ 'by foobar.', err)
=== added file 'tests/test_cli.py'
--- a/tests/test_cli.py 1970-01-01 00:00:00 +0000
+++ b/tests/test_cli.py 2009-09-18 17:18:16 +0000
@@ -0,0 +1,23 @@
+# Copyright (C) 2009 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+"""Tests for commands that we want to exist."""
+
+from bzrlib import tests
+
+
+class TestCLIBehavior(tests.TestCaseWithTransport):
+ pass
=== modified file 'tests/test_file_lock.py'
--- a/tests/test_file_lock.py 2009-09-18 16:43:27 +0000
+++ b/tests/test_file_lock.py 2009-09-18 17:18:16 +0000
@@ -25,3 +25,10 @@
def test_create(self):
file_lock.LockingSerializer()
+
+
+class TestLocksInfo(tests.TestCase):
+
+ def test_trivial_from_bytes(self):
+ li = file_lock.LocksInfo.from_bytes('')
+ self.assertIsInstance(li, file_lock.LocksInfo)
More information about the bazaar-commits
mailing list