[PATCH 5 of 8 chgtocore] server: add public function to select either cmdserver or hgweb
Yuya Nishihara
yuya at tcha.org
Tue Nov 22 10:59:58 EST 2016
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1476508756 -32400
# Sat Oct 15 14:19:16 2016 +0900
# Node ID ac7e304b598a4f05e96605602679ea868b4fe38d
# Parent 03857e7317d72b4d57ecb54894dda31e6124931a
server: add public function to select either cmdserver or hgweb
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6447,10 +6447,7 @@ def serve(ui, repo, **opts):
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',
diff --git a/mercurial/server.py b/mercurial/server.py
--- a/mercurial/server.py
+++ b/mercurial/server.py
@@ -113,14 +113,14 @@ def runservice(opts, parentfn=None, init
'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 @@ def createhgwebservice(ui, repo, opts):
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)
More information about the Mercurial-devel
mailing list