Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7163580
D3307.id11802.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
D3307.id11802.diff
View Options
diff --git a/requirements-swh.txt b/requirements-swh.txt
--- a/requirements-swh.txt
+++ b/requirements-swh.txt
@@ -1,4 +1,4 @@
-swh.storage >= 0.1
+swh.storage >= 0.7.0
swh.model >= 0.3
swh.scheduler >= 0.0.39
swh.loader.core >= 0.3.2
diff --git a/swh/loader/svn/loader.py b/swh/loader/svn/loader.py
--- a/swh/loader/svn/loader.py
+++ b/swh/loader/svn/loader.py
@@ -31,7 +31,7 @@
from swh.model import from_disk
from swh.loader.core.loader import BaseLoader
from swh.loader.core.utils import clean_dangling_folders
-from swh.storage.algos.snapshot import snapshot_get_all_branches
+from swh.storage.algos.snapshot import snapshot_get_latest
from . import svn, converters
from .utils import (
@@ -166,13 +166,14 @@
self.svnrepo.clean_fs(local_dirname)
return h
- def swh_latest_snapshot_revision(self, origin_url, previous_swh_revision=None):
+ def swh_latest_snapshot_revision(
+ self, origin_url: str, previous_swh_revision: Optional[bytes] = None
+ ):
"""Look for latest snapshot revision and returns it if any.
Args:
- origin_url (str): Origin identifier
- previous_swh_revision: (optional) id of a possible
- previous swh revision
+ origin_url: Origin identifier
+ previous_swh_revision: id of a possible previous swh revision
Returns:
dict: The latest known point in time. Dict with keys:
@@ -180,29 +181,27 @@
'revision': latest visited revision
'snapshot': latest snapshot
- If None is found, return an empty dict.
+ If nothing matching criteria is found, return an empty dict.
"""
storage = self.storage
- if not previous_swh_revision: # check latest snapshot's revision
- visit = storage.origin_visit_get_latest(origin_url, require_snapshot=True)
- if visit:
- latest_snap = snapshot_get_all_branches(storage, visit["snapshot"])
- if latest_snap:
- branches = latest_snap.get("branches")
- if not branches:
- return {}
- branch = branches.get(DEFAULT_BRANCH)
- if not branch:
- return {}
- target_type = branch["target_type"]
- if target_type != "revision":
- return {}
- previous_swh_revision = branch["target"]
- else:
- return {}
- else:
+
+ latest_snapshot_d = {}
+ if not previous_swh_revision:
+ latest_snapshot = snapshot_get_latest(storage, origin_url)
+ if not latest_snapshot:
+ return {}
+ latest_snapshot_d = latest_snapshot.to_dict()
+ branches = latest_snapshot.branches
+ if not branches:
+ return {}
+ branch = branches.get(DEFAULT_BRANCH)
+ if not branch:
+ return {}
+ target_type = branch.target_type.value
+ if target_type != "revision":
return {}
+ previous_swh_revision = branch.target
if isinstance(previous_swh_revision, dict):
swh_id = previous_swh_revision["id"]
@@ -211,7 +210,7 @@
revs = list(storage.revision_get([swh_id]))
if revs:
- return {"snapshot": latest_snap, "revision": revs[0]}
+ return {"snapshot": latest_snapshot_d, "revision": revs[0]}
return {}
def build_swh_revision(self, rev, commit, dir_id, parents):
@@ -452,6 +451,7 @@
def prepare_origin_visit(self, *args, **kwargs):
self.origin = Origin(url=self.origin_url if self.origin_url else self.svn_url)
+ self.last_visit = self.storage.origin_visit_get_latest(self.origin_url)
def prepare(self, *args, **kwargs):
if self.swh_revision:
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 30, 10:48 AM (1 w, 20 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3222783
Attached To
D3307: loader: Read snapshot out of the last origin visit status
Event Timeline
Log In to Comment