Page MenuHomeSoftware Heritage

Make Storage.origin_get support a list of origins, like other Storage.*_get methods.
ClosedPublic

Authored by vlorentz on Wed, Feb 6, 4:45 PM.

Details

Summary

Backward compatibility is preserved.

Diff Detail

Repository
rDSTO Storage manager
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

vlorentz created this revision.Wed, Feb 6, 4:45 PM
vlorentz updated this revision to Diff 3416.Wed, Feb 6, 4:45 PM
  • Fix typo.
anlambert accepted this revision.Wed, Feb 6, 5:39 PM
anlambert added a subscriber: anlambert.

Apart a couple of nitpicks, looks good to me.

I think once this is landed, we should create a task to track the calls of origin_get using the old API in all swh modules and port them to the new one.
Once it is done, the return_single switches should be removed from the origin_get method implementation.

swh/storage/in_memory.py
780–781

The method description should be updated to inform that multiple origins can be passed as parameter now.

813–847

That else block could be removed by initializing return_single to False before the dict check

845

I think that test can be removed, None will be returned with or without it

swh/storage/storage.py
1083–1084

Method description needs update here too

1118

same remark as above: else block could be removed

1145

I know None is returned by default when return is not called but I think that expression is clearer

return results[0] if results[0]['id'] is not None else None
1244–1247

origin_id seems a better variable name here

swh/storage/tests/test_storage.py
1002

s/id/origin_id/

This revision is now accepted and ready to land.Wed, Feb 6, 5:39 PM
vlorentz updated this revision to Diff 3454.Thu, Feb 7, 3:38 PM
vlorentz marked 7 inline comments as done.
This revision was automatically updated to reflect the committed changes.
vlorentz added inline comments.Thu, Feb 7, 3:38 PM
swh/storage/in_memory.py
845

Indeed, that was from an earlier iteration of my code.