Patchwork [3,of,8,chgtocore] hgweb: extract app factory

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 22, 2016, 3:59 p.m.
Message ID <bb4b6d8aeea5e7f9ce62.1479830396@mimosa>
Download mbox | patch
Permalink /patch/17702/
State Accepted
Headers show

Comments

Yuya Nishihara - Nov. 22, 2016, 3:59 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1476508006 -32400
#      Sat Oct 15 14:06:46 2016 +0900
# Node ID bb4b6d8aeea5e7f9ce62b15679285040016f7bb1
# Parent  aca8c3cfc3a5924dd99945baae3cb784c3c79c99
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.

Patch

diff --git a/mercurial/hgweb/__init__.py b/mercurial/hgweb/__init__.py
--- a/mercurial/hgweb/__init__.py
+++ b/mercurial/hgweb/__init__.py
@@ -115,11 +115,14 @@  def createservice(ui, repo, opts):
         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)