Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9343122
D5171.id18496.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
D5171.id18496.diff
View Options
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)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jul 3, 1:17 PM (1 w, 1 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3216095
Attached To
D5171: Remove remaining uses of the deprecated swhid() function.
Event Timeline
Log In to Comment