26
from bzrlib.revision import (
29
26
from bzrlib.versionedfile import (
30
27
AbsentContentFactory,
31
FulltextContentFactory,
28
ChunkedContentFactory,
36
33
class GitRevisions(VersionedFiles):
38
def __init__(self, object_store):
35
def __init__(self, repository, object_store):
36
self.repository = repository
39
37
self.object_store = object_store
41
39
def check(self, progressbar=None):
55
53
def get_record_stream(self, keys, ordering, include_delta_closure):
56
(commit_id, mapping) = self.repository.lookup_bzr_revision_id(revid)
59
text = self.object_store.get_raw(sha)
58
commit = self.object_store[commit_id]
61
60
yield AbsentContentFactory(key)
63
yield FulltextContentFactory(key, None, None, text)
62
yield ChunkedContentFactory(key,
63
tuple([(self.repository.lookup_foreign_revision_id(p, mapping),) for p in commit.parents]), None,
64
commit.as_raw_chunks())
65
66
def get_parent_map(self, keys):
69
(commit_id, mapping) = self.repository.lookup_bzr_revision_id(revid)
69
ret[(key,)] = [(p,) for p in self.object_store[key].parents]
71
ret[(revid,)] = [(self.repository.lookup_foreign_revision_id(p, mapping),) for p in self.object_store[commit_id].parents]
88
90
def get_record_stream(self, keys, ordering, include_delta_closure):
90
92
(fileid, revid) = key
91
(foreign_revid, mapping) = self.repository.lookup_git_revid(revid)
92
root_tree = self.object_store[foreign_revid].tree
93
(commit_id, mapping) = self.repository.lookup_bzr_revision_id(revid)
94
root_tree = self.object_store[commit_id].tree
93
95
path = mapping.parse_file_id(fileid)
95
obj = tree_lookup_path(self.object_store.__getitem__,
97
obj = tree_lookup_path(
98
self.object_store.__getitem__, root_tree, path)
99
if isinstance(obj, tuple):
100
(mode, item_id) = obj
101
obj = self.object_store[item_id]
98
103
yield AbsentContentFactory(key)
100
105
if isinstance(obj, Tree):
101
yield FulltextContentFactory(key, None, None, "")
106
yield ChunkedContentFactory(key, None, None, [])
102
107
elif isinstance(obj, Blob):
103
yield FulltextContentFactory(key, None, None, obj._text)
108
yield ChunkedContentFactory(key, None, None, obj.chunked)
105
yield AbsentContentFactory(key)
110
raise AssertionError("file text resolved to %r" % obj)
107
112
def get_parent_map(self, keys):
108
113
raise NotImplementedError(self.get_parent_map)