38
36
self._revision_id = revision_id
39
37
self._rules_searcher = None
41
def has_versioned_directories(self):
42
"""See `Tree.has_versioned_directories`."""
43
return self._repository._format.supports_versioned_directories
45
39
def supports_tree_reference(self):
46
40
return getattr(self._repository._format, "supports_tree_reference",
67
61
raise NotImplementedError(self.get_file_revision)
69
63
def get_file_text(self, file_id, path=None):
70
for (identifier, content) in self.iter_files_bytes([(file_id, None)]):
71
ret = "".join(content)
64
_, content = list(self.iter_files_bytes([(file_id, None)]))[0]
65
return ''.join(content)
74
67
def get_file(self, file_id, path=None):
75
68
return StringIO(self.get_file_text(file_id))
103
96
self._inventory = inv
105
98
def get_file_mtime(self, file_id, path=None):
106
inv, inv_file_id = self._unpack_file_id(file_id)
107
ie = inv[inv_file_id]
99
ie = self._inventory[file_id]
109
101
revision = self._repository.get_revision(ie.revision)
110
102
except errors.NoSuchRevision:
112
104
return revision.timestamp
114
106
def get_file_size(self, file_id):
115
inv, inv_file_id = self._unpack_file_id(file_id)
116
return inv[inv_file_id].text_size
107
return self._inventory[file_id].text_size
118
109
def get_file_sha1(self, file_id, path=None, stat_value=None):
119
inv, inv_file_id = self._unpack_file_id(file_id)
120
ie = inv[inv_file_id]
110
ie = self._inventory[file_id]
121
111
if ie.kind == "file":
122
112
return ie.text_sha1
125
115
def get_file_revision(self, file_id, path=None):
126
inv, inv_file_id = self._unpack_file_id(file_id)
127
ie = inv[inv_file_id]
116
ie = self._inventory[file_id]
128
117
return ie.revision
130
119
def is_executable(self, file_id, path=None):
131
inv, inv_file_id = self._unpack_file_id(file_id)
132
ie = inv[inv_file_id]
120
ie = self._inventory[file_id]
133
121
if ie.kind != "file":
135
123
return ie.executable
137
125
def has_filename(self, filename):
138
return bool(self.path2id(filename))
126
return bool(self.inventory.path2id(filename))
140
128
def list_files(self, include_root=False, from_dir=None, recursive=True):
141
129
# The only files returned by this are those from the version
142
131
if from_dir is None:
143
132
from_dir_id = None
146
inv, from_dir_id = self._path2inv_file_id(from_dir)
134
from_dir_id = inv.path2id(from_dir)
147
135
if from_dir_id is None:
148
136
# Directory not versioned
155
143
yield path, 'V', entry.kind, entry.file_id, entry
157
145
def get_symlink_target(self, file_id, path=None):
158
inv, inv_file_id = self._unpack_file_id(file_id)
159
ie = inv[inv_file_id]
146
ie = self._inventory[file_id]
160
147
# Inventories store symlink targets in unicode
161
148
return ie.symlink_target
163
150
def get_reference_revision(self, file_id, path=None):
164
inv, inv_file_id = self._unpack_file_id(file_id)
165
return inv[inv_file_id].reference_revision
151
return self.inventory[file_id].reference_revision
167
153
def get_root_id(self):
168
154
if self.inventory.root:
169
155
return self.inventory.root.file_id
171
157
def kind(self, file_id):
172
inv, inv_file_id = self._unpack_file_id(file_id)
173
return inv[inv_file_id].kind
158
return self._inventory[file_id].kind
175
160
def path_content_summary(self, path):
176
161
"""See Tree.path_content_summary."""
177
inv, file_id = self._path2inv_file_id(path)
162
id = self.inventory.path2id(path)
179
164
return ('missing', None, None, None)
165
entry = self._inventory[id]
181
166
kind = entry.kind
182
167
if kind == 'file':
183
168
return (kind, entry.text_size, entry.executable, entry.text_sha1)
225
211
def iter_files_bytes(self, desired_files):
226
212
"""See Tree.iter_files_bytes.
228
This version is implemented on top of Repository.iter_files_bytes"""
214
This version is implemented on top of Repository.extract_files_bytes"""
229
215
repo_desired_files = [(f, self.get_file_revision(f), i)
230
216
for f, i in desired_files]
232
218
for result in self._repository.iter_files_bytes(repo_desired_files):
234
220
except errors.RevisionNotPresent, e:
235
raise errors.NoSuchFile(e.file_id)
221
raise errors.NoSuchFile(e.revision_id)
237
223
def annotate_iter(self, file_id,
238
224
default_revision=revision.CURRENT_REVISION):
277
263
# to CHKInventory.iter_changes and do a better job there -- vila
279
265
changed_file_ids = set()
280
for result in self.target.inventory.iter_changes(
281
self.source.inventory):
266
for result in self.target.inventory.iter_changes(self.source.inventory):
282
267
if specific_file_ids is not None:
283
268
file_id = result[0]
284
269
if file_id not in specific_file_ids: