409
409
extra_trees=extra_trees, require_versioned=True)
412
differ = Differ(to_file, diff_file)
412
differ = Differ(old_tree, new_tree, to_file, diff_file)
413
413
for path, file_id, kind in delta.removed:
415
415
path_encoded = path.encode(path_encoding, "replace")
417
417
old_name = '%s%s\t%s' % (old_label, path,
418
418
_patch_header_date(old_tree, file_id, path))
419
419
new_name = '%s%s\t%s' % (new_label, path, EPOCH_DATE)
420
differ.diff(file_id, old_tree, new_tree, old_name, new_name)
420
differ.diff(file_id, old_name, new_name)
421
421
for path, file_id, kind in delta.added:
423
423
path_encoded = path.encode(path_encoding, "replace")
425
425
old_name = '%s%s\t%s' % (old_label, path, EPOCH_DATE)
426
426
new_name = '%s%s\t%s' % (new_label, path,
427
427
_patch_header_date(new_tree, file_id, path))
428
differ.diff(file_id, old_tree, new_tree, old_name, new_name)
428
differ.diff(file_id, old_name, new_name)
429
429
for (old_path, new_path, file_id, kind,
430
430
text_modified, meta_modified) in delta.renamed:
501
501
def _maybe_diff_file_or_symlink(old_path, old_tree, file_id,
502
502
new_path, new_tree, text_modified, differ):
503
503
if text_modified:
504
differ.diff(file_id, old_tree, new_tree, old_path, new_path)
504
differ.diff(file_id, old_path, new_path)
507
507
class Differ(object):
509
def __init__(self, to_file, text_diff):
509
def __init__(self, old_tree, new_tree, to_file, text_diff):
510
self.old_tree = old_tree
511
self.new_tree = new_tree
510
512
self.to_file = to_file
511
513
self.text_diff = text_diff
513
def diff(self, file_id, old_tree, new_tree, old_name, new_name):
515
def diff(self, file_id, old_name, new_name):
515
old_entry = old_tree.inventory[file_id]
517
old_entry = self.old_tree.inventory[file_id]
516
518
except errors.NoSuchId:
519
new_entry = new_tree.inventory[file_id]
521
new_entry = self.new_tree.inventory[file_id]
520
522
except errors.NoSuchId:
522
524
if old_entry is None:
523
new_entry.diff(self.text_diff, new_name, new_tree, old_name,
524
old_entry, old_tree, self.to_file, reverse=True)
525
new_entry.diff(self.text_diff, new_name, self.new_tree, old_name,
526
old_entry, self.old_tree, self.to_file,
526
old_entry.diff(self.text_diff, old_name, old_tree, new_name,
527
new_entry, new_tree, self.to_file)
529
old_entry.diff(self.text_diff, old_name, self.old_tree, new_name,
530
new_entry, self.new_tree, self.to_file)