Page MenuHomeSoftware Heritage

Revisions walker: Add methods to query produced history state
ClosedPublic

Authored by anlambert on Apr 24 2019, 11:34 AM.

Details

Summary

Add methods is_history_truncated and missing_revisions to check if the produced
history got truncated or not.

Related T1677

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

anlambert created this revision.Apr 24 2019, 11:34 AM
vlorentz accepted this revision.Mon, May 6, 11:40 AM
vlorentz added a subscriber: vlorentz.
vlorentz added inline comments.
swh/storage/tests/algos/test_revisions_walker.py
293

Why did you replace the decorator with a with?

298–303
revs_lists_truncated = [None if hash_to_hex(rev['id']) == _rev_missing else rev
                        for rev in _revisions_list]
314–319
else:
    self.assertEqual(revs_walker.missing_revisions(), set())
This revision is now accepted and ready to land.Mon, May 6, 11:40 AM
anlambert added inline comments.Mon, May 6, 11:56 AM
swh/storage/tests/algos/test_revisions_walker.py
293

Because I wanted to use the new truncated_history argument as a keyword one in tests implementation for better readability.

298–303

list comprehension, ack

314–319

ack

vlorentz added inline comments.Mon, May 6, 1:15 PM
swh/storage/tests/algos/test_revisions_walker.py
293

Doesn't this work?

@patch('swh.storage.storage.Storage')
def check_revisions_ordering(self, rev_walker_type, expected_result, truncated_history, MockStorage):
anlambert added inline comments.Mon, May 6, 1:30 PM
swh/storage/tests/algos/test_revisions_walker.py
293

Nope, got this kind of error when proceeding like this:

swh/storage/tests/algos/test_revisions_walker.py:404: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

args = (<swh.storage.tests.algos.test_revisions_walker.RevisionsWalkerTest testMethod=test_revisions_walker_truncated_history...40c85c10ac0b6423b61554d', '9c5051397e5c2e0c258bb639c3dd34406584ca10'], <MagicMock name='Storage' id='139885825057680'>)
keywargs = {'truncated_history': True}, extra_args = [<MagicMock name='Storage' id='139885825057680'>], entered_patchers = [<unittest.mock._patch object at 0x7f39c1691278>]
exc_info = (<class 'TypeError'>, TypeError("check_revisions_ordering() got multiple values for argument 'truncated_history'",), <traceback object at 0x7f39b4e097c8>), patching = <unittest.mock._patch object at 0x7f39c1691278>
arg = <MagicMock name='Storage' id='139885825057680'>

    @wraps(func)
    def patched(*args, **keywargs):
        extra_args = []
        entered_patchers = []
    
        exc_info = tuple()
        try:
            for patching in patched.patchings:
                arg = patching.__enter__()
                entered_patchers.append(patching)
                if patching.attribute_name is not None:
                    keywargs.update(arg)
                elif patching.new is DEFAULT:
                    extra_args.append(arg)
    
            args += tuple(extra_args)
>           return func(*args, **keywargs)
E           TypeError: check_revisions_ordering() got multiple values for argument 'truncated_history'

/usr/lib/python3.5/unittest/mock.py:1159: TypeError
anlambert updated this revision to Diff 4692.Mon, May 6, 1:32 PM

Update:

  • address comments
  • update current year in copyright for modified files
This revision was automatically updated to reflect the committed changes.