82
82
cms = self._git.commits("--all", max_count=max_count, skip=skip)
84
ret.update([self.get_mapping().revision_id_foreign_to_bzr(cm.id) for cm in cms])
84
ret.update([default_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, self.get_mapping()), max_count=max_count, skip=skip)
106
cms = self._git.commits(self.lookup_git_revid(revision_id, default_mapping), max_count=max_count, skip=skip)
107
107
skip += max_count
108
ret += [self.get_mapping().revision_id_foreign_to_bzr(cm.id) for cm in cms]
108
ret += [default_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):
112
112
raise errors.NoSuchRevision(self, revision_id)
114
def lookup_revision_id(self, revid):
115
"""Lookup a revision id.
117
:param revid: Bazaar revision id.
118
:return: Tuple with git revisionid and mapping.
120
# Yes, this doesn't really work, but good enough as a stub
121
return osutils.sha(rev_id).hexdigest(), self.get_mapping()
123
114
def has_signature_for_revision_id(self, revision_id):
126
def get_mapping(self):
127
return default_mapping
129
117
def get_parent_map(self, revision_ids):
131
119
for revid in revision_ids:
132
120
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)
137
ret[revid] = tuple([self.get_mapping().revision_id_foreign_to_bzr(p.id) for p in commit.parents])
123
commit = self._git.commit(self.lookup_git_revid(revid, default_mapping))
124
ret[revid] = tuple([default_mapping.revision_id_foreign_to_bzr(p.id) for p in commit.parents])
140
127
def lookup_git_revid(self, bzr_revid, mapping):
144
131
raise errors.NoSuchRevision(bzr_revid, self)
146
133
def get_revision(self, revision_id):
147
git_commit_id = self.lookup_git_revid(revision_id, self.get_mapping())
134
git_commit_id = self.lookup_git_revid(revision_id, default_mapping)
148
135
commit = self._git.commit(git_commit_id)
149
136
# print "fetched revision:", git_commit_id
150
revision = self._parse_rev(commit, self.get_mapping())
137
revision = self._parse_rev(commit, default_mapping)
153
140
def has_revision(self, revision_id):
213
200
def __init__(self, repository, revision_id):
214
201
self._repository = repository
215
202
self.revision_id = revision_id
216
git_id = repository.lookup_git_revid(revision_id, repository.get_mapping())
203
git_id = repository.lookup_git_revid(revision_id, default_mapping)
217
204
self.tree = repository._git.commit(git_id).tree
218
205
self._inventory = inventory.Inventory(revision_id=revision_id)
219
206
self._inventory.root.revision = revision_id
230
217
def _build_inventory(self, tree, ie, path):
231
218
assert isinstance(path, str)
232
for name, mode, hexsha in tree.entries():
233
basename = name.decode("utf-8")
219
for b in tree.contents:
220
basename = b.name.decode("utf-8")
237
child_path = urlutils.join(path, name)
224
child_path = urlutils.join(path, b.name)
238
225
file_id = escape_file_id(child_path.encode('utf-8'))
240
227
child_ie = inventory.InventoryDirectory(file_id, basename, ie.file_id)
228
elif b.mode[0] == '1':
243
230
child_ie = inventory.InventoryFile(file_id, basename, ie.file_id)
244
231
child_ie.text_sha1 = osutils.sha_string(b.data)
232
elif b.mode[1] == '2':
246
233
child_ie = inventory.InventoryLink(file_id, basename, ie.file_id)
247
234
child_ie.text_sha1 = osutils.sha_string("")
249
236
raise AssertionError(
250
"Unknown file kind, perms=%r." % (mode,))
237
"Unknown file kind, perms=%r." % (b.mode,))
251
238
child_ie.text_id = b.id
252
239
child_ie.text_size = b.size
254
241
raise AssertionError(
255
"Unknown blob kind, perms=%r." % (mode,))
256
child_ie.executable = bool(int(mode[3:], 8) & 0111)
242
"Unknown blob kind, perms=%r." % (b.mode,))
243
child_ie.executable = bool(int(b.mode[3:], 8) & 0111)
257
244
child_ie.revision = self.revision_id
258
245
self._inventory.add(child_ie)
260
247
self._build_inventory(b, child_ie, child_path)