Rev 2398: Split TransportLock to its own file in http://sourcefrog.net/bzr/no-controlfiles
Martin Pool
mbp at sourcefrog.net
Thu Apr 5 07:25:30 BST 2007
At http://sourcefrog.net/bzr/no-controlfiles
------------------------------------------------------------
revno: 2398
revision-id: mbp at sourcefrog.net-20070405062529-h5e33vin342zj1de
parent: mbp at sourcefrog.net-20070405062507-qjd6t24fthqe07ay
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: no-controlfiles
timestamp: Thu 2007-04-05 16:25:29 +1000
message:
Split TransportLock to its own file
added:
bzrlib/transport_lock.py transport_lock.py-20070405061939-v76eijhb949j0u25-1
modified:
bzrlib/lockable_files.py control_files.py-20051111201905-bb88546e799d669f
=== added file 'bzrlib/transport_lock.py'
--- a/bzrlib/transport_lock.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/transport_lock.py 2007-04-05 06:25:29 +0000
@@ -0,0 +1,57 @@
+# Copyright (C) 2005, 2006, 2007 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+
+
+class TransportLock(object):
+ """Locking method which uses transport-dependent locks.
+
+ On the local filesystem these transform into OS-managed locks.
+
+ These do not guard against concurrent access via different
+ transports.
+
+ This is suitable for use only in WorkingTrees (which are at present
+ always local) and old all-in-one BzrDirs which don't lock across transports.
+ """
+ def __init__(self, transport, escaped_name, file_modebits, dir_modebits):
+ self._transport = transport
+ self._escaped_name = escaped_name
+ self._file_modebits = file_modebits
+ self._dir_modebits = dir_modebits
+
+ def break_lock(self):
+ raise NotImplementedError(self.break_lock)
+
+ def lock_write(self):
+ self._lock = self._transport.lock_write(self._escaped_name)
+
+ def lock_read(self):
+ self._lock = self._transport.lock_read(self._escaped_name)
+
+ def unlock(self):
+ self._lock.unlock()
+ self._lock = None
+
+ def peek(self):
+ raise NotImplementedError()
+
+ def create(self, mode=None):
+ """Create lock mechanism"""
+ # for old-style locks, create the file now
+ self._transport.put_bytes(self._escaped_name, '',
+ mode=self._file_modebits)
=== modified file 'bzrlib/lockable_files.py'
--- a/bzrlib/lockable_files.py 2007-02-09 23:39:24 +0000
+++ b/bzrlib/lockable_files.py 2007-04-05 06:25:29 +0000
@@ -313,41 +313,4 @@
transaction.finish()
-class TransportLock(object):
- """Locking method which uses transport-dependent locks.
-
- On the local filesystem these transform into OS-managed locks.
-
- These do not guard against concurrent access via different
- transports.
-
- This is suitable for use only in WorkingTrees (which are at present
- always local).
- """
- def __init__(self, transport, escaped_name, file_modebits, dir_modebits):
- self._transport = transport
- self._escaped_name = escaped_name
- self._file_modebits = file_modebits
- self._dir_modebits = dir_modebits
-
- def break_lock(self):
- raise NotImplementedError(self.break_lock)
-
- def lock_write(self):
- self._lock = self._transport.lock_write(self._escaped_name)
-
- def lock_read(self):
- self._lock = self._transport.lock_read(self._escaped_name)
-
- def unlock(self):
- self._lock.unlock()
- self._lock = None
-
- def peek(self):
- raise NotImplementedError()
-
- def create(self, mode=None):
- """Create lock mechanism"""
- # for old-style locks, create the file now
- self._transport.put_bytes(self._escaped_name, '',
- mode=self._file_modebits)
+from bzrlib.transport_lock import TransportLock
More information about the bazaar-commits
mailing list