comparison mercurial/server.py @ 30510:a0878bc87379

server: add public function to select either cmdserver or hgweb
author Yuya Nishihara <yuya@tcha.org>
date Sat, 15 Oct 2016 14:19:16 +0900
parents add7bcad1d9c
children ff7df4bb75de
comparison
equal deleted inserted replaced
30509:add7bcad1d9c 30510:a0878bc87379
111 _cmdservicemap = { 111 _cmdservicemap = {
112 'pipe': commandserver.pipeservice, 112 'pipe': commandserver.pipeservice,
113 'unix': commandserver.unixforkingservice, 113 'unix': commandserver.unixforkingservice,
114 } 114 }
115 115
116 def createcmdservice(ui, repo, opts): 116 def _createcmdservice(ui, repo, opts):
117 mode = opts['cmdserver'] 117 mode = opts['cmdserver']
118 try: 118 try:
119 return _cmdservicemap[mode](ui, repo, opts) 119 return _cmdservicemap[mode](ui, repo, opts)
120 except KeyError: 120 except KeyError:
121 raise error.Abort(_('unknown mode %s') % mode) 121 raise error.Abort(_('unknown mode %s') % mode)
122 122
123 def createhgwebservice(ui, repo, opts): 123 def _createhgwebservice(ui, repo, opts):
124 # this way we can check if something was given in the command-line 124 # this way we can check if something was given in the command-line
125 if opts.get('port'): 125 if opts.get('port'):
126 opts['port'] = util.getport(opts.get('port')) 126 opts['port'] = util.getport(opts.get('port'))
127 127
128 alluis = set([ui]) 128 alluis = set([ui])
150 for u in alluis: 150 for u in alluis:
151 u.setconfig("web", o, val, 'serve') 151 u.setconfig("web", o, val, 'serve')
152 152
153 app = hgweb.createapp(baseui, repo, webconf) 153 app = hgweb.createapp(baseui, repo, webconf)
154 return hgweb.httpservice(servui, app, opts) 154 return hgweb.httpservice(servui, app, opts)
155
156 def createservice(ui, repo, opts):
157 if opts["cmdserver"]:
158 return _createcmdservice(ui, repo, opts)
159 else:
160 return _createhgwebservice(ui, repo, opts)