diff mercurial/server.py @ 30507:dd539e2d89aa

server: move service table and factory from commandserver This is necessary to solve future dependency cycle between commandserver.py and chgserver.py. 'cmd' prefix is added to table and function names to avoid conflicts with hgweb.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 15 Oct 2016 13:57:17 +0900
parents d9d8d78e6bc9
children add7bcad1d9c
line wrap: on
line diff
--- a/mercurial/server.py	Sat Oct 15 13:47:43 2016 +0900
+++ b/mercurial/server.py	Sat Oct 15 13:57:17 2016 +0900
@@ -15,6 +15,7 @@
 from .i18n import _
 
 from . import (
+    commandserver,
     error,
     util,
 )
@@ -105,3 +106,15 @@
 
     if runfn:
         return runfn()
+
+_cmdservicemap = {
+    'pipe': commandserver.pipeservice,
+    'unix': commandserver.unixforkingservice,
+}
+
+def createcmdservice(ui, repo, opts):
+    mode = opts['cmdserver']
+    try:
+        return _cmdservicemap[mode](ui, repo, opts)
+    except KeyError:
+        raise error.Abort(_('unknown mode %s') % mode)