Matt Harbison <matt_harbison@yahoo.com> [Wed, 07 Feb 2018 23:42:48 -0500] rev 35989
tests: stabilize ssh tests on Windows
This seems like a somewhat common type of failure (double vs single quote), so
I'm interested in ideas about how to avoid this. I doubt that we should
automatically fall back from single quote to double quote, like with '/' vs '\'.
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 01 Feb 2018 08:54:48 -0800] rev 35988
wireprotoserver: rename abstractserverproto and improve docstring
The docstring isn't completely accurate for the current state
of the world. But it does describe the direction future patches
will be taking things.
Differential Revision: https://phab.mercurial-scm.org/D2065
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 01 Feb 2018 16:11:54 -0800] rev 35987
wireprotoserver: document and improve the httplib workaround
This workaround dates all the way back to
a42d27bc809d in 2008.
The code is esoteric enough to warrant an inline explanation.
So I've added one.
At the time the code was written, the only wire protocol command
that accepted an HTTP request body was "unbundle." In the years
since, we've grown the ability to accept command arguments via
HTTP POST requests. So, the code has been changed to apply the
httplib workaround to all HTTP POST requests.
While staring at this code, I realized that the HTTP response
body in case of error is always the same. And, it appears to
mimic the behavior of a failed call to the "unbundle" command.
Since we can hit this code path on theoretically any protocol
request (since self.check_perm accepts custom auth checking
functions which may raise), I'm having a hard time believing
that clients react well to an "unbundle" response payload on
any wire protocol command. I wouldn't be surprised if our test
coverage for this feature only covers HTTP POST calls to
"unbundle." In other words, the experimental support for sending
arguments via HTTP POST request bodies may result in badness on
the client. Something to investigate another time perhaps...
Differential Revision: https://phab.mercurial-scm.org/D2064
Gregory Szorc <gregory.szorc@gmail.com> [Wed, 31 Jan 2018 17:34:45 -0800] rev 35986
wireprotoserver: move error response handling out of hgweb
The exception handler for ErrorResponse has more to do with the
wire protocol than the generic HTTP server. Move the code so it
lives alongside other wire protocol code.
Differential Revision: https://phab.mercurial-scm.org/D2021
Gregory Szorc <gregory.szorc@gmail.com> [Wed, 31 Jan 2018 16:43:46 -0800] rev 35985
hgweb: move call to protocol handler outside of try..except
The protocol handler doesn't raise ErrorResponse. So it doesn't
need to be in this `try..except ErrorResponse` block.
Differential Revision: https://phab.mercurial-scm.org/D2020
Gregory Szorc <gregory.szorc@gmail.com> [Wed, 31 Jan 2018 16:21:43 -0800] rev 35984
wireprotoserver: move protocol parsing and dispatch out of hgweb
Previously, hgweb_mod had code for detecting if the request
was for the wire protocol. It would then (eventually) call
wireprotoserver.callhttp() to dispatch the request handling.
Detection of wire protocol requests is not trivial. There's
currently a big gotcha in the handling of the "cmd" request
parameter, for example.
Furthermore, in the near future we will have a second HTTP
protocol handler. Its mechanism for calling commands will be
a bit different. And we don't want the low-level logic for
detecting protocol commands to live in hgweb.
We establish a new function in wireprotoserver for detecting
an HTTP protocol request and for giving the caller an easy-to-use
mechanism for dispatching requests to it.
Some wire protocol specific functionality still lives in hgweb.
This will be addressed in subsequent commits.
Differential Revision: https://phab.mercurial-scm.org/D2019
Gregory Szorc <gregory.szorc@gmail.com> [Thu, 01 Feb 2018 18:48:52 -0800] rev 35983
largefiles: register wire protocol commands with modern APIs
The wireproto.wireprotocommand decorator is the preferred mechanism for
registering wire protocol commands. In addition, wireproto.commands
is no longer a 2-tuple and use of that 2-tuple API should be considered
deprecated.
This commit ports largefiles to use wireproto.wireprotocommand()
and ports to the "commandentry" API.
As part of this, the definition of the "lheads" wire protocol
command is moved to the proper stanza.
We stop short of actually using wireprotocommand as a decorator
in order to minimize churn. We should ideally move wire protocol
commands to the registrar mechanism. But that's for another
changeset.
Differential Revision: https://phab.mercurial-scm.org/D2018
Gregory Szorc <gregory.szorc@gmail.com> [Tue, 30 Jan 2018 18:41:44 -0800] rev 35982
wireproto: function for testing if wire protocol command is available
Currently, we perform simple membership testing for whether a wire
command is available. In the future, not all wire protocol commands
will be available on all transports. For example, a legacy transport
may not support newer commands.
In preparation of this, teach the protocol handlers to call into a
function to determine if a wire protocol command is available. That
function currently does membership testing like before, so behavior
should be identical.
In the case of the HTTP server, behavior is a bit wonkier. "cmd" is
used by both the wire protocol and hgweb. We do want the protocol
handler to handle requests for all commands that look like wire
protocol commands, even if they aren't available. Otherwise, the
fallback to hgweb would only confuse automated clients and make it
easier for hgweb to accidentally implement a "cmd" that is identical
to wire protocol commands (since they aren't centrally registered).
Differential Revision: https://phab.mercurial-scm.org/D1999
Gregory Szorc <gregory.szorc@gmail.com> [Wed, 31 Jan 2018 14:05:11 -0800] rev 35981
wireproto: define and use types for wire protocol commands
Wire protocol commands have historically been declared as
2-tuples in wireproto.commands. There are some additional features I'd
like to implement that require going beyond 2-tuples. But because
the 2-tuple API (both destructuring assignment and direct assignment
into the dict) is used throughout the code base and in 3rd party
extensions, we can't do a trivial type change.
This commit creates a new "commandentry" type to represent declared
wire protocol commands. It implements __getitem__ and __iter__ so
it can quack like a 2-tuple. The @wireprotocommand decorator now
creates "commandentry" instances.
We also create a "commanddict" type to represent the dictionary of
declared wire protocol commands. It inherits from "dict" but provides
a custom __setitem__ to coerce passed 2-tuples to "commandentry"
instances. wireproto.commands is now an instance of this type.
Various callers in core rely on the new functionality. And tests
pass. So I'm reasonably confident things will "just work" in 3rd
party extensions as well.
Differential Revision: https://phab.mercurial-scm.org/D1998
Gregory Szorc <gregory.szorc@gmail.com> [Tue, 30 Jan 2018 15:21:59 -0800] rev 35980
wireproto: improve docstring for @wireprotocommand
I'm about to add more arguments and want them to be documented.
Plus, good documentation is nice to have.
Differential Revision: https://phab.mercurial-scm.org/D1997