Page MenuHomeSoftware Heritage

D3455.id12237.diff
No OneTemporary

D3455.id12237.diff

diff --git a/requirements-swh-server.txt b/requirements-swh-server.txt
--- a/requirements-swh-server.txt
+++ b/requirements-swh-server.txt
@@ -1,4 +1,4 @@
swh.core[http]
swh.loader.core >= 0.0.71
swh.scheduler >= 0.0.39
-swh.model >= 0.1.0
+swh.model >= 0.3.8
diff --git a/swh/deposit/api/private/deposit_read.py b/swh/deposit/api/private/deposit_read.py
--- a/swh/deposit/api/private/deposit_read.py
+++ b/swh/deposit/api/private/deposit_read.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2017-2019 The Software Heritage developers
+# Copyright (C) 2017-2020 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
@@ -182,10 +182,8 @@
if deposit.parent:
swh_persistent_id = deposit.parent.swh_id
- persistent_identifier = identifiers.parse_persistent_identifier(
- swh_persistent_id
- )
- parent_revision = persistent_identifier.object_id
+ swhid = identifiers.parse_swhid(swh_persistent_id)
+ parent_revision = swhid.object_id
parents = [parent_revision]
else:
parents = []
diff --git a/swh/deposit/api/private/deposit_update_status.py b/swh/deposit/api/private/deposit_update_status.py
--- a/swh/deposit/api/private/deposit_update_status.py
+++ b/swh/deposit/api/private/deposit_update_status.py
@@ -5,7 +5,7 @@
from rest_framework.parsers import JSONParser
-from swh.model.identifiers import DIRECTORY, persistent_identifier, REVISION, SNAPSHOT
+from swh.model.identifiers import DIRECTORY, swhid, REVISION, SNAPSHOT
from . import SWHPrivateAPIView
from ..common import SWHPutDepositAPI
@@ -81,13 +81,13 @@
origin_url = data["origin_url"]
directory_id = data["directory_id"]
revision_id = data["revision_id"]
- dir_id = persistent_identifier(DIRECTORY, directory_id)
- snp_id = persistent_identifier(SNAPSHOT, data["snapshot_id"])
- rev_id = persistent_identifier(REVISION, revision_id)
+ dir_id = swhid(DIRECTORY, directory_id)
+ snp_id = swhid(SNAPSHOT, data["snapshot_id"])
+ rev_id = swhid(REVISION, revision_id)
deposit.swh_id = dir_id
# new id with contextual information
- deposit.swh_id_context = persistent_identifier(
+ deposit.swh_id_context = swhid(
DIRECTORY,
directory_id,
metadata={
diff --git a/swh/deposit/migrations/0018_migrate_swhids.py b/swh/deposit/migrations/0018_migrate_swhids.py
--- a/swh/deposit/migrations/0018_migrate_swhids.py
+++ b/swh/deposit/migrations/0018_migrate_swhids.py
@@ -11,8 +11,8 @@
from swh.deposit.config import DEPOSIT_STATUS_LOAD_SUCCESS
from swh.model.hashutil import hash_to_bytes, hash_to_hex
from swh.model.identifiers import (
- parse_persistent_identifier,
- persistent_identifier,
+ parse_swhid,
+ swhid,
DIRECTORY,
REVISION,
SNAPSHOT,
@@ -105,10 +105,10 @@
for deposit in Deposit.objects.filter(
status=DEPOSIT_STATUS_LOAD_SUCCESS, swh_id_context__isnull=False
):
- obj_dir = parse_persistent_identifier(deposit.swh_id_context)
+ obj_dir = parse_swhid(deposit.swh_id_context)
assert obj_dir.object_type == DIRECTORY
- obj_rev = parse_persistent_identifier(deposit.swh_anchor_id)
+ obj_rev = parse_swhid(deposit.swh_anchor_id)
assert obj_rev.object_type == REVISION
if set(obj_dir.metadata.keys()) != {"origin"}:
@@ -146,13 +146,13 @@
old_swh_anchor_id_context = deposit.swh_anchor_id_context
# Update
- deposit.swh_id_context = persistent_identifier(
+ deposit.swh_id_context = swhid(
DIRECTORY,
dir_id,
metadata={
"origin": origin,
- "visit": persistent_identifier(SNAPSHOT, snp_id),
- "anchor": persistent_identifier(REVISION, rev_id),
+ "visit": swhid(SNAPSHOT, snp_id),
+ "anchor": swhid(REVISION, rev_id),
"path": "/",
},
)
@@ -250,7 +250,7 @@
for deposit in Deposit.objects.filter(
status=DEPOSIT_STATUS_LOAD_SUCCESS, swh_id_context__isnull=True
):
- obj_rev = parse_persistent_identifier(deposit.swh_id)
+ obj_rev = parse_swhid(deposit.swh_id)
if obj_rev.object_type == DIRECTORY:
# Assuming the migration is already done for that deposit
logger.warning(
@@ -301,20 +301,20 @@
continue
# New SWHIDs ids
- deposit.swh_id = persistent_identifier(DIRECTORY, dir_id)
- deposit.swh_id_context = persistent_identifier(
+ deposit.swh_id = swhid(DIRECTORY, dir_id)
+ deposit.swh_id_context = swhid(
DIRECTORY,
dir_id,
metadata={
"origin": origin,
- "visit": persistent_identifier(SNAPSHOT, snp_id),
- "anchor": persistent_identifier(REVISION, rev_id),
+ "visit": swhid(SNAPSHOT, snp_id),
+ "anchor": swhid(REVISION, rev_id),
"path": "/",
},
)
# Realign the remaining deposit SWHIDs fields
- deposit.swh_anchor_id = persistent_identifier(REVISION, rev_id)
- deposit.swh_anchor_id_context = persistent_identifier(
+ deposit.swh_anchor_id = swhid(REVISION, rev_id)
+ deposit.swh_anchor_id_context = swhid(
REVISION, rev_id, metadata={"origin": origin,}
)
diff --git a/swh/deposit/tests/api/test_deposit_private_update_status.py b/swh/deposit/tests/api/test_deposit_private_update_status.py
--- a/swh/deposit/tests/api/test_deposit_private_update_status.py
+++ b/swh/deposit/tests/api/test_deposit_private_update_status.py
@@ -9,7 +9,7 @@
from django.urls import reverse
from rest_framework import status
-from swh.model.identifiers import DIRECTORY, persistent_identifier, REVISION, SNAPSHOT
+from swh.model.identifiers import DIRECTORY, swhid, REVISION, SNAPSHOT
from swh.deposit.api.private.deposit_update_status import MANDATORY_KEYS
@@ -53,9 +53,9 @@
"origin_url": origin_url,
}
for url in private_check_url_endpoints(deposit_collection, deposit):
- dir_id = persistent_identifier(DIRECTORY, directory_id)
- rev_id = persistent_identifier(REVISION, revision_id)
- snp_id = persistent_identifier(SNAPSHOT, snapshot_id)
+ dir_id = swhid(DIRECTORY, directory_id)
+ rev_id = swhid(REVISION, revision_id)
+ snp_id = swhid(SNAPSHOT, snapshot_id)
expected_swh_id = "swh:1:dir:%s" % directory_id
expected_swh_id_context = (
diff --git a/swh/deposit/tests/conftest.py b/swh/deposit/tests/conftest.py
--- a/swh/deposit/tests/conftest.py
+++ b/swh/deposit/tests/conftest.py
@@ -21,7 +21,7 @@
from swh.scheduler import get_scheduler
from swh.scheduler.tests.conftest import * # noqa
-from swh.model.identifiers import DIRECTORY, persistent_identifier, REVISION, SNAPSHOT
+from swh.model.identifiers import DIRECTORY, swhid, REVISION, SNAPSHOT
from swh.deposit.config import setup_django_for
from swh.deposit.parsers import parse_xml
from swh.deposit.config import SWHDefaultConfig
@@ -408,14 +408,14 @@
directory_id = "42a13fc721c8716ff695d0d62fc851d641f3a12b"
revision_id = "548b3c0a2bb43e1fca191e24b5803ff6b3bc7c10"
snapshot_id = "e5e82d064a9c3df7464223042e0c55d72ccff7f0"
- deposit.swh_id = persistent_identifier(DIRECTORY, directory_id)
- deposit.swh_id_context = persistent_identifier(
+ deposit.swh_id = swhid(DIRECTORY, directory_id)
+ deposit.swh_id_context = swhid(
DIRECTORY,
directory_id,
metadata={
"origin": origin,
- "visit": persistent_identifier(SNAPSHOT, snapshot_id),
- "anchor": persistent_identifier(REVISION, revision_id),
+ "visit": swhid(SNAPSHOT, snapshot_id),
+ "anchor": swhid(REVISION, revision_id),
"path": "/",
},
)

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 17, 4:11 PM (2 d, 20 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3217126

Event Timeline