638
638
self.differs, old_path, new_path, None, new_kind)
641
class DiffTreeReference(DiffPath):
643
def diff(self, old_path, new_path, old_kind, new_kind):
644
"""Perform comparison between two tree references. (dummy)
647
if 'tree-reference' not in (old_kind, new_kind):
648
return self.CANNOT_DIFF
649
if old_kind not in ('tree-reference', None):
650
return self.CANNOT_DIFF
651
if new_kind not in ('tree-reference', None):
652
return self.CANNOT_DIFF
641
656
class DiffDirectory(DiffPath):
643
658
def diff(self, old_path, new_path, old_kind, new_kind):
948
963
# list of factories that can provide instances of DiffPath objects
949
964
# may be extended by plugins.
950
965
diff_factories = [DiffSymlink.from_diff_tree,
951
DiffDirectory.from_diff_tree]
966
DiffDirectory.from_diff_tree,
967
DiffTreeReference.from_diff_tree]
953
969
def __init__(self, old_tree, new_tree, to_file, path_encoding='utf-8',
954
970
diff_text=None, extra_factories=None):
1044
1060
def get_encoded_path(path):
1045
1061
if path is not None:
1046
1062
return path.encode(self.path_encoding, "replace")
1047
for (file_id, paths, changed_content, versioned, parent, name, kind,
1048
executable) in sorted(iterator, key=changes_key):
1063
for change in sorted(iterator, key=changes_key):
1049
1064
# The root does not get diffed, and items with no known kind (that
1050
1065
# is, missing) in both trees are skipped as well.
1051
if parent == (None, None) or kind == (None, None):
1066
if change.parent_id == (None, None) or change.kind == (None, None):
1053
if kind[0] == 'symlink' and not self.new_tree.supports_symlinks():
1068
if change.kind[0] == 'symlink' and not self.new_tree.supports_symlinks():
1055
1070
'Ignoring "%s" as symlinks are not '
1056
'supported on this filesystem.' % (paths[0],))
1071
'supported on this filesystem.' % (change.path[0],))
1058
oldpath, newpath = paths
1059
oldpath_encoded = get_encoded_path(paths[0])
1060
newpath_encoded = get_encoded_path(paths[1])
1061
old_present = (kind[0] is not None and versioned[0])
1062
new_present = (kind[1] is not None and versioned[1])
1063
renamed = (parent[0], name[0]) != (parent[1], name[1])
1073
oldpath, newpath = change.path
1074
oldpath_encoded = get_encoded_path(change.path[0])
1075
newpath_encoded = get_encoded_path(change.path[1])
1076
old_present = (change.kind[0] is not None and change.versioned[0])
1077
new_present = (change.kind[1] is not None and change.versioned[1])
1078
executable = change.executable
1080
renamed = (change.parent_id[0], change.name[0]) != (change.parent_id[1], change.name[1])
1065
1082
properties_changed = []
1066
1083
properties_changed.extend(
1088
1105
# modified *somehow*, either content or execute bit.
1089
1106
self.to_file.write(b"=== modified %s '%s'%s\n" % (kind[0].encode('ascii'),
1090
1107
newpath_encoded, prop_str))
1108
if change.changed_content:
1092
1109
self._diff(oldpath, newpath, kind[0], kind[1])
1093
1110
has_changes = 1