This is an archive of the discontinued Mercurial Phabricator instance.

bundle2: seek part back during iteration
ClosedPublic

Authored by durham on Aug 8 2017, 8:05 PM.

Details

Summary

Previously, iterparts would yield the part to users, then consume the part. This
changed the part after the user was given it and left it at the end, both of
which seem unexpected. Let's seek back to the beginning after we've consumed
it. I tried not seeking to the end at all, but that seems important for the
overall bundle2 consumption.

This is used in a future patch to let us move the bundlerepo
bundle2-changegroup-part to be handled entirely within the for loop, instead of
having to do a seek back to 0 after the entire loop finishes.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

durham created this revision.Aug 8 2017, 8:05 PM
indygreg accepted this revision.Aug 14 2017, 9:46 PM
indygreg added a subscriber: indygreg.

This change feels a bit brittle to me, as it is relying on low-level implementation details of how bundle2 part handling and underlying stream consumption works. But I know from trying to touch this code that we have test coverage of it courtesy of bundlerepo. So I think we'll be fine.

This revision is now accepted and ready to land.Aug 14 2017, 9:46 PM
martinvonz added inline comments.
mercurial/bundle2.py
834–835

Unrelated to this patch, but seems like we should define constants for "whence". I don't think seek(0, 2) is clear at all.

I agree it's brittle, but no more brittle than before, since we still had to seek back.

durham updated this revision to Diff 1216.Aug 23 2017, 3:35 PM
This revision was automatically updated to reflect the committed changes.