48
48
from bzrlib.tree import EmptyTree, RevisionTree
51
from bzrlib.decorators import needs_read_lock, needs_write_lock
53
54
BZR_BRANCH_FORMAT_4 = "Bazaar-NG branch, format 0.0.4\n"
54
55
BZR_BRANCH_FORMAT_5 = "Bazaar-NG branch, format 5\n"
55
56
BZR_BRANCH_FORMAT_6 = "Bazaar-NG branch, format 6\n"
56
## TODO: Maybe include checks for common corruption of newlines, etc?
59
# TODO: Maybe include checks for common corruption of newlines, etc?
59
61
# TODO: Some operations like log might retrieve the same revisions
60
62
# repeatedly to calculate deltas. We could perhaps have a weakref
61
63
# cache in memory to make this faster. In general anything can be
62
64
# cached in memory between lock and unlock operations.
66
# FIXME: At the moment locking the Branch locks both the repository and the
67
# control files, representing the two aspects currently controlled by one
68
# object. However, they currently both map to the same lockfile.
64
70
def find_branch(*ignored, **ignored_too):
65
71
# XXX: leave this here for about one release, then remove it
66
72
raise NotImplementedError('find_branch() is not supported anymore, '
67
73
'please use one of the new branch constructors')
70
def needs_read_lock(unbound):
71
"""Decorate unbound to take out and release a read lock."""
72
def decorated(self, *args, **kwargs):
75
return unbound(self, *args, **kwargs)
81
def needs_write_lock(unbound):
82
"""Decorate unbound to take out and release a write lock."""
83
def decorated(self, *args, **kwargs):
86
return unbound(self, *args, **kwargs)
91
76
######################################################################
174
159
def unlock(self):
175
160
raise NotImplementedError('unlock is abstract')
162
def peek_lock_mode(self):
163
"""Return lock mode for the Branch: 'r', 'w' or None"""
164
raise NotImplementedError(self.is_locked)
177
166
def abspath(self, name):
178
167
"""Return absolute filename for something in the branch
619
608
self.repository.unlock()
620
609
self.control_files.unlock()
611
def peek_lock_mode(self):
612
if self.control_files._lock_count == 0:
615
return self.control_files._lock_mode
623
618
def print_file(self, file, revision_id):
624
619
"""See Branch.print_file."""