diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -5536,8 +5536,8 @@ def serve(ui, repo, **opts): s.serve_forever() if opts["cmdserver"]: - s = commandserver.server(ui, repo, opts["cmdserver"]) - return s.serve() + service = commandserver.pipeservice(ui, repo, opts) + return cmdutil.service(opts, initfn=service.init, runfn=service.run) # this way we can check if something was given in the command-line if opts.get('port'): diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py --- a/mercurial/commandserver.py +++ b/mercurial/commandserver.py @@ -248,3 +248,13 @@ class server(object): return 1 return 0 + +class pipeservice(object): + def __init__(self, ui, repo, opts): + self.server = server(ui, repo, opts['cmdserver']) + + def init(self): + pass + + def run(self): + return self.server.serve()