14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
from bzrlib.revision import NULL_REVISION
18
from bzrlib.versionedfile import VersionedFiles, AbsentContentFactory
17
from dulwich.object_store import (
20
from dulwich.objects import (
26
from bzrlib.revision import (
29
from bzrlib.versionedfile import (
31
FulltextContentFactory,
36
class GitRevisions(VersionedFiles):
38
def __init__(self, object_store):
39
self.object_store = object_store
41
def check(self, progressbar=None):
45
for sha in self.object_store:
46
if type(sha) == Commit:
50
return list(self.iterkeys())
52
def add_mpdiffs(self, records):
53
raise NotImplementedError(self.add_mpdiffs)
55
def get_record_stream(self, keys, ordering, include_delta_closure):
59
text = self.object_store.get_raw(sha)
61
yield AbsentContentFactory(key)
63
yield FulltextContentFactory(key, None, None, text)
65
def get_parent_map(self, keys):
69
ret[(key,)] = [(p,) for p in self.object_store[key].parents]
20
75
class GitTexts(VersionedFiles):
76
"""A texts VersionedFiles instance that is backed onto a Git object store."""
22
78
def __init__(self, repository):
23
79
self.repository = repository
80
self.object_store = self.repository._git.object_store
25
82
def check(self, progressbar=None):
31
88
def get_record_stream(self, keys, ordering, include_delta_closure):
33
yield AbsentContentFactory(key)
91
(foreign_revid, mapping) = self.repository.lookup_git_revid(revid)
92
root_tree = self.object_store[foreign_revid].tree
93
path = mapping.parse_file_id(fileid)
95
obj = tree_lookup_path(self.object_store.__getitem__,
98
yield AbsentContentFactory(key)
100
if isinstance(obj, Tree):
101
yield FulltextContentFactory(key, None, None, "")
102
elif isinstance(obj, Blob):
103
yield FulltextContentFactory(key, None, None, obj._text)
105
yield AbsentContentFactory(key)
35
107
def get_parent_map(self, keys):
36
108
raise NotImplementedError(self.get_parent_map)