145
145
os.mkdir(os.path.join(self.tempdir, "texts"))
148
def __contains__(self, file_id):
149
return id in self.tree
151
def get_file_sha1(self, id):
152
return self.tree.get_file_sha1(id)
148
154
def readonly_path(self, id):
149
155
if id not in self.tree:
232
238
source_file.interesting = source_file.id in interesting_ids
235
def set_optimized(tree_a, tree_b, inventory_a, inventory_b):
236
"""Mark files that have changed texts as interesting
238
for file_id in tree_a.tree.inventory:
239
if file_id not in tree_b.tree.inventory:
241
entry_a = tree_a.tree.inventory[file_id]
242
entry_b = tree_b.tree.inventory[file_id]
243
if (entry_a.kind, entry_b.kind) != ("file", "file"):
245
if None in (entry_a.text_id, entry_b.text_id):
247
if entry_a.text_id != entry_b.text_id:
249
inventory_a[abspath(tree_a.tree, file_id)].interesting = False
250
inventory_b[abspath(tree_b.tree, file_id)].interesting = False
253
241
def generate_cset_optimized(tree_a, tree_b, inventory_a, inventory_b,
254
242
interesting_ids=None):
255
"""Generate a changeset, with preprocessing to select interesting files.
256
using the text_id to mark really-changed files.
257
This permits blazing comparisons when text_ids are present. It also
258
disables metadata comparison for files with identical texts.
243
"""Generate a changeset. If interesting_ids is supplied, only changes
244
to those files will be shown. Metadata changes are stripped.
260
if interesting_ids is None:
261
set_optimized(tree_a, tree_b, inventory_a, inventory_b)
246
if interesting_ids is not None:
263
247
set_interesting(inventory_a, inventory_b, interesting_ids)
264
248
cset = generate_changeset(tree_a, tree_b, inventory_a, inventory_b)
265
249
for entry in cset.entries.itervalues():