/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: Martin
  • Date: 2018-11-18 19:48:57 UTC
  • mto: This revision was merged to the branch mainline in revision 7205.
  • Revision ID: gzlist@googlemail.com-20181118194857-mqty4xka790jf934
Fix remaining whitespace lint in codebase

Enables rules W191, W291, W293, and W391 for flake8.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
    tree_lookup_path,
23
23
    )
24
24
 
25
 
from .. import osutils
26
25
from ..errors import (
27
26
    NoSuchRevision,
28
27
    UnavailableRepresentation,
33
32
    )
34
33
 
35
34
 
36
 
class GitBlobContentFactory(object):
 
35
class GitFulltextContentFactory(object):
37
36
    """Static data content factory.
38
37
 
39
38
    This takes a fulltext when created and just returns that during
53
52
        """Create a ContentFactory."""
54
53
        self.store = store
55
54
        self.key = (path, revision)
56
 
        self.storage_kind = 'git-blob'
 
55
        self.storage_kind = 'fulltext'
57
56
        self.parents = None
58
57
        self.blob_id = blob_id
59
 
        self.size = None
60
58
 
61
59
    def get_bytes_as(self, storage_kind):
62
60
        if storage_kind == 'fulltext':
63
61
            return self.store[self.blob_id].as_raw_string()
64
 
        elif storage_kind == 'lines':
65
 
            return list(osutils.chunks_to_lines(self.store[self.blob_id].as_raw_chunks()))
66
62
        elif storage_kind == 'chunked':
67
63
            return self.store[self.blob_id].as_raw_chunks()
68
64
        raise UnavailableRepresentation(self.key, storage_kind,
69
 
                                        self.storage_kind)
70
 
 
71
 
    def iter_bytes_as(self, storage_kind):
72
 
        if storage_kind == 'lines':
73
 
            return iter(osutils.chunks_to_lines(self.store[self.blob_id].as_raw_chunks()))
74
 
        elif storage_kind == 'chunked':
75
 
            return iter(self.store[self.blob_id].as_raw_chunks())
76
 
        raise UnavailableRepresentation(self.key, storage_kind,
77
 
                                        self.storage_kind)
 
65
                                        'fulltext')
78
66
 
79
67
 
80
68
class GitAbsentContentFactory(object):
96
84
        self.key = (path, revision)
97
85
        self.storage_kind = 'absent'
98
86
        self.parents = None
99
 
        self.size = None
100
87
 
101
88
    def get_bytes_as(self, storage_kind):
102
89
        raise ValueError
103
90
 
104
 
    def iter_bytes_as(self, storage_kind):
105
 
        raise ValueError
106
 
 
107
91
 
108
92
class AnnotateProvider(object):
109
93
 
116
100
            self.change_scanner.repository.lookup_bzr_revision_id(
117
101
                text_revision))
118
102
        text_parents = []
119
 
        path = path.encode('utf-8')
120
103
        for commit_parent in self.store[commit_id].parents:
121
104
            try:
122
105
                (path, text_parent) = (
123
106
                    self.change_scanner.find_last_change_revision(
124
 
                        path, commit_parent))
 
107
                        path.encode('utf-8'), commit_parent))
125
108
            except KeyError:
126
109
                continue
127
110
            if text_parent not in text_parents:
169
152
            except KeyError:
170
153
                yield GitAbsentContentFactory(store, path, text_revision)
171
154
            else:
172
 
                yield GitBlobContentFactory(
 
155
                yield GitFulltextContentFactory(
173
156
                    store, path, text_revision, blob_sha)