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.9.3 -swh.model < 0.4.0 +swh.storage >= 0.10.0 +swh.model >= 0.4.0 swh.scheduler >= 0.0.39 swh.loader.core >= 0.5.2 diff --git a/swh/loader/svn/converters.py b/swh/loader/svn/converters.py --- a/swh/loader/svn/converters.py +++ b/swh/loader/svn/converters.py @@ -3,7 +3,7 @@ # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information -from typing import Any, Dict, Optional, Sequence +from typing import Dict, Optional, Sequence, Tuple from swh.model.model import Person, Revision, RevisionType, TimestampWithTimezone @@ -41,7 +41,7 @@ def build_swh_revision( - rev: int, commit: Dict, repo_uuid: str, dir_id: bytes, parents: Sequence[bytes] + rev: int, commit: Dict, repo_uuid: bytes, dir_id: bytes, parents: Sequence[bytes] ) -> Revision: """Given a svn revision, build a swh revision. @@ -63,12 +63,10 @@ msg = commit["message"] date = commit["author_date"] - metadata: Dict[str, Any] = { - "extra_headers": [ - ["svn_repo_uuid", repo_uuid], - ["svn_revision", str(rev).encode("utf-8")], - ] - } + extra_headers: Tuple[Tuple[bytes, bytes], ...] = ( + (b"svn_repo_uuid", repo_uuid), + (b"svn_revision", str(rev).encode()), + ) return Revision( type=RevisionType.SUBVERSION, @@ -79,6 +77,6 @@ author=author, committer=author, synthetic=True, - metadata=metadata, + extra_headers=extra_headers, parents=tuple(parents), ) 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 @@ -276,10 +276,10 @@ return previous_swh_revision if partial_swh_revision and previous_swh_revision: # will determine from which to start from - extra_headers1 = dict(partial_swh_revision["metadata"]["extra_headers"]) - extra_headers2 = dict(previous_swh_revision["metadata"]["extra_headers"]) - rev_start1 = int(extra_headers1["svn_revision"]) - rev_start2 = int(extra_headers2["svn_revision"]) + extra_headers1 = dict(partial_swh_revision["extra_headers"]) + extra_headers2 = dict(previous_swh_revision["extra_headers"]) + rev_start1 = int(extra_headers1[b"svn_revision"]) + rev_start2 = int(extra_headers2[b"svn_revision"]) if rev_start1 <= rev_start2: return previous_swh_revision return partial_swh_revision @@ -326,8 +326,8 @@ ) if swh_rev: # Yes, we know a previous revision. Try and update it. - extra_headers = dict(swh_rev["metadata"]["extra_headers"]) - revision_start = int(extra_headers["svn_revision"]) + extra_headers = dict(swh_rev["extra_headers"]) + revision_start = int(extra_headers[b"svn_revision"]) revision_parents = { revision_start: swh_rev["parents"], } @@ -682,8 +682,8 @@ try: origin = self.storage.origin_get({"url": svn_url}) last_swh_rev = self.swh_latest_snapshot_revision(origin["url"])["revision"] - last_swh_rev_headers = dict(last_swh_rev["metadata"]["extra_headers"]) - last_loaded_svn_rev = int(last_swh_rev_headers["svn_revision"]) + last_swh_rev_headers = dict(last_swh_rev["extra_headers"]) + last_loaded_svn_rev = int(last_swh_rev_headers[b"svn_revision"]) except Exception: pass return last_loaded_svn_rev diff --git a/swh/loader/svn/tests/test_converters.py b/swh/loader/svn/tests/test_converters.py --- a/swh/loader/svn/tests/test_converters.py +++ b/swh/loader/svn/tests/test_converters.py @@ -83,9 +83,7 @@ "fullname": b"theo ", }, "synthetic": True, - "metadata": { - "extra_headers": [["svn_repo_uuid", b"uuid"], ["svn_revision", b"10"],] - }, + "extra_headers": ((b"svn_repo_uuid", b"uuid"), (b"svn_revision", b"10"),), "parents": (), } )