/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: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-01-25 17:16:33 UTC
  • mfrom: (7459.3.7 file-content-factory)
  • Revision ID: breezy.the.bot@gmail.com-20200125171633-7mvl4p52cwdxn9l4
Add a 'lines' storage kind.

Merged from https://code.launchpad.net/~jelmer/brz/file-content-factory/+merge/378072

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
25
26
from ..errors import (
26
27
    NoSuchRevision,
27
28
    UnavailableRepresentation,
32
33
    )
33
34
 
34
35
 
35
 
class GitFulltextContentFactory(object):
 
36
class GitBlobContentFactory(object):
36
37
    """Static data content factory.
37
38
 
38
39
    This takes a fulltext when created and just returns that during
52
53
        """Create a ContentFactory."""
53
54
        self.store = store
54
55
        self.key = (path, revision)
55
 
        self.storage_kind = 'fulltext'
 
56
        self.storage_kind = 'git-blob'
56
57
        self.parents = None
57
58
        self.blob_id = blob_id
58
59
 
59
60
    def get_bytes_as(self, storage_kind):
60
61
        if storage_kind == 'fulltext':
61
62
            return self.store[self.blob_id].as_raw_string()
 
63
        elif storage_kind == 'lines':
 
64
            return osutils.chunks_to_lines(self.store[self.blob_id].as_raw_chunks())
62
65
        elif storage_kind == 'chunked':
63
66
            return self.store[self.blob_id].as_raw_chunks()
64
67
        raise UnavailableRepresentation(self.key, storage_kind,
65
 
                                        'fulltext')
 
68
                                        self.storage_kind)
66
69
 
67
70
 
68
71
class GitAbsentContentFactory(object):
153
156
            except KeyError:
154
157
                yield GitAbsentContentFactory(store, path, text_revision)
155
158
            else:
156
 
                yield GitFulltextContentFactory(
 
159
                yield GitBlobContentFactory(
157
160
                    store, path, text_revision, blob_sha)