server: add public function to select either cmdserver or hgweb
authorYuya Nishihara <yuya@tcha.org>
Sat, 15 Oct 2016 14:19:16 +0900
changeset 30510 a0878bc87379
parent 30509 add7bcad1d9c
child 30511 1873563e1ede
server: add public function to select either cmdserver or hgweb
mercurial/commands.py
mercurial/server.py
--- a/mercurial/commands.py	Sat Oct 15 14:09:36 2016 +0900
+++ b/mercurial/commands.py	Sat Oct 15 14:19:16 2016 +0900
@@ -6296,10 +6296,7 @@
         s = sshserver.sshserver(ui, repo)
         s.serve_forever()
 
-    if opts["cmdserver"]:
-        service = server.createcmdservice(ui, repo, opts)
-    else:
-        service = server.createhgwebservice(ui, repo, opts)
+    service = server.createservice(ui, repo, opts)
     return server.runservice(opts, initfn=service.init, runfn=service.run)
 
 @command('^status|st',
--- a/mercurial/server.py	Sat Oct 15 14:09:36 2016 +0900
+++ b/mercurial/server.py	Sat Oct 15 14:19:16 2016 +0900
@@ -113,14 +113,14 @@
     'unix': commandserver.unixforkingservice,
 }
 
-def createcmdservice(ui, repo, opts):
+def _createcmdservice(ui, repo, opts):
     mode = opts['cmdserver']
     try:
         return _cmdservicemap[mode](ui, repo, opts)
     except KeyError:
         raise error.Abort(_('unknown mode %s') % mode)
 
-def createhgwebservice(ui, repo, opts):
+def _createhgwebservice(ui, repo, opts):
     # this way we can check if something was given in the command-line
     if opts.get('port'):
         opts['port'] = util.getport(opts.get('port'))
@@ -152,3 +152,9 @@
 
     app = hgweb.createapp(baseui, repo, webconf)
     return hgweb.httpservice(servui, app, opts)
+
+def createservice(ui, repo, opts):
+    if opts["cmdserver"]:
+        return _createcmdservice(ui, repo, opts)
+    else:
+        return _createhgwebservice(ui, repo, opts)