59
59
Instances of this class are often called control_files.
61
61
This object builds on top of a Transport, which is used to actually write
62
62
the files to disk, and an OSLock or LockDir, which controls how access to
63
63
the files is controlled. The particular type of locking used is set when
64
64
the object is constructed. In older formats OSLocks are used everywhere.
65
in newer formats a LockDir is used for Repositories and Branches, and
65
in newer formats a LockDir is used for Repositories and Branches, and
66
66
OSLocks for the local filesystem.
68
This class is now deprecated; code should move to using the Transport
69
directly for file operations and using the lock or CountedLock for
68
This class is now deprecated; code should move to using the Transport
69
directly for file operations and using the lock or CountedLock for
73
73
# _lock_mode: None, or 'r' or 'w'
75
75
# _lock_count: If _lock_mode is true, a positive count of the number of
76
# times the lock has been taken *by this process*.
76
# times the lock has been taken *by this process*.
78
78
def __init__(self, transport, lock_name, lock_class):
79
79
"""Create a LockableFiles group
81
:param transport: Transport pointing to the directory holding the
81
:param transport: Transport pointing to the directory holding the
82
82
control files and lock.
83
83
:param lock_name: Name of the lock guarding these files.
84
84
:param lock_class: Class of lock strategy to use: typically
152
152
@deprecated_method(deprecated_in((1, 6, 0)))
153
153
def controlfilename(self, file_or_path):
154
154
"""Return location relative to branch.
156
156
:deprecated: Use Transport methods instead.
158
158
return self._transport.abspath(self._escape(file_or_path))
161
161
@deprecated_method(deprecated_in((1, 5, 0)))
162
162
def get(self, relpath):
163
163
"""Get a file as a bytestream.
165
165
:deprecated: Use a Transport instead of LockableFiles.
167
167
relpath = self._escape(relpath)
171
171
@deprecated_method(deprecated_in((1, 5, 0)))
172
172
def get_utf8(self, relpath):
173
173
"""Get a file as a unicode stream.
175
175
:deprecated: Use a Transport instead of LockableFiles.
177
177
relpath = self._escape(relpath)
182
182
@deprecated_method(deprecated_in((1, 6, 0)))
183
183
def put(self, path, file):
186
186
:param path: The path to put the file, relative to the .bzr control
188
188
:param file: A file-like or string object whose contents should be copied.
235
235
def lock_write(self, token=None):
236
236
"""Lock this group of files for writing.
238
238
:param token: if this is already locked, then lock_write will fail
239
239
unless the token matches the existing lock.
240
240
:returns: a token if this instance supports tokens, otherwise None.
277
277
self._set_transaction(transactions.ReadOnlyTransaction())
278
278
# 5K may be excessive, but hey, its a knob.
279
279
self.get_transaction().set_cache_size(5000)
281
281
def unlock(self):
282
282
if not self._lock_mode:
283
283
raise errors.LockNotHeld(self)
298
298
def get_physical_lock_status(self):
299
299
"""Return physical lock status.
301
301
Returns true if a lock is held on the transport. If no lock is held, or
302
302
the underlying locking mechanism does not support querying lock
303
303
status, false is returned.