34
41
class BzrBranch4(FullHistoryBzrBranch):
35
42
"""Branch format 4."""
44
def lock_write(self, token=None):
45
"""Lock the branch for write operations.
47
:param token: A token to permit reacquiring a previously held and
49
:return: A BranchWriteLockResult.
51
if not self.is_locked():
53
# All-in-one needs to always unlock/lock.
54
self.repository._warn_if_deprecated(self)
55
self.repository.lock_write()
57
return BranchWriteLockResult(self.unlock,
58
self.control_files.lock_write(token=token))
60
self.repository.unlock()
64
"""Lock the branch for read operations.
66
:return: A bzrlib.lock.LogicalLockResult.
68
if not self.is_locked():
70
# All-in-one needs to always unlock/lock.
71
self.repository._warn_if_deprecated(self)
72
self.repository.lock_read()
74
self.control_files.lock_read()
75
return LogicalLockResult(self.unlock)
77
self.repository.unlock()
80
@only_raises(errors.LockNotHeld, errors.LockBroken)
82
if self.control_files._lock_count == 2 and self.conf_store is not None:
83
self.conf_store.save_changes()
85
self.control_files.unlock()
87
# All-in-one needs to always unlock/lock.
88
self.repository.unlock()
89
if not self.control_files.is_locked():
90
# we just released the lock
91
self._clear_cached_state()
37
93
def _get_checkout_format(self, lightweight=False):
38
94
"""Return the most suitable metadir for a checkout of this branch.