# HG changeset patch # User Pierre-Yves David # Date 2014-03-28 21:30:11 # Node ID 7a634b34fc9114e8e1de7d726d32379f7262ef5b # Parent 167047ba3cfa311f520814a74431e0e746d0a4cd wireproto: add decorator for wire protocol command Move move in the same direction we took for command line commands. each wire protocol function will be decorated with its name and arguments. Beside beside easier to read, this open the road to easily adding more metadata (like security level or return type) diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py --- a/mercurial/wireproto.py +++ b/mercurial/wireproto.py @@ -471,6 +471,16 @@ def options(cmd, keys, others): % (cmd, ",".join(others))) return opts +# list of commands +commands = {} + +def wireprotocommand(name, args=''): + """decorator for wireprotocol command""" + def register(func): + commands[name] = (func, args) + return func + return register + def batch(repo, proto, cmds, others): repo = repo.filtered("served") res = [] @@ -770,7 +780,7 @@ def unbundle(repo, proto, heads): fp.close() os.unlink(tempname) -commands = { +commands.update({ 'batch': (batch, 'cmds *'), 'between': (between, 'pairs'), 'branchmap': (branchmap, ''), @@ -788,4 +798,4 @@ commands = { 'pushkey': (pushkey, 'namespace key old new'), 'stream_out': (stream, ''), 'unbundle': (unbundle, 'heads'), -} +})