/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tree.py

  • Committer: Jelmer Vernooij
  • Date: 2020-02-13 23:57:28 UTC
  • mfrom: (7490 work)
  • mto: This revision was merged to the branch mainline in revision 7492.
  • Revision ID: jelmer@jelmer.uk-20200213235728-m6ds0mm3mbs4y182
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
709
709
        :return: None if content filtering is not supported by this tree.
710
710
        """
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
714
713
        else:
715
714
            return None
716
715
 
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)
969
967
        entry_count = 0
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
1029
1027
                continue
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)
1193
1191
 
 
1192
    def find_target_path(self, path, recurse='none'):
 
1193
        """Find target tree path.
 
1194
 
 
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
 
1198
        """
 
1199
        file_id = self.source.path2id(path)
 
1200
        if file_id is None:
 
1201
            raise errors.NoSuchFile(path)
 
1202
        try:
 
1203
            return self.target.id2path(file_id, recurse=recurse)
 
1204
        except errors.NoSuchId:
 
1205
            return None
 
1206
 
 
1207
    def find_source_path(self, path, recurse='none'):
 
1208
        """Find the source tree path.
 
1209
 
 
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
 
1213
        """
 
1214
        file_id = self.target.path2id(path)
 
1215
        if file_id is None:
 
1216
            raise errors.NoSuchFile(path)
 
1217
        try:
 
1218
            return self.source.id2path(file_id, recurse=recurse)
 
1219
        except errors.NoSuchId:
 
1220
            return None
 
1221
 
 
1222
    def find_target_paths(self, paths, recurse='none'):
 
1223
        """Find target tree paths.
 
1224
 
 
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.
 
1228
        """
 
1229
        ret = {}
 
1230
        for path in paths:
 
1231
            ret[path] = self.find_target_path(path, recurse=recurse)
 
1232
        return ret
 
1233
 
 
1234
    def find_source_paths(self, paths, recurse='none'):
 
1235
        """Find source tree paths.
 
1236
 
 
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.
 
1240
        """
 
1241
        ret = {}
 
1242
        for path in paths:
 
1243
            ret[path] = self.find_source_path(path, recurse=recurse)
 
1244
        return ret
 
1245
 
1194
1246
 
1195
1247
InterTree.register_optimiser(InterTree)
1196
1248
 
1204
1256
    :return: Dictionary mapping from from_tree paths to paths in to_tree, or
1205
1257
        None if there is no equivalent path.
1206
1258
    """
1207
 
    ret = {}
1208
 
    for path in paths:
1209
 
        ret[path] = find_previous_path(from_tree, to_tree, path, recurse=recurse)
1210
 
    return ret
1211
 
 
1212
 
 
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)
 
1260
 
 
1261
 
 
1262
def find_previous_path(from_tree, to_tree, path, recurse='none'):
1214
1263
    """Find previous tree path.
1215
1264
 
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
1221
1270
    """
1222
 
    if file_id is None:
1223
 
        file_id = from_tree.path2id(path)
1224
 
    if file_id is None:
1225
 
        raise errors.NoSuchFile(path)
1226
 
    try:
1227
 
        return to_tree.id2path(file_id, recurse=recurse)
1228
 
    except errors.NoSuchId:
1229
 
        return None
 
1271
    return InterTree.get(to_tree, from_tree).find_source_path(
 
1272
        path, recurse=recurse)
1230
1273
 
1231
1274
 
1232
1275
def get_canonical_path(tree, path, normalize):