diff --git a/swh/web/browse/snapshot_context.py b/swh/web/browse/snapshot_context.py --- a/swh/web/browse/snapshot_context.py +++ b/swh/web/browse/snapshot_context.py @@ -13,7 +13,16 @@ from django.template.defaultfilters import filesizeformat from django.utils.html import escape -from swh.model.identifiers import CONTENT, DIRECTORY, RELEASE, REVISION, SNAPSHOT, swhid +from swh.model.hashutil import hash_to_bytes +from swh.model.identifiers import ( + CONTENT, + DIRECTORY, + RELEASE, + REVISION, + SNAPSHOT, + CoreSWHID, + ObjectType, +) from swh.model.model import Snapshot from swh.web.browse.utils import ( content_display_max_size, @@ -500,7 +509,9 @@ is_empty = (snapshot_sizes["release"] + snapshot_sizes["revision"]) == 0 - swh_snp_id = swhid("snapshot", snapshot_id) + swh_snp_id = str( + CoreSWHID(object_type=ObjectType.SNAPSHOT, object_id=hash_to_bytes(snapshot_id)) + ) if visit_info: timestamp = format_utc_iso_date(visit_info["date"]) diff --git a/swh/web/browse/views/revision.py b/swh/web/browse/views/revision.py --- a/swh/web/browse/views/revision.py +++ b/swh/web/browse/views/revision.py @@ -12,7 +12,15 @@ from django.template.defaultfilters import filesizeformat from django.utils.safestring import mark_safe -from swh.model.identifiers import CONTENT, DIRECTORY, REVISION, SNAPSHOT, swhid +from swh.model.hashutil import hash_to_bytes +from swh.model.identifiers import ( + CONTENT, + DIRECTORY, + REVISION, + SNAPSHOT, + CoreSWHID, + ObjectType, +) from swh.web.browse.browseurls import browse_route from swh.web.browse.snapshot_context import get_snapshot_context from swh.web.browse.utils import ( @@ -264,7 +272,9 @@ revision_log_data = format_log_entries(revision_log, per_page) - swh_rev_id = swhid("revision", sha1_git) + swh_rev_id = str( + CoreSWHID(object_type=ObjectType.REVISION, object_id=hash_to_bytes(sha1_git)) + ) return render( request, diff --git a/swh/web/tests/api/views/test_graph.py b/swh/web/tests/api/views/test_graph.py --- a/swh/web/tests/api/views/test_graph.py +++ b/swh/web/tests/api/views/test_graph.py @@ -11,7 +11,8 @@ from django.http.response import StreamingHttpResponse -from swh.model.identifiers import ORIGIN, SNAPSHOT, swhid +from swh.model.hashutil import hash_to_bytes +from swh.model.identifiers import ExtendedObjectType, ExtendedSWHID from swh.web.api.views.graph import API_GRAPH_PERM from swh.web.common.utils import reverse from swh.web.config import SWH_WEB_INTERNAL_SERVER_NAME, get_config @@ -171,10 +172,16 @@ ): hasher = hashlib.sha1() hasher.update(origin["url"].encode()) - origin_sha1 = hasher.hexdigest() - origin_swhid = str(swhid(ORIGIN, origin_sha1)) + origin_sha1 = hasher.digest() + origin_swhid = str( + ExtendedSWHID(object_type=ExtendedObjectType.ORIGIN, object_id=origin_sha1) + ) snapshot = archive_data.snapshot_get_latest(origin["url"])["id"] - snapshot_swhid = str(swhid(SNAPSHOT, snapshot)) + snapshot_swhid = str( + ExtendedSWHID( + object_type=ExtendedObjectType.SNAPSHOT, object_id=hash_to_bytes(snapshot) + ) + ) _authenticate_graph_user(api_client, mocker)