/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/git/tree.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-02-08 23:46:02 UTC
  • mfrom: (7357.1.7 intertree-find-target-path)
  • Revision ID: breezy.the.bot@gmail.com-20200208234602-59w6n0pyiewl99vi
Move the logic behind find_previous_path onto InterTree, so it can be overriden.

Merged from https://code.launchpad.net/~jelmer/brz/intertree-find-target-path/+merge/369202

Show diffs side-by-side

added added

removed removed

Lines of Context:
985
985
                          want_unversioned=False):
986
986
        raise NotImplementedError(self._iter_git_changes)
987
987
 
 
988
    def find_target_path(self, path, recurse='none'):
 
989
        ret = self.find_target_paths([path], recurse=recurse)
 
990
        return ret[path]
 
991
 
 
992
    def find_source_path(self, path, recurse='none'):
 
993
        ret = self.find_source_paths([path], recurse=recurse)
 
994
        return ret[path]
 
995
 
 
996
    def find_target_paths(self, paths, recurse='none'):
 
997
        paths = set(paths)
 
998
        ret = {}
 
999
        changes = self._iter_git_changes(specific_files=paths)[0]
 
1000
        for (oldpath, newpath), (oldmode, newmode), (oldsha, newsha) in changes:
 
1001
            if oldpath in paths:
 
1002
                ret[oldpath] = newpath
 
1003
        for path in paths:
 
1004
            if path not in ret:
 
1005
                if self.source.has_filename(path):
 
1006
                    if self.target.has_filename(path):
 
1007
                        ret[path] = path
 
1008
                    else:
 
1009
                        ret[path] = None
 
1010
                else:
 
1011
                    raise errors.NoSuchFile(path)
 
1012
        return ret
 
1013
 
 
1014
    def find_source_paths(self, paths, recurse='none'):
 
1015
        paths = set(paths)
 
1016
        ret = {}
 
1017
        changes = self._iter_git_changes(specific_files=paths)[0]
 
1018
        for (oldpath, newpath), (oldmode, newmode), (oldsha, newsha) in changes:
 
1019
            if newpath in paths:
 
1020
                ret[newpath] = oldpath
 
1021
        for path in paths:
 
1022
            if path not in ret:
 
1023
                if self.target.has_filename(path):
 
1024
                    if self.source.has_filename(path):
 
1025
                        ret[path] = path
 
1026
                    else:
 
1027
                        ret[path] = None
 
1028
                else:
 
1029
                    raise errors.NoSuchFile(path)
 
1030
        return ret
 
1031
 
988
1032
 
989
1033
class InterGitRevisionTrees(InterGitTrees):
990
1034
    """InterTree that works between two git revision trees."""