Changeset View
Changeset View
Standalone View
Standalone View
swh/vault/cookers/git_bare.py
Show First 20 Lines • Show All 279 Lines • ▼ Show 20 Lines | def push_revision_subgraph(self, obj_id: Sha1Git) -> None: | ||||
revision_ids = ( | revision_ids = ( | ||||
swhid.object_id | swhid.object_id | ||||
for swhid in map( | for swhid in map( | ||||
identifiers.CoreSWHID.from_string, | identifiers.CoreSWHID.from_string, | ||||
self.graph.visit_nodes(str(obj_swhid), edges="rev:rev"), | self.graph.visit_nodes(str(obj_swhid), edges="rev:rev"), | ||||
) | ) | ||||
) | ) | ||||
self._push(self._rev_stack, revision_ids) | self._push(self._rev_stack, revision_ids) | ||||
except GraphArgumentException: | except GraphArgumentException as e: | ||||
# Revision not found in the graph | logger.info( | ||||
pass | "Revision %s not found in swh-graph, falling back to fetching " | ||||
"history using swh-storage. %s", | |||||
hash_to_hex(obj_id), | |||||
e.args[0], | |||||
) | |||||
else: | else: | ||||
loaded_from_graph = True | loaded_from_graph = True | ||||
if not loaded_from_graph: | if not loaded_from_graph: | ||||
# If swh-graph is not available, or the revision is not yet in | # If swh-graph is not available, or the revision is not yet in | ||||
# swh-graph, fall back to self.storage.revision_log. | # swh-graph, fall back to self.storage.revision_log. | ||||
# self.storage.revision_log also gives us the full revisions, | # self.storage.revision_log also gives us the full revisions, | ||||
# so we load them right now instead of just pushing them on the stack. | # so we load them right now instead of just pushing them on the stack. | ||||
Show All 33 Lines | def push_snapshot_subgraph(self, obj_id: Sha1Git) -> None: | ||||
elif swhid.object_type == identifiers.ObjectType.SNAPSHOT: | elif swhid.object_type == identifiers.ObjectType.SNAPSHOT: | ||||
assert ( | assert ( | ||||
swhid.object_id == obj_id | swhid.object_id == obj_id | ||||
), f"Snapshot {obj_id.hex()} references a different snapshot" | ), f"Snapshot {obj_id.hex()} references a different snapshot" | ||||
else: | else: | ||||
raise NotImplementedError( | raise NotImplementedError( | ||||
f"{swhid.object_type} objects in snapshot subgraphs." | f"{swhid.object_type} objects in snapshot subgraphs." | ||||
) | ) | ||||
except GraphArgumentException: | except GraphArgumentException as e: | ||||
# Revision not found in the graph | logger.info( | ||||
pass | "Snapshot %s not found in swh-graph, falling back to fetching " | ||||
"history for each branch. %s", | |||||
hash_to_hex(obj_id), | |||||
e.args[0], | |||||
) | |||||
else: | else: | ||||
self._push(self._rev_stack, revision_ids) | self._push(self._rev_stack, revision_ids) | ||||
self._push(self._rel_stack, release_ids) | self._push(self._rel_stack, release_ids) | ||||
loaded_from_graph = True | loaded_from_graph = True | ||||
# TODO: when self.graph is available and supports edge labels, use it | # TODO: when self.graph is available and supports edge labels, use it | ||||
# directly to get branch names. | # directly to get branch names. | ||||
snapshot = snapshot_get_all_branches(self.storage, obj_id) | snapshot = snapshot_get_all_branches(self.storage, obj_id) | ||||
▲ Show 20 Lines • Show All 151 Lines • Show Last 20 Lines |