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

  • Committer: Jelmer Vernooij
  • Date: 2018-11-16 19:47:19 UTC
  • mfrom: (7178 work)
  • mto: This revision was merged to the branch mainline in revision 7179.
  • Revision ID: jelmer@jelmer.uk-20181116194719-m5ut2wfuze5x9s1p
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
from __future__ import absolute_import
20
20
 
21
 
from dulwich.errors import (
22
 
    NotTreeError,
23
 
    )
24
21
from dulwich.object_store import (
25
22
    tree_lookup_path,
26
23
    )
27
24
 
28
 
from ..errors import UnavailableRepresentation
 
25
from ..errors import (
 
26
    NoSuchRevision,
 
27
    UnavailableRepresentation,
 
28
    )
29
29
from ..graph import Graph
30
30
from ..revision import (
31
31
    NULL_REVISION,
32
32
    )
33
33
 
34
 
from .filegraph import GitFileLastChangeScanner
35
 
 
36
34
 
37
35
class GitFulltextContentFactory(object):
38
36
    """Static data content factory.
64
62
        elif storage_kind == 'chunked':
65
63
            return self.store[self.blob_id].as_raw_chunks()
66
64
        raise UnavailableRepresentation(self.key, storage_kind,
67
 
                'fulltext')
 
65
                                        'fulltext')
68
66
 
69
67
 
70
68
class GitAbsentContentFactory(object):
98
96
        self.store = self.change_scanner.repository._git.object_store
99
97
 
100
98
    def _get_parents(self, path, text_revision):
101
 
        commit_id, mapping = self.change_scanner.repository.lookup_bzr_revision_id(
102
 
            text_revision)
 
99
        commit_id, mapping = (
 
100
            self.change_scanner.repository.lookup_bzr_revision_id(
 
101
                text_revision))
103
102
        text_parents = []
104
103
        for commit_parent in self.store[commit_id].parents:
105
104
            try:
106
 
                (path, text_parent) = self.change_scanner.find_last_change_revision(path.encode('utf-8'), commit_parent)
 
105
                (path, text_parent) = (
 
106
                    self.change_scanner.find_last_change_revision(
 
107
                        path.encode('utf-8'), commit_parent))
107
108
            except KeyError:
108
109
                continue
109
110
            if text_parent not in text_parents:
110
111
                text_parents.append(text_parent)
111
 
        return tuple([(path.decode('utf-8'),
112
 
            self.change_scanner.repository.lookup_foreign_revision_id(p)) for p
113
 
            in text_parents])
 
112
        return tuple([
 
113
            (path.decode('utf-8'),
 
114
                self.change_scanner.repository.lookup_foreign_revision_id(p))
 
115
            for p in text_parents])
114
116
 
115
117
    def get_parent_map(self, keys):
116
118
        ret = {}
132
134
        store = self.change_scanner.repository._git.object_store
133
135
        for (path, text_revision) in keys:
134
136
            try:
135
 
                commit_id, mapping = self.change_scanner.repository.lookup_bzr_revision_id(
136
 
                    text_revision)
137
 
            except errors.NoSuchRevision:
 
137
                commit_id, mapping = (
 
138
                    self.change_scanner.repository.lookup_bzr_revision_id(
 
139
                        text_revision))
 
140
            except NoSuchRevision:
138
141
                yield GitAbsentContentFactory(store, path, text_revision)
139
142
                continue
140
143
 
144
147
                yield GitAbsentContentFactory(store, path, text_revision)
145
148
                continue
146
149
            try:
147
 
                (mode, blob_sha) = tree_lookup_path(store.__getitem__, tree_id, path.encode('utf-8'))
 
150
                (mode, blob_sha) = tree_lookup_path(
 
151
                    store.__getitem__, tree_id, path.encode('utf-8'))
148
152
            except KeyError:
149
153
                yield GitAbsentContentFactory(store, path, text_revision)
150
154
            else:
151
 
                yield GitFulltextContentFactory(store, path, text_revision, blob_sha)
 
155
                yield GitFulltextContentFactory(
 
156
                    store, path, text_revision, blob_sha)