/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: Gustav Hartvigsson
  • Date: 2021-01-09 21:36:27 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20210109213627-h1xwcutzy9m7a99b
Added 'Case Preserving Working Tree Use Cases' from Canonical Wiki

* Addod a page from the Canonical Bazaar wiki
  with information on the scmeatics of case
  perserving filesystems an a case insensitive
  filesystem works.
  
  * Needs re-work, but this will do as it is the
    same inforamoton as what was on the linked
    page in the currint documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Annotate."""
18
18
 
19
 
from __future__ import absolute_import
20
 
 
21
19
from dulwich.object_store import (
22
20
    tree_lookup_path,
23
21
    )
24
22
 
 
23
from .. import osutils
 
24
from ..bzr.versionedfile import UnavailableRepresentation
25
25
from ..errors import (
26
26
    NoSuchRevision,
27
 
    UnavailableRepresentation,
28
27
    )
29
28
from ..graph import Graph
30
29
from ..revision import (
31
30
    NULL_REVISION,
32
31
    )
33
32
 
34
 
 
35
 
class GitFulltextContentFactory(object):
 
33
from .mapping import (
 
34
    decode_git_path,
 
35
    encode_git_path,
 
36
    )
 
37
 
 
38
 
 
39
class GitBlobContentFactory(object):
36
40
    """Static data content factory.
37
41
 
38
42
    This takes a fulltext when created and just returns that during
52
56
        """Create a ContentFactory."""
53
57
        self.store = store
54
58
        self.key = (path, revision)
55
 
        self.storage_kind = 'fulltext'
 
59
        self.storage_kind = 'git-blob'
56
60
        self.parents = None
57
61
        self.blob_id = blob_id
 
62
        self.size = None
58
63
 
59
64
    def get_bytes_as(self, storage_kind):
60
65
        if storage_kind == 'fulltext':
61
66
            return self.store[self.blob_id].as_raw_string()
 
67
        elif storage_kind == 'lines':
 
68
            return list(osutils.chunks_to_lines(self.store[self.blob_id].as_raw_chunks()))
62
69
        elif storage_kind == 'chunked':
63
70
            return self.store[self.blob_id].as_raw_chunks()
64
71
        raise UnavailableRepresentation(self.key, storage_kind,
65
 
                                        'fulltext')
 
72
                                        self.storage_kind)
 
73
 
 
74
    def iter_bytes_as(self, storage_kind):
 
75
        if storage_kind == 'lines':
 
76
            return iter(osutils.chunks_to_lines(self.store[self.blob_id].as_raw_chunks()))
 
77
        elif storage_kind == 'chunked':
 
78
            return iter(self.store[self.blob_id].as_raw_chunks())
 
79
        raise UnavailableRepresentation(self.key, storage_kind,
 
80
                                        self.storage_kind)
66
81
 
67
82
 
68
83
class GitAbsentContentFactory(object):
84
99
        self.key = (path, revision)
85
100
        self.storage_kind = 'absent'
86
101
        self.parents = None
 
102
        self.size = None
87
103
 
88
104
    def get_bytes_as(self, storage_kind):
89
105
        raise ValueError
90
106
 
 
107
    def iter_bytes_as(self, storage_kind):
 
108
        raise ValueError
 
109
 
91
110
 
92
111
class AnnotateProvider(object):
93
112
 
100
119
            self.change_scanner.repository.lookup_bzr_revision_id(
101
120
                text_revision))
102
121
        text_parents = []
 
122
        path = encode_git_path(path)
103
123
        for commit_parent in self.store[commit_id].parents:
104
124
            try:
105
125
                (path, text_parent) = (
106
126
                    self.change_scanner.find_last_change_revision(
107
 
                        path.encode('utf-8'), commit_parent))
 
127
                        path, commit_parent))
108
128
            except KeyError:
109
129
                continue
110
130
            if text_parent not in text_parents:
111
131
                text_parents.append(text_parent)
112
132
        return tuple([
113
 
            (path.decode('utf-8'),
 
133
            (decode_git_path(path),
114
134
                self.change_scanner.repository.lookup_foreign_revision_id(p))
115
135
            for p in text_parents])
116
136
 
148
168
                continue
149
169
            try:
150
170
                (mode, blob_sha) = tree_lookup_path(
151
 
                    store.__getitem__, tree_id, path.encode('utf-8'))
 
171
                    store.__getitem__, tree_id, encode_git_path(path))
152
172
            except KeyError:
153
173
                yield GitAbsentContentFactory(store, path, text_revision)
154
174
            else:
155
 
                yield GitFulltextContentFactory(
 
175
                yield GitBlobContentFactory(
156
176
                    store, path, text_revision, blob_sha)