Patchwork [1,of,3] hgweb: eliminate duck-typing to select hgweb or hgwebdir by command option

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 2, 2015, 1:20 p.m.
Message ID <59dc6fb040b82000ee64.1449062455@mimosa>
Download mbox | patch
Permalink /patch/11742/
State Accepted
Headers show

Comments

Yuya Nishihara - Dec. 2, 2015, 1:20 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1446298010 -32400
#      Sat Oct 31 22:26:50 2015 +0900
# Node ID 59dc6fb040b82000ee643cad376a46b93b68c6fe
# Parent  41c9019a6c94c7184d2469c664881eeb88707e9e
hgweb: eliminate duck-typing to select hgweb or hgwebdir by command option

Since createservice() was moved to hgweb and hgweb imports both hgweb_mod and
hgwebdir_mod, we no longer have to force hgweb() function to select one of
them by the type of 'o' variable. Let's be explicit!

This patch does not change hgweb() function because it is the interface of
existing WSGI and CGI scripts.

Patch

diff --git a/mercurial/hgweb/__init__.py b/mercurial/hgweb/__init__.py
--- a/mercurial/hgweb/__init__.py
+++ b/mercurial/hgweb/__init__.py
@@ -104,12 +104,12 @@  def createservice(ui, repo, opts):
         if repo and repo.ui != baseui:
             repo.ui.setconfig("web", o, val, 'serve')
 
-    o = opts.get('web_conf') or opts.get('webdir_conf')
-    if not o:
+    webconf = opts.get('web_conf') or opts.get('webdir_conf')
+    if webconf:
+        app = hgwebdir_mod.hgwebdir(webconf, baseui=baseui)
+    else:
         if not repo:
             raise error.RepoError(_("there is no Mercurial repository"
                                     " here (.hg not found)"))
-        o = repo
-
-    app = hgweb(o, baseui=baseui)
+        app = hgweb_mod.hgweb(repo, baseui=baseui)
     return httpservice(ui, app, opts)