diff --git a/swh/loader/package/deposit/loader.py b/swh/loader/package/deposit/loader.py --- a/swh/loader/package/deposit/loader.py +++ b/swh/loader/package/deposit/loader.py @@ -57,6 +57,9 @@ """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 @@ 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 @@ 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, ) diff --git a/swh/loader/package/deposit/tests/test_deposit.py b/swh/loader/package/deposit/tests/test_deposit.py --- a/swh/loader/package/deposit/tests/test_deposit.py +++ b/swh/loader/package/deposit/tests/test_deposit.py @@ -19,15 +19,10 @@ 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 @@ 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