( )⚙ D4803 storageutil: extract most of emitrevisions() to standalone function

This is an archive of the discontinued Mercurial Phabricator instance.

storageutil: extract most of emitrevisions() to standalone function
ClosedPublic

Authored by indygreg on Sep 28 2018, 8:18 PM.

Details

Summary

As part of implementing a storage backend, I found myself copying
most of revlog.emitrevisions(). This code is highly nuanced and it
bothered me greatly to be copying such low-level code.

This commit extracts the bulk of revlog.emitrevisions() into a
new standalone function. In order to make the function generally
usable, all "self" function calls that aren't exposed on the
ifilestorage interface are passed in via callable arguments.

No meaningful behavior should have changed as part of the port.

Upcoming commits will tweak behavior to make the code more
generically usable.

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

indygreg created this revision.Sep 28 2018, 8:18 PM
durin42 requested changes to this revision.Oct 3 2018, 10:47 AM
durin42 added a subscriber: durin42.
durin42 added inline comments.
mercurial/utils/storageutil.py
266

This is a huge step backwards for remotefilelog and friends: it's all defined in terms of revs, whereas emitrevisions (as copypasta-inducing as it was) was in terms of nodes. We need to do better.

This revision now requires changes to proceed.Oct 3 2018, 10:47 AM

Oh, I just got to D4805. I think the helper is still of somewhat limited utility and truly novel storage engines will end up totally reimplementing emitrevisions, but that's fine.

This revision was automatically updated to reflect the committed changes.

FWIW I would like to rewrite all of filelog (and this API) to be in terms of nodes. My hands are somewhat tied with this function due to how all the functions are implemented in terms of revs today. We'll get there eventually...