Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/algos/snapshot.py
# Copyright (C) 2018-2020 The Software Heritage developers | # Copyright (C) 2018-2020 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from typing import Iterable, Optional | from typing import List, Optional | ||||
from swh.model.model import Snapshot | from swh.model.model import Snapshot | ||||
from swh.storage.algos.origin import origin_get_latest_visit_status | from swh.storage.algos.origin import origin_get_latest_visit_status | ||||
def snapshot_get_all_branches(storage, snapshot_id): | def snapshot_get_all_branches(storage, snapshot_id): | ||||
"""Get all the branches for a given snapshot | """Get all the branches for a given snapshot | ||||
Show All 19 Lines | while next_branch: | ||||
next_branch = data.get("next_branch") | next_branch = data.get("next_branch") | ||||
return ret | return ret | ||||
def snapshot_get_latest( | def snapshot_get_latest( | ||||
storage, | storage, | ||||
origin: str, | origin: str, | ||||
allowed_statuses: Optional[Iterable[str]] = None, | allowed_statuses: Optional[List[str]] = None, | ||||
branches_count: Optional[int] = None, | branches_count: Optional[int] = None, | ||||
) -> Optional[Snapshot]: | ) -> Optional[Snapshot]: | ||||
"""Get the latest snapshot for the given origin, optionally only from visits that have | """Get the latest snapshot for the given origin, optionally only from visits that have | ||||
one of the given allowed_statuses. | one of the given allowed_statuses. | ||||
The branches of the snapshot are iterated in the lexicographical | The branches of the snapshot are iterated in the lexicographical | ||||
order of their names. | order of their names. | ||||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |