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
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
wireproto: remove unnecessary exception trapping
The `try..except error.Abort` was added in
8474be4412ca back in
2012. The intent was to ensure a failing pushkey hook didn't crash
the server.
Since that changeset, repo.pushkey() and the hooks mechanism is
now much more robust about trapping errors itself. As such, we no
longer need this try..except block. So it has been removed.
Differential Revision: https://phab.mercurial-scm.org/D1996