cmdserver: wrap 'pipe' mode server by service object
authorYuya Nishihara <yuya@tcha.org>
Sat, 27 Sep 2014 14:52:09 +0900
changeset 22988 32b77aba2772
parent 22987 e6d890e1ed4f
child 22989 dc8803ce3dfe
cmdserver: wrap 'pipe' mode server by service object This is the stub for new mode that will listen for connections on unix domain socket. Though --daemon option is not banned in 'pipe' mode, it is useless because the detached 'pipe' mode server exits immediately due to null stdin. Should it abort if --daemon is specified with --cmdserver pipe or --stdio?
mercurial/commands.py
mercurial/commandserver.py
--- a/mercurial/commands.py	Thu Oct 16 14:55:45 2014 -0400
+++ b/mercurial/commands.py	Sat Sep 27 14:52:09 2014 +0900
@@ -5536,8 +5536,8 @@
         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'):
--- a/mercurial/commandserver.py	Thu Oct 16 14:55:45 2014 -0400
+++ b/mercurial/commandserver.py	Sat Sep 27 14:52:09 2014 +0900
@@ -248,3 +248,13 @@
             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()