view .arcconfig @ 35981:ef683a0fd21f

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
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 31 Jan 2018 14:05:11 -0800
parents b2c27d84f05c
children ff396501e841
line wrap: on
line source

{
    "conduit_uri": "https://phab.mercurial-scm.org/api",
    "repository.callsign": "HG",
    "arc.land.onto.default": "@",
    "base": "hg:.^"
}