23
23
from bzrlib.errors import LockError, ReadOnlyError
24
24
from bzrlib.osutils import file_iterator, safe_unicode
25
25
from bzrlib.symbol_versioning import *
26
from bzrlib.symbol_versioning import deprecated_method, zero_eight
27
26
from bzrlib.trace import mutter
28
27
import bzrlib.transactions as transactions
54
53
OSLocks for the local filesystem.
57
_lock_mode = None # None, or 'r' or 'w'
56
# _lock_mode: None, or 'r' or 'w'
59
# If _lock_mode is true, a positive count of the number of times the
60
# lock has been taken *by this process*. Others may have compatible
58
# _lock_count: If _lock_mode is true, a positive count of the number of
59
# times the lock has been taken *by this process*.
64
61
# If set to False (by a plugin, etc) BzrBranch will not set the
65
62
# mode on created files or directories
66
63
_set_file_mode = True
67
64
_set_dir_mode = True
69
def __init__(self, transport, lock_name, lock_strategy_class=None):
66
def __init__(self, transport, lock_name, lock_class=None):
70
67
"""Create a LockableFiles group
72
69
:param transport: Transport pointing to the directory holding the
73
70
control files and lock.
74
71
:param lock_name: Name of the lock guarding these files.
75
:param lock_strategy_class: Class of lock strategy to use.
72
:param lock_class: Class of lock strategy to use: typically
73
either LockDir or TransportLock.
77
75
object.__init__(self)
78
76
self._transport = transport
79
77
self.lock_name = lock_name
80
78
self._transaction = None
82
# TODO: remove this and make the parameter mandatory
83
if lock_strategy_class is None:
84
lock_strategy_class = TransportLock
80
self._lock_mode = None
85
82
esc_name = self._escape(lock_name)
86
self._lock_strategy = lock_strategy_class(transport, esc_name)
83
if lock_class is None:
84
warn("LockableFiles: lock_class is now a mandatory parameter",
85
DeprecationWarning, stacklevel=2)
86
lock_class = TransportLock
87
self._lock = lock_class(transport, esc_name)
88
89
def _escape(self, file_or_path):
89
90
if not isinstance(file_or_path, basestring):