Skip to content
Snippets Groups Projects
Commit 5063082e authored by vlorentz's avatar vlorentz
Browse files

Revert "deposit: Remove 'parent' deposit"

This reverts commit f6905cdf.

That commit was a first step toward making loaders write releases
instead of revisions.

Unfortunately, we will still write revisions for a non-negligeable time,
so I prefer to defer the removal of parent deposit revisions to the
moment we actually make that switch, so we don't end up with inconsistent
revisions.
parent 9f882793
No related branches found
No related tags found
1 merge request!230Revert "deposit: Remove 'parent' deposit"
......@@ -57,6 +57,9 @@ class DepositPackageInfo(BasePackageInfo):
"""The collection in the deposit; see SWORD specification."""
author = attr.ib(type=Person)
committer = attr.ib(type=Person)
revision_parents = attr.ib(type=Tuple[Sha1Git, ...])
"""Revisions created from previous deposits, that will be used as parents of the
revision created for this deposit."""
@classmethod
def from_metadata(
......@@ -87,6 +90,7 @@ class DepositPackageInfo(BasePackageInfo):
collection=depo["collection"],
author=parse_author(depo["author"]),
committer=parse_author(depo["committer"]),
revision_parents=tuple(hash_to_bytes(p) for p in depo["revision_parents"]),
raw_info=raw_info,
directory_extrinsic_metadata=[
RawExtrinsicMetadataCore(
......@@ -202,6 +206,7 @@ class DepositLoader(PackageLoader[DepositPackageInfo]):
date=TimestampWithTimezone.from_dict(p_info.author_date),
committer=p_info.committer,
committer_date=TimestampWithTimezone.from_dict(p_info.commit_date),
parents=p_info.revision_parents,
directory=directory,
synthetic=True,
)
......
......@@ -19,15 +19,10 @@ from swh.model.model import (
MetadataAuthorityType,
MetadataFetcher,
Origin,
Person,
RawExtrinsicMetadata,
Revision,
RevisionType,
Snapshot,
SnapshotBranch,
TargetType,
Timestamp,
TimestampWithTimezone,
)
from swh.model.swhids import CoreSWHID, ExtendedObjectType, ExtendedSWHID, ObjectType
......@@ -205,30 +200,7 @@ def test_deposit_loading_ok(swh_storage, deposit_client, requests_mock_datadir):
check_snapshot(expected_snapshot, storage=loader.storage)
revision = loader.storage.revision_get([revision_id])[0]
date = TimestampWithTimezone(
timestamp=Timestamp(seconds=1507389428, microseconds=0),
offset=0,
negative_utc=False,
)
person = Person(
fullname=b"Software Heritage",
name=b"Software Heritage",
email=b"robot@softwareheritage.org",
)
assert revision == Revision(
id=revision_id,
message=b"hal: Deposit 666 in collection hal",
author=person,
committer=person,
date=date,
committer_date=date,
type=RevisionType.TAR,
directory=b"\xfd-\xf1-\xc5SL\x1d\xa1\xe9\x18\x0b\x91Q\x02\xfbo`\x1d\x19",
synthetic=True,
metadata=None,
parents=(),
extra_headers=(),
)
assert revision is not None
# check metadata
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment