103
103
self._inventory = inv
105
105
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]
106
ie = self._inventory[file_id]
109
108
revision = self._repository.get_revision(ie.revision)
110
109
except errors.NoSuchRevision:
112
111
return revision.timestamp
114
113
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
114
return self._inventory[file_id].text_size
118
116
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]
117
ie = self._inventory[file_id]
121
118
if ie.kind == "file":
122
119
return ie.text_sha1
125
122
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]
123
ie = self._inventory[file_id]
128
124
return ie.revision
130
126
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]
127
ie = self._inventory[file_id]
133
128
if ie.kind != "file":
135
130
return ie.executable
137
132
def has_filename(self, filename):
138
return bool(self.path2id(filename))
133
return bool(self.inventory.path2id(filename))
140
135
def list_files(self, include_root=False, from_dir=None, recursive=True):
141
136
# The only files returned by this are those from the version
142
138
if from_dir is None:
143
139
from_dir_id = None
144
inv = self.root_inventory
146
inv, from_dir_id = self._path2inv_file_id(from_dir)
141
from_dir_id = inv.path2id(from_dir)
147
142
if from_dir_id is None:
148
143
# Directory not versioned
155
150
yield path, 'V', entry.kind, entry.file_id, entry
157
152
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]
153
ie = self._inventory[file_id]
160
154
# Inventories store symlink targets in unicode
161
155
return ie.symlink_target
163
157
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
158
return self.inventory[file_id].reference_revision
167
160
def get_root_id(self):
168
if self.root_inventory.root:
169
return self.root_inventory.root.file_id
161
if self.inventory.root:
162
return self.inventory.root.file_id
171
164
def kind(self, file_id):
172
inv, inv_file_id = self._unpack_file_id(file_id)
173
return inv[inv_file_id].kind
165
return self._inventory[file_id].kind
175
167
def path_content_summary(self, path):
176
168
"""See Tree.path_content_summary."""
177
inv, file_id = self._path2inv_file_id(path)
169
id = self.inventory.path2id(path)
179
171
return ('missing', None, None, None)
172
entry = self._inventory[id]
181
173
kind = entry.kind
182
174
if kind == 'file':
183
175
return (kind, entry.text_size, entry.executable, entry.text_sha1)
242
235
annotations = annotator.annotate_flat(text_key)
243
236
return [(key[-1], line) for key, line in annotations]
245
def __eq__(self, other):
248
if isinstance(other, InventoryRevisionTree):
249
return (self.root_inventory == other.root_inventory)
252
def __ne__(self, other):
253
return not (self == other)
256
raise ValueError('not hashable')
259
239
class InterCHKRevisionTree(tree.InterTree):
260
240
"""Fast path optimiser for RevisionTrees with CHK inventories."""
265
245
and isinstance(target, RevisionTree)):
267
247
# Only CHK inventories have id_to_entry attribute
268
source.root_inventory.id_to_entry
269
target.root_inventory.id_to_entry
248
source.inventory.id_to_entry
249
target.inventory.id_to_entry
271
251
except AttributeError:
290
270
# to CHKInventory.iter_changes and do a better job there -- vila
292
272
changed_file_ids = set()
293
# FIXME: nested tree support
294
for result in self.target.root_inventory.iter_changes(
295
self.source.root_inventory):
273
for result in self.target.inventory.iter_changes(self.source.inventory):
296
274
if specific_file_ids is not None:
297
275
file_id = result[0]
298
276
if file_id not in specific_file_ids:
315
293
# Now walk the whole inventory, excluding the already yielded
317
# FIXME: Support nested trees
318
295
changed_file_ids = set(changed_file_ids)
319
for relpath, entry in self.target.root_inventory.iter_entries():
296
for relpath, entry in self.target.inventory.iter_entries():
320
297
if (specific_file_ids is not None
321
298
and not entry.file_id in specific_file_ids):