116 mode = opts['cmdserver'] |
117 mode = opts['cmdserver'] |
117 try: |
118 try: |
118 return _cmdservicemap[mode](ui, repo, opts) |
119 return _cmdservicemap[mode](ui, repo, opts) |
119 except KeyError: |
120 except KeyError: |
120 raise error.Abort(_('unknown mode %s') % mode) |
121 raise error.Abort(_('unknown mode %s') % mode) |
|
122 |
|
123 def createhgwebservice(ui, repo, opts): |
|
124 # this way we can check if something was given in the command-line |
|
125 if opts.get('port'): |
|
126 opts['port'] = util.getport(opts.get('port')) |
|
127 |
|
128 alluis = set([ui]) |
|
129 if repo: |
|
130 baseui = repo.baseui |
|
131 alluis.update([repo.baseui, repo.ui]) |
|
132 else: |
|
133 baseui = ui |
|
134 webconf = opts.get('web_conf') or opts.get('webdir_conf') |
|
135 if webconf: |
|
136 # load server settings (e.g. web.port) to "copied" ui, which allows |
|
137 # hgwebdir to reload webconf cleanly |
|
138 servui = ui.copy() |
|
139 servui.readconfig(webconf, sections=['web']) |
|
140 alluis.add(servui) |
|
141 else: |
|
142 servui = ui |
|
143 |
|
144 optlist = ("name templates style address port prefix ipv6" |
|
145 " accesslog errorlog certificate encoding") |
|
146 for o in optlist.split(): |
|
147 val = opts.get(o, '') |
|
148 if val in (None, ''): # should check against default options instead |
|
149 continue |
|
150 for u in alluis: |
|
151 u.setconfig("web", o, val, 'serve') |
|
152 |
|
153 app = hgweb.createapp(baseui, repo, webconf) |
|
154 return hgweb.httpservice(servui, app, opts) |