Skip to content
Snippets Groups Projects
Commit dbb12fdb authored by Raphaël Gomès's avatar Raphaël Gomès
Browse files

new-loader: save ExtID for each revision

... instead of doing it in bulk at the end.
parent e666b0dd
No related branches found
No related tags found
No related merge requests found
......@@ -353,8 +353,6 @@ class HgLoaderFromDisk(BaseLoader):
target_type=TargetType.RELEASE,
)
extids = []
for hg_nodeid, revision_sha1git in self._revision_nodeid_to_sha1git.items():
if hg_nodeid in branch_by_hg_nodeid:
name = branch_by_hg_nodeid[hg_nodeid]
......@@ -369,20 +367,9 @@ class HgLoaderFromDisk(BaseLoader):
target=name, target_type=TargetType.ALIAS,
)
if hg_nodeid not in self._latest_heads:
revision_swhid = identifiers.CoreSWHID(
object_type=identifiers.ObjectType.REVISION,
object_id=revision_sha1git,
)
extids.append(
ExtID(extid_type=EXTID_TYPE, extid=hg_nodeid, target=revision_swhid)
)
snapshot = Snapshot(branches=snapshot_branches)
self.storage.snapshot_add([snapshot])
self.storage.extid_add(extids)
self.flush()
self.loaded_snapshot_id = snapshot.id
......@@ -499,6 +486,14 @@ class HgLoaderFromDisk(BaseLoader):
self._revision_nodeid_to_sha1git[hg_nodeid] = revision.id
self.storage.revision_add([revision])
# Save the mapping from SWHID to hg id
revision_swhid = identifiers.CoreSWHID(
object_type=identifiers.ObjectType.REVISION, object_id=revision.id,
)
self.storage.extid_add(
[ExtID(extid_type=EXTID_TYPE, extid=hg_nodeid, target=revision_swhid)]
)
def store_release(self, name: bytes, target: Sha1Git) -> Sha1Git:
"""Store a release given its name and its target.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment