server: abstract setup of ipv6 vs. normal server
authorDirkjan Ochtman <djc.ochtman@kentyde.com>
Thu, 11 Mar 2010 13:31:37 +0100
changeset 10641 dedf88fe945a
parent 10640 90a095c24bc4
child 10642 812b85d02c92
server: abstract setup of ipv6 vs. normal server
mercurial/hgweb/server.py
--- a/mercurial/hgweb/server.py	Thu Mar 11 13:30:52 2010 +0100
+++ b/mercurial/hgweb/server.py	Thu Mar 11 13:31:37 2010 +0100
@@ -218,7 +218,6 @@
         myui = repo.ui
     address = myui.config("web", "address", "")
     port = int(myui.config("web", "port", 8000))
-    use_ipv6 = myui.configbool("web", "ipv6")
     webdir_conf = myui.config("web", "webdir_conf")
 
     if webdir_conf:
@@ -280,14 +279,16 @@
     else:
         handler = _hgwebhandler
 
+    if myui.configbool('web', 'ipv6'):
+        cls = IPv6HTTPServer
+    else:
+        cls = MercurialHTTPServer
+
     # ugly hack due to python issue5853 (for threaded use)
     import mimetypes; mimetypes.init()
 
     try:
-        if use_ipv6:
-            return IPv6HTTPServer(myui, (address, port), handler)
-        else:
-            return MercurialHTTPServer(myui, (address, port), handler)
+        return cls(myui, (address, port), handler)
     except socket.error, inst:
         raise util.Abort(_("cannot start server at '%s:%d': %s")
                          % (address, port, inst.args[1]))