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