Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/server.py @ 10641:dedf88fe945a
server: abstract setup of ipv6 vs. normal server
author | Dirkjan Ochtman <djc.ochtman@kentyde.com> |
---|---|
date | Thu, 11 Mar 2010 13:31:37 +0100 |
parents | 90a095c24bc4 |
children | 812b85d02c92 |
comparison
equal
deleted
inserted
replaced
10640:90a095c24bc4 | 10641:dedf88fe945a |
---|---|
216 myui = ui | 216 myui = ui |
217 else: | 217 else: |
218 myui = repo.ui | 218 myui = repo.ui |
219 address = myui.config("web", "address", "") | 219 address = myui.config("web", "address", "") |
220 port = int(myui.config("web", "port", 8000)) | 220 port = int(myui.config("web", "port", 8000)) |
221 use_ipv6 = myui.configbool("web", "ipv6") | |
222 webdir_conf = myui.config("web", "webdir_conf") | 221 webdir_conf = myui.config("web", "webdir_conf") |
223 | 222 |
224 if webdir_conf: | 223 if webdir_conf: |
225 hgwebobj = hgwebdir(webdir_conf, ui) | 224 hgwebobj = hgwebdir(webdir_conf, ui) |
226 elif repo is not None: | 225 elif repo is not None: |
278 if myui.config('web', 'certificate'): | 277 if myui.config('web', 'certificate'): |
279 handler = _shgwebhandler | 278 handler = _shgwebhandler |
280 else: | 279 else: |
281 handler = _hgwebhandler | 280 handler = _hgwebhandler |
282 | 281 |
282 if myui.configbool('web', 'ipv6'): | |
283 cls = IPv6HTTPServer | |
284 else: | |
285 cls = MercurialHTTPServer | |
286 | |
283 # ugly hack due to python issue5853 (for threaded use) | 287 # ugly hack due to python issue5853 (for threaded use) |
284 import mimetypes; mimetypes.init() | 288 import mimetypes; mimetypes.init() |
285 | 289 |
286 try: | 290 try: |
287 if use_ipv6: | 291 return cls(myui, (address, port), handler) |
288 return IPv6HTTPServer(myui, (address, port), handler) | |
289 else: | |
290 return MercurialHTTPServer(myui, (address, port), handler) | |
291 except socket.error, inst: | 292 except socket.error, inst: |
292 raise util.Abort(_("cannot start server at '%s:%d': %s") | 293 raise util.Abort(_("cannot start server at '%s:%d': %s") |
293 % (address, port, inst.args[1])) | 294 % (address, port, inst.args[1])) |