diff --git a/requirements-swh.txt b/requirements-swh.txt --- a/requirements-swh.txt +++ b/requirements-swh.txt @@ -2,4 +2,4 @@ swh.loader.core >= 0.3.2 swh.model >= 0.3.0 swh.scheduler >= 0.0.39 -swh.storage >= 0.3.0 +swh.storage >= 0.7.0 diff --git a/swh/loader/git/from_disk.py b/swh/loader/git/from_disk.py --- a/swh/loader/git/from_disk.py +++ b/swh/loader/git/from_disk.py @@ -22,6 +22,7 @@ from swh.model import hashutil from swh.model.model import Origin, Snapshot, SnapshotBranch, TargetType from swh.loader.core.loader import DVCSLoader +from swh.storage.algos.origin import origin_get_latest_visit_status from . import converters, utils @@ -139,13 +140,14 @@ def fetch_data(self): """Fetch the data from the data source""" - previous_visit = self.storage.origin_visit_get_latest( - self.origin.url, require_snapshot=True + visit_and_status = origin_get_latest_visit_status( + self.storage, self.origin_url, require_snapshot=True ) - if previous_visit: - self.previous_snapshot_id = previous_visit["snapshot"] - else: + if visit_and_status is None: self.previous_snapshot_id = None + else: + _, visit_status = visit_and_status + self.previous_snapshot_id = visit_status.snapshot type_to_ids = defaultdict(list) for oid in self.iter_objects(): diff --git a/swh/loader/git/loader.py b/swh/loader/git/loader.py --- a/swh/loader/git/loader.py +++ b/swh/loader/git/loader.py @@ -30,7 +30,7 @@ Sha1Git, ) from swh.loader.core.loader import DVCSLoader -from swh.storage.algos.snapshot import snapshot_get_all_branches +from swh.storage.algos.snapshot import snapshot_get_latest from . import converters, utils @@ -210,14 +210,7 @@ self.origin = Origin(url=self.origin_url) def get_full_snapshot(self, origin_url) -> Optional[Snapshot]: - visit = self.storage.origin_visit_get_latest(origin_url, require_snapshot=True) - if visit and visit["snapshot"]: - snapshot = snapshot_get_all_branches(self.storage, visit["snapshot"]) - else: - snapshot = None - if snapshot is None: - return None - return Snapshot.from_dict(snapshot) + return snapshot_get_latest(self.storage, origin_url) def prepare(self, *args, **kwargs) -> None: assert self.origin is not None