208
208
self._rules_searcher = super(RevisionTree,
209
209
self)._get_rules_searcher(default_searcher)
210
210
return self._rules_searcher
213
class InterCHKRevisionTree(tree.InterTree):
214
"""Fast path optimiser for RevisionTrees with CHK inventories."""
217
def is_compatible(source, target):
218
if (isinstance(source, RevisionTree)
219
and isinstance(target, RevisionTree)):
221
# Only CHK inventories have id_to_entry attribute
222
source.inventory.id_to_entry
223
target.inventory.id_to_entry
225
except AttributeError:
229
def iter_changes(self, include_unchanged=False,
230
specific_files=None, pb=None, extra_trees=[],
231
require_versioned=True, want_unversioned=False):
232
lookup_trees = [self.source]
234
lookup_trees.extend(extra_trees)
235
if specific_files == []:
236
specific_file_ids = []
238
specific_file_ids = self.target.paths2ids(specific_files,
239
lookup_trees, require_versioned=require_versioned)
241
# FIXME: It should be possible to delegate include_unchanged handling
242
# to CHKInventory.iter_changes and do a better job there -- vila
244
if include_unchanged:
245
changed_file_ids = []
246
for result in self.target.inventory.iter_changes(self.source.inventory):
247
if (specific_file_ids is not None
248
and not result[0] in specific_file_ids):
249
# CHKMap.iter_changes is clean and fast. Better filter out
250
# the specific files *after* it did its job.
253
if include_unchanged:
254
# Keep track of yielded results (cheaper than building the
256
changed_file_ids.append(result[0])
257
if include_unchanged:
258
# CHKMap avoid being O(tree), so we go to O(tree) only if
260
# Now walk the whole inventory, excluding the already yielded
262
changed_file_ids = set(changed_file_ids)
263
for relpath, entry in self.target.inventory.iter_entries():
264
if (specific_file_ids is not None
265
and not entry.file_id in specific_file_ids):
267
if not entry.file_id in changed_file_ids:
268
yield (entry.file_id,
269
(relpath, relpath), # Not renamed
270
False, # Not modified
271
(True, True), # Still versioned
272
(entry.parent_id, entry.parent_id),
273
(entry.name, entry.name),
274
(entry.kind, entry.kind),
275
(entry.executable, entry.executable))
278
tree.InterTree.register_optimiser(InterCHKRevisionTree)