diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py --- a/mercurial/debugcommands.py +++ b/mercurial/debugcommands.py @@ -2584,6 +2584,21 @@ Behaves like ``raw`` except flushes output afterwards. + command + ----------- + + Send a request to run a named command, whose name follows the ``command`` + string. + + Arguments to the command are defined as lines in this block. The format of + each line is `` ``. e.g.:: + + command listkeys + namespace bookmarks + + Values are interpreted as Python b'' literals. This allows encoding + special byte sequences via backslash escaping. + close ----- @@ -2683,6 +2698,24 @@ stdin.flush() elif action == 'flush': stdin.flush() + elif action.startswith('command'): + if not peer: + raise error.Abort(_('cannot send commands unless peer instance ' + 'is available')) + + command = action.split(' ', 1)[1] + + args = {} + for line in lines: + fields = line.lstrip().split() + if len(fields) == 2: + key, value = fields + args[key] = ast.literal_eval(b'b"%s"' % value) + else: + raise error.Abort(_('value-less arguments not supported')) + + peer._call(command, **args) + elif action == 'close': peer.close() elif action == 'readavailable':