This is an archive of the discontinued Mercurial Phabricator instance.

wireproto: port heads command to wire protocol v2
ClosedPublic

Authored by indygreg on Apr 7 2018, 1:53 AM.

Details

Summary

After much thought and consideration, wire protocol version 2's
commands will be defined in different functions from the existing
commands. This will make it easier to implement these commands
because it won't require shoehorning things like response formatting
and argument declaration into the same APIs.

For example, wire protocol version 1 requires that commands declare
a fixed and ordered list of argument names. It isn't really possible
to insert new arguments or have optional arguments without
breaking backwards compatibility. Wire protocol version 2, however,
uses CBOR maps for passing arguments. So arguments a) can be
optional b) can be added without BC c) can be strongly typed.

This commit starts our trek towards reimplementing the wire protocol
for version 2 with the heads command. It is pretty similar to the
existing heads command. One added feature is it can be told to
operate on only public phase changesets. This is useful for
making discovery faster when a repo has tens of thousands of
draft phase heads (such as Mozilla's "try" repository).

The HTTPv2 server-side protocol has had its getargs() implementation
updated to reflect that arguments are a map and not a list.

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.Apr 7 2018, 1:53 AM
yuja accepted this revision.Apr 9 2018, 10:58 AM
This revision is now accepted and ready to land.Apr 9 2018, 10:58 AM
yuja added inline comments.Apr 9 2018, 11:07 AM
mercurial/wireproto.py
526

My two cents. I think it's better to pass args dict without expansion.
**args means we can't use repo and proto as parameter names.

1209

Maybe we'll need a separate v2 command module?

This revision was automatically updated to reflect the committed changes.
indygreg added inline comments.Apr 9 2018, 2:00 PM
mercurial/wireproto.py
526

I agree about not using `**args. It is there mostly for compatibility with existing command handlers. Once we have a distinct set of handlers, we can ditch **args`.

1209

I also think it makes sense to separate things into separate modules. However, there are a number of cycles involved. I'll try to do this. Not sure if I'll make it before 4.6 freeze though.