diff --git a/swh/loader/mercurial/loader.py b/swh/loader/mercurial/loader.py --- a/swh/loader/mercurial/loader.py +++ b/swh/loader/mercurial/loader.py @@ -58,6 +58,7 @@ ) from swh.loader.core.loader import DVCSLoader from swh.loader.core.utils import clean_dangling_folders +from swh.storage.algos.snapshot import snapshot_get_latest from . import converters from .archive_extract import tmp_extract @@ -117,6 +118,7 @@ self.bundle_path = None self.heads = {} self.releases = {} + self.last_snapshot: Optional[Snapshot] = None def pre_cleanup(self): """Cleanup potential dangling files from prior runs (e.g. OOM killed @@ -168,9 +170,7 @@ if isinstance(visit_date, str): # visit_date can be string or datetime visit_date = parser.parse(visit_date) self.visit_date = visit_date - self.last_visit = self.storage.origin_visit_get_latest( - self.origin_url, require_snapshot=True - ) + self.last_snapshot = snapshot_get_latest(self.storage, self.origin_url) @staticmethod def clone_with_timeout(log, origin, destination, timeout): @@ -598,7 +598,7 @@ def load_status(self): snapshot = self.get_snapshot() load_status = "eventful" - if self.last_visit is not None and self.last_visit["snapshot"] == snapshot.id: + if self.last_snapshot is not None and self.last_snapshot.id == snapshot.id: load_status = "uneventful" return { "status": load_status,