( )⚙ D4480 exchangev2: start to implement pull with wire protocol v2

This is an archive of the discontinued Mercurial Phabricator instance.

exchangev2: start to implement pull with wire protocol v2
ClosedPublic

Authored by indygreg on Sep 5 2018, 12:20 PM.

Details

Summary

Wire protocol version 2 will take a substantially different
approach to exchange than version 1 (at least as far as pulling
is concerned).

This commit establishes a new exchangev2 module for holding
code related to exchange using wire protocol v2. I could have
added things to the existing exchange module. But it is already
quite big. And doing things inline isn't in question because
the existing code is already littered with conditional code
for various states of support for the existing wire protocol
as it evolved over 10+ years. A new module gives us a chance
to make a clean break.

This approach does mean we'll end up writing some duplicate
code. And there's a significant chance we'll miss functionality
as code is ported. The plan is to eventually add #testcase's
to existing tests so the new wire protocol is tested side-by-side
with the existing one. This will hopefully tease out any
features that weren't ported properly. But before we get there,
we need to build up support for the new exchange methods.

Our journey towards implementing a new exchange begins with pulling.
And pulling begins with discovery.

The discovery code added to exchangev2 is heavily drawn from
the following functions:

  • exchange._pulldiscoverychangegroup
  • discovery.findcommonincoming

For now, we build on top of existing discovery mechanisms. The
new wire protocol should be capable of doing things more efficiently.
But I'd rather defer on this problem.

To foster the transition, we invent a fake capability on the HTTPv2
peer and have the main pull code in exchange.py call into exchangev2
when the new wire protocol is being used.

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

indygreg created this revision.Sep 5 2018, 12:20 PM
durin42 added inline comments.
mercurial/exchange.py
1512

What's the deal with this function-level import? It doesn't appear to be avoiding a cycle...

indygreg planned changes to this revision.Sep 12 2018, 12:56 PM
indygreg added inline comments.
mercurial/exchange.py
1512

At one time the series introduced a cycle. But the current series doesn't do that. So I suppose this can be rewritten to a file-level import for now.

indygreg updated this revision to Diff 10961.Sep 12 2018, 1:11 PM
This revision was automatically updated to reflect the committed changes.