comparison mercurial/commands.py @ 27139:d73f23344dc7

hgweb: extract factory function of httpservice object The next patch will merge the cmdutil.service() calls of both commandserver and hgweb. Before doing it, this patch wipes out the code specific to hgweb from commands.serve().
author Yuya Nishihara <yuya@tcha.org>
date Sat, 31 Oct 2015 22:15:16 +0900
parents ea8e27e6098d
children dfdac09b57dd
comparison
equal deleted inserted replaced
27138:ea8e27e6098d 27139:d73f23344dc7
5972 if opts["cmdserver"]: 5972 if opts["cmdserver"]:
5973 import commandserver 5973 import commandserver
5974 service = commandserver.createservice(ui, repo, opts) 5974 service = commandserver.createservice(ui, repo, opts)
5975 return cmdutil.service(opts, initfn=service.init, runfn=service.run) 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 5977 service = hgweb.createservice(ui, repo, opts)
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)
6004 cmdutil.service(opts, initfn=service.init, runfn=service.run) 5978 cmdutil.service(opts, initfn=service.init, runfn=service.run)
6005 5979
6006 @command('^status|st', 5980 @command('^status|st',
6007 [('A', 'all', None, _('show status of all files')), 5981 [('A', 'all', None, _('show status of all files')),
6008 ('m', 'modified', None, _('show only modified files')), 5982 ('m', 'modified', None, _('show only modified files')),