/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: 2018-03-12 02:03:26 UTC
  • mto: (6885.7.1 fix-commit-builder)
  • mto: This revision was merged to the branch mainline in revision 6891.
  • Revision ID: jelmer@jelmer.uk-20180312020326-r2wf6v22b52hhm59
Add find_previous_path.

Show diffs side-by-side

added added

removed removed

Lines of Context:
309
309
        """
310
310
        raise NotImplementedError(self._comparison_data)
311
311
 
312
 
    def _file_size(self, entry, stat_value):
313
 
        raise NotImplementedError(self._file_size)
314
 
 
315
312
    def get_file(self, path, file_id=None):
316
313
        """Return a file object for the file file_id in the tree.
317
314
 
620
617
    def supports_content_filtering(self):
621
618
        return False
622
619
 
623
 
    def _content_filter_stack(self, path=None, file_id=None):
 
620
    def _content_filter_stack(self, path=None):
624
621
        """The stack of content filters for a path if filtering is supported.
625
622
 
626
623
        Readers will be applied in first-to-last order.
629
626
 
630
627
        :param path: path relative to the root of the tree
631
628
            or None if unknown
632
 
        :param file_id: file_id or None if unknown
633
629
        :return: the list of filters - [] if there are none
634
630
        """
635
631
        filter_pref_names = filters._get_registered_names()
636
632
        if len(filter_pref_names) == 0:
637
633
            return []
638
 
        if path is None:
639
 
            path = self.id2path(file_id)
640
634
        prefs = next(self.iter_search_rules([path], filter_pref_names))
641
635
        stk = filters._get_filter_stack_for(prefs)
642
636
        if 'filters' in debug.debug_flags:
653
647
        """
654
648
        if self.supports_content_filtering():
655
649
            return lambda path, file_id: \
656
 
                    self._content_filter_stack(path, file_id)
 
650
                    self._content_filter_stack(path)
657
651
        else:
658
652
            return None
659
653
 
1028
1022
            if file_id in to_paths:
1029
1023
                # already returned
1030
1024
                continue
1031
 
            if not self.target.has_id(file_id):
1032
 
                # common case - paths we have not emitted are not present in
1033
 
                # target.
1034
 
                to_path = None
1035
 
            else:
1036
 
                to_path = self.target.id2path(file_id)
 
1025
            to_path = find_previous_path(self.source, self.target, path)
1037
1026
            entry_count += 1
1038
1027
            if pb is not None:
1039
1028
                pb.update('comparing files', entry_count, num_entries)
1441
1430
    """
1442
1431
    ret = {}
1443
1432
    for path in paths:
1444
 
        file_id = from_tree.path2id(path)
1445
 
        if file_id is None:
1446
 
            raise errors.NoSuchFile(path)
1447
 
        try:
1448
 
            ret[path] = to_tree.id2path(file_id)
1449
 
        except errors.NoSuchId:
1450
 
            ret[path] = None
 
1433
        ret[path] = find_previous_path(from_tree, to_tree, path)
1451
1434
    return ret
 
1435
 
 
1436
 
 
1437
def find_previous_path(from_tree, to_tree, path):
 
1438
    """Find previous tree path.
 
1439
 
 
1440
    :param from_tree: From tree
 
1441
    :param to_tree: To tree
 
1442
    :param path: Path to search for
 
1443
    :return: path in to_tree, or None if there is no equivalent path.
 
1444
    """
 
1445
    file_id = from_tree.path2id(path)
 
1446
    if file_id is None:
 
1447
        raise errors.NoSuchFile(path)
 
1448
    try:
 
1449
        return to_tree.id2path(file_id)
 
1450
    except errors.NoSuchId:
 
1451
        return None