Page MenuHomeSoftware Heritage

D7399.id26835.diff
No OneTemporary

D7399.id26835.diff

diff --git a/requirements-swh.txt b/requirements-swh.txt
--- a/requirements-swh.txt
+++ b/requirements-swh.txt
@@ -1,4 +1,4 @@
swh.core[db,http] >= 2
swh.counters >= v0.8.0
-swh.model >= 4.4.0
+swh.model >= 6.0.0
swh.objstorage >= 0.2.2
diff --git a/swh/storage/postgresql/converters.py b/swh/storage/postgresql/converters.py
--- a/swh/storage/postgresql/converters.py
+++ b/swh/storage/postgresql/converters.py
@@ -238,9 +238,9 @@
return Revision(
id=db_revision["id"],
- author=author, # type: ignore # will pass in swh-model v5.1.0
+ author=author,
date=date,
- committer=committer, # type: ignore # will pass in swh-model v5.1.0
+ committer=committer,
committer_date=committer_date,
type=RevisionType(db_revision["type"]),
directory=db_revision["directory"],
diff --git a/swh/storage/proxies/buffer.py b/swh/storage/proxies/buffer.py
--- a/swh/storage/proxies/buffer.py
+++ b/swh/storage/proxies/buffer.py
@@ -65,8 +65,10 @@
if revision.message:
s += len(revision.message)
- s += len(revision.author.fullname)
- s += len(revision.committer.fullname)
+ if revision.author is not None:
+ s += len(revision.author.fullname)
+ if revision.committer is not None:
+ s += len(revision.committer.fullname)
s += sum(len(h) + len(v) for h, v in revision.extra_headers)
return s
diff --git a/swh/storage/tests/storage_tests.py b/swh/storage/tests/storage_tests.py
--- a/swh/storage/tests/storage_tests.py
+++ b/swh/storage/tests/storage_tests.py
@@ -4,7 +4,6 @@
# See top-level LICENSE file for more information
from collections import defaultdict
-import contextlib
import datetime
from datetime import timedelta
import inspect
@@ -56,16 +55,6 @@
)
-@contextlib.contextmanager
-def disable_attrs_validator():
- v = attr.validators.get_disabled()
- try:
- attr.validators.set_disabled(True)
- yield
- finally:
- attr.validators.set_disabled(v)
-
-
def transform_entries(
storage: StorageInterface, dir_: Directory, *, prefix: bytes = b""
) -> Iterator[Dict[str, Any]]:
@@ -1161,8 +1150,12 @@
revision,
synthetic=False,
metadata=None,
- committer=Person.from_fullname(revision.committer.fullname),
- author=Person.from_fullname(revision.author.fullname),
+ author=None
+ if revision.author is None
+ else Person.from_fullname(revision.author.fullname),
+ committer=None
+ if revision.committer is None
+ else Person.from_fullname(revision.committer.fullname),
type=RevisionType.GIT,
)
for revision in revisions
@@ -1322,12 +1315,9 @@
def test_revision_add_no_author_or_date(self, swh_storage, sample_data):
full_revision = sample_data.revision
- with disable_attrs_validator():
- # TODO: remove context manager when support for author=None
- # lands in swh-model
- revision = attr.evolve(full_revision, author=None, date=None)
- revision = attr.evolve(revision, id=revision.compute_hash())
- actual_result = swh_storage.revision_add([revision])
+ revision = attr.evolve(full_revision, author=None, date=None)
+ revision = attr.evolve(revision, id=revision.compute_hash())
+ actual_result = swh_storage.revision_add([revision])
assert actual_result == {"revision:add": 1}
end_missing = swh_storage.revision_missing([revision.id])
@@ -1337,20 +1327,14 @@
("revision", revision)
]
- with disable_attrs_validator():
- # TODO: remove context manager when support for author=None
- # lands in swh-model
- assert swh_storage.revision_get([revision.id]) == [revision]
+ assert swh_storage.revision_get([revision.id]) == [revision]
def test_revision_add_no_committer_or_date(self, swh_storage, sample_data):
full_revision = sample_data.revision
- with disable_attrs_validator():
- # TODO: remove context manager when support for author=None
- # lands in swh-model
- revision = attr.evolve(full_revision, committer=None, committer_date=None)
- revision = attr.evolve(revision, id=revision.compute_hash())
- actual_result = swh_storage.revision_add([revision])
+ revision = attr.evolve(full_revision, committer=None, committer_date=None)
+ revision = attr.evolve(revision, id=revision.compute_hash())
+ actual_result = swh_storage.revision_add([revision])
assert actual_result == {"revision:add": 1}
end_missing = swh_storage.revision_missing([revision.id])
@@ -1360,10 +1344,7 @@
("revision", revision)
]
- with disable_attrs_validator():
- # TODO: remove context manager when support for author=None
- # lands in swh-model
- assert swh_storage.revision_get([revision.id]) == [revision]
+ assert swh_storage.revision_get([revision.id]) == [revision]
def test_extid_add_git(self, swh_storage, sample_data):

File Metadata

Mime Type
text/plain
Expires
Jul 3 2025, 6:14 PM (4 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3220019

Event Timeline