Changeset View
Changeset View
Standalone View
Standalone View
swh/vault/cookers/git_bare.py
Show First 20 Lines • Show All 509 Lines • ▼ Show 20 Lines | def load_directory(self, obj_id: Sha1Git) -> None: | ||||
return | return | ||||
entries = [entry.to_dict() for entry in entries_it] | entries = [entry.to_dict() for entry in entries_it] | ||||
directory = {"id": obj_id, "entries": entries} | directory = {"id": obj_id, "entries": entries} | ||||
git_object = identifiers.directory_git_object(directory) | git_object = identifiers.directory_git_object(directory) | ||||
self.write_object(obj_id, git_object) | self.write_object(obj_id, git_object) | ||||
# Add children to the stack | # Add children to the stack | ||||
entry_loaders: Dict[str, List[Sha1Git]] = { | entry_loaders: Dict[str, Optional[List[Sha1Git]]] = { | ||||
"file": self._cnt_stack, | "file": self._cnt_stack, | ||||
"dir": self._dir_stack, | "dir": self._dir_stack, | ||||
"rev": self._rev_stack, | "rev": None, | ||||
anlambert: could you add a comment explaining why the rev entry is None ? | |||||
} | } | ||||
for entry in directory["entries"]: | for entry in directory["entries"]: | ||||
stack = entry_loaders[entry["type"]] | stack = entry_loaders[entry["type"]] | ||||
if stack is not None: | |||||
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: | ||||
# 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. | ||||
contents = self.storage.content_get(obj_ids, "sha1_git") | contents = self.storage.content_get(obj_ids, "sha1_git") | ||||
visible_contents = [] | visible_contents = [] | ||||
▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines |
could you add a comment explaining why the rev entry is None ?