Rev 1: Initial framework for a cooperative file-locking plugin. in http://bzr.arbash-meinel.com/plugins/file_locking
John Arbash Meinel
john at arbash-meinel.com
Fri Sep 18 17:43:34 BST 2009
At http://bzr.arbash-meinel.com/plugins/file_locking
------------------------------------------------------------
revno: 1
revision-id: 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 11:43:27 -0500
message:
Initial framework for a cooperative file-locking plugin.
-------------- next part --------------
=== added file '__init__.py'
--- a/__init__.py 1970-01-01 00:00:00 +0000
+++ b/__init__.py 2009-09-18 16:43:27 +0000
@@ -0,0 +1,40 @@
+# 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
+
+"""A plugin providing commands to implement cooperative file locking.
+
+Sometimes you want to know if anyone is currently modifying a file that you
+want to modify. And these files are well known for being hard to merge.
+(images, generated content, etc.)
+
+This does not implement enforced locking. So people who chose not to lock can
+still modify/commit/etc files that are being watched.
+"""
+
+from bzrlib import commands
+
+
+class cmd_lock_file(commands.Command):
+ """Take out a cooperative lock on the given file."""
+
+
+commands.register_command(cmd_lock_file)
+
+
+def load_tests(standard_tests, module, loader):
+ standard_tests.addTests(loader.loadTestsFromModuleNames(
+ [__name__ + '.tests']))
+ return standard_tests
=== added file 'file_lock.py'
--- a/file_lock.py 1970-01-01 00:00:00 +0000
+++ b/file_lock.py 2009-09-18 16:43:27 +0000
@@ -0,0 +1,24 @@
+# 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
+
+"""Functionality for cooperative file locking."""
+
+from bzrlib import rio
+
+
+class LockingSerializer(object):
+ """Keeps track of writing/reading the shared lock file."""
+
=== added directory 'tests'
=== added file 'tests/__init__.py'
--- a/tests/__init__.py 1970-01-01 00:00:00 +0000
+++ b/tests/__init__.py 2009-09-18 16:43:27 +0000
@@ -0,0 +1,25 @@
+# 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 cooperative file locking."""
+
+
+def load_tests(standard_tests, module, loader):
+ standard_tests.addTests(loader.loadTestsFromModuleNames(
+ [__name__ + '.' + x for x in [
+ 'test_file_lock',
+ ]]))
+ return standard_tests
=== added file 'tests/test_file_lock.py'
--- a/tests/test_file_lock.py 1970-01-01 00:00:00 +0000
+++ b/tests/test_file_lock.py 2009-09-18 16:43:27 +0000
@@ -0,0 +1,27 @@
+# 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 cooperative file locking."""
+
+from bzrlib import tests
+
+from bzrlib.plugins.file_locking import file_lock
+
+
+class TestLockSerializer(tests.TestCase):
+
+ def test_create(self):
+ file_lock.LockingSerializer()
More information about the bazaar-commits
mailing list