82
82
cms = self._git.commits("--all", max_count=max_count, skip=skip)
84
ret.update([default_mapping.revision_id_foreign_to_bzr(cm.id) for cm in cms])
84
ret.update([self.get_mapping().revision_id_foreign_to_bzr(cm.id) for cm in cms])
87
87
def is_shared(self):
106
cms = self._git.commits(self.lookup_git_revid(revision_id, default_mapping), max_count=max_count, skip=skip)
106
cms = self._git.commits(self.lookup_git_revid(revision_id, self.get_mapping()), max_count=max_count, skip=skip)
107
107
skip += max_count
108
ret += [default_mapping.revision_id_foreign_to_bzr(cm.id) for cm in cms]
108
ret += [self.get_mapping().revision_id_foreign_to_bzr(cm.id) for cm in cms]
109
109
return [None] + ret
111
111
def get_signature_text(self, revision_id):
123
123
def has_signature_for_revision_id(self, revision_id):
126
def get_mapping(self):
127
return default_mapping
126
129
def get_parent_map(self, revision_ids):
128
131
for revid in revision_ids:
129
132
if revid == revision.NULL_REVISION:
135
git_commit_id = self.lookup_git_revid(revid, self.get_mapping())
136
commit = self._git.commit(git_commit_id)
132
137
ret[revid] = tuple([self.get_mapping().revision_id_foreign_to_bzr(p.id) for p in commit.parents])
139
144
raise errors.NoSuchRevision(bzr_revid, self)
141
146
def get_revision(self, revision_id):
142
git_commit_id = self.lookup_git_revid(revision_id, default_mapping)
147
git_commit_id = self.lookup_git_revid(revision_id, self.get_mapping())
143
148
commit = self._git.commit(git_commit_id)
144
149
# print "fetched revision:", git_commit_id
145
revision = self._parse_rev(commit, default_mapping)
150
revision = self._parse_rev(commit, self.get_mapping())
148
153
def has_revision(self, revision_id):
208
213
def __init__(self, repository, revision_id):
209
214
self._repository = repository
210
215
self.revision_id = revision_id
211
git_id = repository.lookup_git_revid(revision_id, default_mapping)
216
git_id = repository.lookup_git_revid(revision_id, repository.get_mapping())
212
217
self.tree = repository._git.commit(git_id).tree
213
218
self._inventory = inventory.Inventory(revision_id=revision_id)
214
219
self._inventory.root.revision = revision_id
225
230
def _build_inventory(self, tree, ie, path):
226
231
assert isinstance(path, str)
227
for b in tree.contents:
228
basename = b.name.decode("utf-8")
232
for name, mode, hexsha in tree.entries():
233
basename = name.decode("utf-8")
232
child_path = urlutils.join(path, b.name)
237
child_path = urlutils.join(path, name)
233
238
file_id = escape_file_id(child_path.encode('utf-8'))
235
240
child_ie = inventory.InventoryDirectory(file_id, basename, ie.file_id)
236
elif b.mode[0] == '1':
238
243
child_ie = inventory.InventoryFile(file_id, basename, ie.file_id)
239
244
child_ie.text_sha1 = osutils.sha_string(b.data)
240
elif b.mode[1] == '2':
241
246
child_ie = inventory.InventoryLink(file_id, basename, ie.file_id)
242
247
child_ie.text_sha1 = osutils.sha_string("")
244
249
raise AssertionError(
245
"Unknown file kind, perms=%r." % (b.mode,))
250
"Unknown file kind, perms=%r." % (mode,))
246
251
child_ie.text_id = b.id
247
252
child_ie.text_size = b.size
249
254
raise AssertionError(
250
"Unknown blob kind, perms=%r." % (b.mode,))
251
child_ie.executable = bool(int(b.mode[3:], 8) & 0111)
255
"Unknown blob kind, perms=%r." % (mode,))
256
child_ie.executable = bool(int(mode[3:], 8) & 0111)
252
257
child_ie.revision = self.revision_id
253
258
self._inventory.add(child_ie)
255
260
self._build_inventory(b, child_ie, child_path)