39
40
# construction - this will mean that we can change the constructor
40
41
# with much less chance of breaking client code.
41
42
self._repository = branch
42
self._weave_store = branch.weave_store
43
43
self._inventory = inv
44
44
self._revision_id = revision_id
45
self._rules_searcher = None
46
47
def supports_tree_reference(self):
62
63
"""Return the revision id associated with this tree."""
63
64
return self._revision_id
65
@symbol_versioning.deprecated_method(symbol_versioning.zero_ninety)
66
def get_weave(self, file_id):
67
return self._get_weave(file_id)
69
def _get_weave(self, file_id):
70
return self._weave_store.get_weave(file_id,
71
self._repository.get_transaction())
73
66
def get_file_lines(self, file_id):
74
ie = self._inventory[file_id]
75
weave = self._get_weave(file_id)
76
return weave.get_lines(ie.revision)
67
return osutils.split_lines(self.get_file_text(file_id))
78
69
def get_file_text(self, file_id):
79
return ''.join(self.get_file_lines(file_id))
70
return list(self.iter_files_bytes([(file_id, None)]))[0][1]
81
72
def get_file(self, file_id, path=None):
82
73
return StringIO(self.get_file_text(file_id))
84
75
def iter_files_bytes(self, desired_files):
85
"""See Tree.extract_files_bytes.
76
"""See Tree.iter_files_bytes.
87
78
This version is implemented on top of Repository.extract_files_bytes"""
88
79
repo_desired_files = [(f, self.inventory[f].revision, i)
89
80
for f, i in desired_files]
90
return self._repository.iter_files_bytes(repo_desired_files)
82
for result in self._repository.iter_files_bytes(repo_desired_files):
84
except errors.RevisionNotPresent, e:
85
raise errors.NoSuchFile(e.revision_id)
92
87
def annotate_iter(self, file_id,
93
88
default_revision=revision.CURRENT_REVISION):
94
89
"""See Tree.annotate_iter"""
95
w = self._get_weave(file_id)
96
return w.annotate_iter(self.inventory[file_id].revision)
90
text_key = (file_id, self.inventory[file_id].revision)
91
annotations = self._repository.texts.annotate(text_key)
92
return [(key[-1], line) for key, line in annotations]
98
94
def get_file_size(self, file_id):
95
"""See Tree.get_file_size"""
99
96
return self._inventory[file_id].text_size
101
98
def get_file_sha1(self, file_id, path=None, stat_value=None):
207
203
for dir in reversed(dirblock):
208
204
if dir[2] == _directory:
209
205
pending.append(dir)
207
def _get_rules_searcher(self, default_searcher):
208
"""See Tree._get_rules_searcher."""
209
if self._rules_searcher is None:
210
self._rules_searcher = super(RevisionTree,
211
self)._get_rules_searcher(default_searcher)
212
return self._rules_searcher