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
62
62
"""Return the revision id associated with this tree."""
63
63
return self._revision_id
65
def _get_weave(self, file_id):
66
return self._weave_store.get_weave(file_id,
67
self._repository.get_transaction())
69
65
def get_file_lines(self, file_id):
70
ie = self._inventory[file_id]
71
weave = self._get_weave(file_id)
72
return weave.get_lines(ie.revision)
66
return osutils.split_lines(self.get_file_text(file_id))
74
68
def get_file_text(self, file_id):
75
return ''.join(self.get_file_lines(file_id))
69
return list(self.iter_files_bytes([(file_id, None)]))[0][1]
77
71
def get_file(self, file_id, path=None):
78
72
return StringIO(self.get_file_text(file_id))
80
74
def iter_files_bytes(self, desired_files):
81
"""See Tree.extract_files_bytes.
75
"""See Tree.iter_files_bytes.
83
77
This version is implemented on top of Repository.extract_files_bytes"""
84
78
repo_desired_files = [(f, self.inventory[f].revision, i)
85
79
for f, i in desired_files]
86
return self._repository.iter_files_bytes(repo_desired_files)
81
for result in self._repository.iter_files_bytes(repo_desired_files):
83
except errors.RevisionNotPresent, e:
84
raise errors.NoSuchFile(e.revision_id)
88
86
def annotate_iter(self, file_id,
89
87
default_revision=revision.CURRENT_REVISION):
90
88
"""See Tree.annotate_iter"""
91
w = self._get_weave(file_id)
92
return w.annotate(self.inventory[file_id].revision)
89
text_key = (file_id, self.inventory[file_id].revision)
90
annotations = self._repository.texts.annotate(text_key)
91
return [(key[-1], line) for key, line in annotations]
94
93
def get_file_size(self, file_id):
95
94
"""See Tree.get_file_size"""