server: externalize application creation
authorDirkjan Ochtman <djc.ochtman@kentyde.com>
Thu, 11 Mar 2010 11:21:48 +0100
changeset 10638 92209ae8610a
parent 10636 23ab3b05bd66
child 10639 a6808629f450
server: externalize application creation
mercurial/hgweb/server.py
--- a/mercurial/hgweb/server.py	Tue Mar 09 21:53:16 2010 -0500
+++ b/mercurial/hgweb/server.py	Thu Mar 11 11:21:48 2010 +0100
@@ -233,6 +233,14 @@
             class _mixin:
                 pass
 
+    if webdir_conf:
+        hgwebobj = hgwebdir(webdir_conf, ui)
+    elif repo is not None:
+        hgwebobj = hgweb(hg.repository(repo.ui, repo.root))
+    else:
+        raise error.RepoError(_("There is no Mercurial repository"
+                                " here (.hg not found)"))
+
     class MercurialHTTPServer(object, _mixin, BaseHTTPServer.HTTPServer):
 
         # SO_REUSEADDR has broken semantics on windows
@@ -244,16 +252,7 @@
             self.accesslog = accesslog
             self.errorlog = errorlog
             self.daemon_threads = True
-            def make_handler():
-                if webdir_conf:
-                    hgwebobj = hgwebdir(webdir_conf, ui)
-                elif repo is not None:
-                    hgwebobj = hgweb(hg.repository(repo.ui, repo.root))
-                else:
-                    raise error.RepoError(_("There is no Mercurial repository"
-                                            " here (.hg not found)"))
-                return hgwebobj
-            self.application = make_handler()
+            self.application = hgwebobj
 
             if ssl_cert:
                 try: