709
709
:return: None if content filtering is not supported by this tree.
711
711
if self.supports_content_filtering():
712
return lambda path, file_id: \
713
self._content_filter_stack(path)
712
return self._content_filter_stack
963
962
from_data = dict(from_entries_by_dir)
964
963
to_entries_by_dir = list(self.target.iter_entries_by_dir(
965
964
specific_files=target_specific_files))
966
path_equivs = find_previous_paths(
967
self.target, self.source, [p for p, e in to_entries_by_dir])
965
path_equivs = self.find_source_paths([p for p, e in to_entries_by_dir])
968
966
num_entries = len(from_entries_by_dir) + len(to_entries_by_dir)
970
968
# the unversioned path lookup only occurs on real trees - where there
1027
1025
if file_id in to_paths:
1028
1026
# already returned
1030
to_path = find_previous_path(self.source, self.target, path)
1028
to_path = self.find_target_path(path)
1031
1029
entry_count += 1
1032
1030
if pb is not None:
1033
1031
pb.update('comparing files', entry_count, num_entries)
1191
1189
target_sha1 = target_verifier_data
1192
1190
return (source_sha1 == target_sha1)
1192
def find_target_path(self, path, recurse='none'):
1193
"""Find target tree path.
1195
:param path: Path to search for (exists in source)
1196
:return: path in target, or None if there is no equivalent path.
1197
:raise NoSuchFile: If the path doesn't exist in source
1199
file_id = self.source.path2id(path)
1201
raise errors.NoSuchFile(path)
1203
return self.target.id2path(file_id, recurse=recurse)
1204
except errors.NoSuchId:
1207
def find_source_path(self, path, recurse='none'):
1208
"""Find the source tree path.
1210
:param path: Path to search for (exists in target)
1211
:return: path in source, or None if there is no equivalent path.
1212
:raise NoSuchFile: if the path doesn't exist in target
1214
file_id = self.target.path2id(path)
1216
raise errors.NoSuchFile(path)
1218
return self.source.id2path(file_id, recurse=recurse)
1219
except errors.NoSuchId:
1222
def find_target_paths(self, paths, recurse='none'):
1223
"""Find target tree paths.
1225
:param paths: Iterable over paths in target to search for
1226
:return: Dictionary mapping from source paths to paths in target , or
1227
None if there is no equivalent path.
1231
ret[path] = self.find_target_path(path, recurse=recurse)
1234
def find_source_paths(self, paths, recurse='none'):
1235
"""Find source tree paths.
1237
:param paths: Iterable over paths in target to search for
1238
:return: Dictionary mapping from target paths to paths in source, or
1239
None if there is no equivalent path.
1243
ret[path] = self.find_source_path(path, recurse=recurse)
1195
1247
InterTree.register_optimiser(InterTree)
1204
1256
:return: Dictionary mapping from from_tree paths to paths in to_tree, or
1205
1257
None if there is no equivalent path.
1209
ret[path] = find_previous_path(from_tree, to_tree, path, recurse=recurse)
1213
def find_previous_path(from_tree, to_tree, path, file_id=None, recurse='none'):
1259
return InterTree.get(to_tree, from_tree).find_source_paths(paths, recurse=recurse)
1262
def find_previous_path(from_tree, to_tree, path, recurse='none'):
1214
1263
"""Find previous tree path.
1216
1265
:param from_tree: From tree
1219
1268
:return: path in to_tree, or None if there is no equivalent path.
1220
1269
:raise NoSuchFile: If the path doesn't exist in from_tree
1223
file_id = from_tree.path2id(path)
1225
raise errors.NoSuchFile(path)
1227
return to_tree.id2path(file_id, recurse=recurse)
1228
except errors.NoSuchId:
1271
return InterTree.get(to_tree, from_tree).find_source_path(
1272
path, recurse=recurse)
1232
1275
def get_canonical_path(tree, path, normalize):