Changeset View
Changeset View
Standalone View
Standalone View
swh/vault/cookers/git_bare.py
Show First 20 Lines • Show All 265 Lines • ▼ Show 20 Lines | def load_directory(self, obj_id: Sha1Git) -> None: | ||||
"dir": self._dir_stack, | "dir": self._dir_stack, | ||||
"rev": self._rev_stack, | "rev": self._rev_stack, | ||||
} | } | ||||
for entry in directory["entries"]: | for entry in directory["entries"]: | ||||
stack = entry_loaders[entry["type"]] | stack = entry_loaders[entry["type"]] | ||||
self._push(stack, [entry["target"]]) | self._push(stack, [entry["target"]]) | ||||
def load_contents(self, obj_ids: List[Sha1Git]) -> None: | def load_contents(self, obj_ids: List[Sha1Git]) -> None: | ||||
for obj_id in obj_ids: | |||||
self.load_content(obj_id) | |||||
def load_content(self, obj_id: Sha1Git) -> None: | |||||
# TODO: add support of filtered objects, somehow? | # TODO: add support of filtered objects, somehow? | ||||
# It's tricky, because, by definition, we can't write a git object with | # It's tricky, because, by definition, we can't write a git object with | ||||
# the expected hash, so git-fsck *will* choke on it. | # the expected hash, so git-fsck *will* choke on it. | ||||
content_sha1 = self.storage.content_find({"sha1_git": obj_id})[0].sha1 | contents = self.storage.content_get(obj_ids, "sha1_git") | ||||
content = self.storage.content_get_data(content_sha1) | for (obj_id, content) in zip(obj_ids, contents): | ||||
self.write_object(obj_id, f"blob {len(content)}\0".encode("ascii") + content) | assert obj_id == content.sha1_git # just to be sure | ||||
content = self.storage.content_get_data(content.sha1) | |||||
self.write_object( | |||||
obj_id, f"blob {len(content)}\0".encode("ascii") + content | |||||
) |