Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/algos/snapshot.py
Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | if branches_count: # partial snapshot | ||||
if not isinstance(branches_count, int) or branches_count <= 0: | if not isinstance(branches_count, int) or branches_count <= 0: | ||||
raise ValueError( | raise ValueError( | ||||
"Parameter branches_count must be a positive integer. " | "Parameter branches_count must be a positive integer. " | ||||
f"Current value is {branches_count}" | f"Current value is {branches_count}" | ||||
) | ) | ||||
snapshot = storage.snapshot_get_branches( | snapshot = storage.snapshot_get_branches( | ||||
snapshot_id, branches_count=branches_count | snapshot_id, branches_count=branches_count | ||||
) | ) | ||||
if snapshot is None: | |||||
return None | |||||
snapshot.pop("next_branch") | snapshot.pop("next_branch") | ||||
else: | else: | ||||
snapshot = snapshot_get_all_branches(storage, snapshot_id) | snapshot = snapshot_get_all_branches(storage, snapshot_id) | ||||
return Snapshot.from_dict(snapshot) if snapshot else None | |||||
return Snapshot.from_dict(snapshot) |