##// END OF EJS Templates
hgweb: extract factory function of httpservice object...
Yuya Nishihara -
r27139:d73f2334 default
parent child Browse files
Show More
@@ -5974,33 +5974,7 b' def serve(ui, repo, **opts):'
5974 5974 service = commandserver.createservice(ui, repo, opts)
5975 5975 return cmdutil.service(opts, initfn=service.init, runfn=service.run)
5976 5976
5977 # this way we can check if something was given in the command-line
5978 if opts.get('port'):
5979 opts['port'] = util.getport(opts.get('port'))
5980
5981 if repo:
5982 baseui = repo.baseui
5983 else:
5984 baseui = ui
5985 optlist = ("name templates style address port prefix ipv6"
5986 " accesslog errorlog certificate encoding")
5987 for o in optlist.split():
5988 val = opts.get(o, '')
5989 if val in (None, ''): # should check against default options instead
5990 continue
5991 baseui.setconfig("web", o, val, 'serve')
5992 if repo and repo.ui != baseui:
5993 repo.ui.setconfig("web", o, val, 'serve')
5994
5995 o = opts.get('web_conf') or opts.get('webdir_conf')
5996 if not o:
5997 if not repo:
5998 raise error.RepoError(_("there is no Mercurial repository"
5999 " here (.hg not found)"))
6000 o = repo
6001
6002 app = hgweb.hgweb(o, baseui=baseui)
6003 service = hgweb.httpservice(ui, app, opts)
5977 service = hgweb.createservice(ui, repo, opts)
6004 5978 cmdutil.service(opts, initfn=service.init, runfn=service.run)
6005 5979
6006 5980 @command('^status|st',
@@ -13,6 +13,7 b' import os'
13 13 from ..i18n import _
14 14
15 15 from .. import (
16 error,
16 17 util,
17 18 )
18 19
@@ -83,3 +84,32 b' class httpservice(object):'
83 84
84 85 def run(self):
85 86 self.httpd.serve_forever()
87
88 def createservice(ui, repo, opts):
89 # this way we can check if something was given in the command-line
90 if opts.get('port'):
91 opts['port'] = util.getport(opts.get('port'))
92
93 if repo:
94 baseui = repo.baseui
95 else:
96 baseui = ui
97 optlist = ("name templates style address port prefix ipv6"
98 " accesslog errorlog certificate encoding")
99 for o in optlist.split():
100 val = opts.get(o, '')
101 if val in (None, ''): # should check against default options instead
102 continue
103 baseui.setconfig("web", o, val, 'serve')
104 if repo and repo.ui != baseui:
105 repo.ui.setconfig("web", o, val, 'serve')
106
107 o = opts.get('web_conf') or opts.get('webdir_conf')
108 if not o:
109 if not repo:
110 raise error.RepoError(_("there is no Mercurial repository"
111 " here (.hg not found)"))
112 o = repo
113
114 app = hgweb(o, baseui=baseui)
115 return httpservice(ui, app, opts)
General Comments 0
You need to be logged in to leave comments. Login now