/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/filegraph.py

  • Committer: Jelmer Vernooij
  • Date: 2019-03-04 00:16:27 UTC
  • mfrom: (7293 work)
  • mto: This revision was merged to the branch mainline in revision 7318.
  • Revision ID: jelmer@jelmer.uk-20190304001627-v6u7o6pf97tukhek
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
            raise TypeError(path)
45
45
        commit = self.store[commit_id]
46
46
        target_mode, target_sha = tree_lookup_path(self.store.__getitem__,
47
 
            commit.tree, path)
 
47
                                                   commit.tree, path)
48
48
        if path == b'':
49
49
            target_mode = stat.S_IFDIR
50
50
        if target_mode is None:
51
 
            raise AssertionError("sha %r for %r in %r" % (target_sha, path, commit_id))
 
51
            raise AssertionError("sha %r for %r in %r" %
 
52
                                 (target_sha, path, commit_id))
52
53
        while True:
53
54
            parent_commits = []
54
55
            for parent_commit in [self.store[c] for c in commit.parents]:
55
56
                try:
56
57
                    mode, sha = tree_lookup_path(self.store.__getitem__,
57
 
                        parent_commit.tree, path)
 
58
                                                 parent_commit.tree, path)
58
59
                except (NotTreeError, KeyError):
59
60
                    continue
60
61
                else:
64
65
                # Candidate found iff, mode or text changed,
65
66
                # or is a directory that didn't previously exist.
66
67
                if mode != target_mode or (
67
 
                    not stat.S_ISDIR(target_mode) and sha != target_sha):
68
 
                        return (path, commit.id)
 
68
                        not stat.S_ISDIR(target_mode) and sha != target_sha):
 
69
                    return (path, commit.id)
69
70
            if parent_commits == []:
70
71
                break
71
72
            commit = parent_commits[0]
79
80
        self.store = self.change_scanner.repository._git.object_store
80
81
 
81
82
    def _get_parents(self, file_id, text_revision):
82
 
        commit_id, mapping = self.change_scanner.repository.lookup_bzr_revision_id(
83
 
            text_revision)
 
83
        commit_id, mapping = (
 
84
            self.change_scanner.repository.lookup_bzr_revision_id(
 
85
                text_revision))
84
86
        try:
85
87
            path = mapping.parse_file_id(file_id)
86
88
        except ValueError:
88
90
        text_parents = []
89
91
        for commit_parent in self.store[commit_id].parents:
90
92
            try:
91
 
                (path, text_parent) = self.change_scanner.find_last_change_revision(path.encode('utf-8'), commit_parent)
 
93
                (path, text_parent) = (
 
94
                    self.change_scanner.find_last_change_revision(
 
95
                        path.encode('utf-8'), commit_parent))
92
96
            except KeyError:
93
97
                continue
94
98
            if text_parent not in text_parents:
95
99
                text_parents.append(text_parent)
96
 
        return tuple([(file_id,
97
 
            self.change_scanner.repository.lookup_foreign_revision_id(p)) for p
98
 
            in text_parents])
 
100
        return tuple([
 
101
            (file_id,
 
102
                self.change_scanner.repository.lookup_foreign_revision_id(p))
 
103
            for p in text_parents])
99
104
 
100
105
    def get_parent_map(self, keys):
101
106
        ret = {}