changeset 30508:9195bc4cb816

hgweb: extract app factory I'll move createservice() to the server module, but createapp() seems good to remain in the hgweb module because of its dependency on hgweb/hgwebdir_mod.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 15 Oct 2016 14:06:46 +0900
parents dd539e2d89aa
children add7bcad1d9c
files mercurial/hgweb/__init__.py
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/__init__.py	Sat Oct 15 13:57:17 2016 +0900
+++ b/mercurial/hgweb/__init__.py	Sat Oct 15 14:06:46 2016 +0900
@@ -115,11 +115,14 @@
         for u in alluis:
             u.setconfig("web", o, val, 'serve')
 
+    app = createapp(baseui, repo, webconf)
+    return httpservice(servui, app, opts)
+
+def createapp(baseui, repo, webconf):
     if webconf:
-        app = hgwebdir_mod.hgwebdir(webconf, baseui=baseui)
+        return hgwebdir_mod.hgwebdir(webconf, baseui=baseui)
     else:
         if not repo:
             raise error.RepoError(_("there is no Mercurial repository"
                                     " here (.hg not found)"))
-        app = hgweb_mod.hgweb(repo, baseui=baseui)
-    return httpservice(servui, app, opts)
+        return hgweb_mod.hgweb(repo, baseui=baseui)