Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7066429
D6409.id23451.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
D6409.id23451.diff
View Options
diff --git a/swh/provenance/model.py b/swh/provenance/model.py
--- a/swh/provenance/model.py
+++ b/swh/provenance/model.py
@@ -8,9 +8,7 @@
from datetime import datetime
from typing import Iterable, Iterator, List, Optional
-from swh.model.hashutil import hash_to_bytes
-from swh.model.identifiers import origin_identifier
-from swh.model.model import Sha1Git
+from swh.model.model import Origin, Sha1Git
from .archive import ArchiveInterface
@@ -18,7 +16,7 @@
class OriginEntry:
def __init__(self, url: str, snapshot: Sha1Git) -> None:
self.url = url
- self.id: Sha1Git = hash_to_bytes(origin_identifier({"url": self.url}))
+ self.id = Origin(url=self.url).id
self.snapshot = snapshot
self._revisions: Optional[List[RevisionEntry]] = None
diff --git a/swh/provenance/tests/test_provenance_storage.py b/swh/provenance/tests/test_provenance_storage.py
--- a/swh/provenance/tests/test_provenance_storage.py
+++ b/swh/provenance/tests/test_provenance_storage.py
@@ -9,8 +9,7 @@
from typing import Any, Dict, Iterable, Optional, Set, Tuple
from swh.model.hashutil import hash_to_bytes
-from swh.model.identifiers import origin_identifier
-from swh.model.model import Sha1Git
+from swh.model.model import Origin, Sha1Git
from swh.provenance.archive import ArchiveInterface
from swh.provenance.interface import (
EntityType,
@@ -129,7 +128,7 @@
# Test origin methods.
# Add all origins present in the current repo to the storage. Then check that the
# returned results when querying are the same.
- orgs = {hash_to_bytes(origin_identifier(org)): org["url"] for org in data["origin"]}
+ orgs = {Origin(url=org["url"]).id: org["url"] for org in data["origin"]}
assert orgs
assert provenance_storage.origin_add(orgs)
assert provenance_storage.origin_get(set(orgs.keys())) == orgs
@@ -148,16 +147,15 @@
# Add all revisions present in the current repo to the storage, assigning their
# dates and an arbitrary origin to each one. Then check that the returned results
# when querying are the same.
- origin = next(iter(data["origin"]))
- origin_sha1 = hash_to_bytes(origin_identifier(origin))
+ origin = Origin(url=next(iter(data["origin"]))["url"])
# Origin must be inserted in advance.
- assert provenance_storage.origin_add({origin_sha1: origin["url"]})
+ assert provenance_storage.origin_add({origin.id: origin.url})
revs = {rev["id"] for idx, rev in enumerate(data["revision"]) if idx % 6 == 0}
rev_data = {
rev["id"]: RevisionData(
date=ts2dt(rev["date"]) if idx % 2 != 0 else None,
- origin=origin_sha1 if idx % 3 != 0 else None,
+ origin=origin.id if idx % 3 != 0 else None,
)
for idx, rev in enumerate(data["revision"])
if idx % 6 != 0
@@ -316,10 +314,7 @@
# Test revision-in-origin relation.
# Origins must be inserted in advance (cannot be done by `entity_add` inside
# `relation_add_and_compare_result`).
- orgs = {
- hash_to_bytes(origin_identifier(origin)): origin["url"]
- for origin in data["origin"]
- }
+ orgs = {Origin(url=org["url"]).id: org["url"] for org in data["origin"]}
assert provenance_storage.origin_add(orgs)
# Add all revisions that are head of some snapshot branch to the corresponding
# origin.
@@ -332,9 +327,7 @@
if branch["target_type"] == "revision":
rev_in_org.setdefault(branch["target"], set()).add(
RelationData(
- dst=hash_to_bytes(
- origin_identifier({"url": status["origin"]})
- ),
+ dst=Origin(url=status["origin"]).id,
path=None,
)
)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Nov 5 2024, 8:35 AM (11 w, 18 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3224714
Attached To
D6409: Remove direct dependencies on deprecated `swh.model.identifiers` module
Event Timeline
Log In to Comment