hgweb: eliminate duck-typing to select hgweb or hgwebdir by command option
authorYuya Nishihara <yuya@tcha.org>
Sat, 31 Oct 2015 22:26:50 +0900
changeset 27181 a9cecc7b68d3
parent 27180 8e7db961535a
child 27182 71aa5a26162d
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.
mercurial/hgweb/__init__.py
--- a/mercurial/hgweb/__init__.py	Tue Dec 01 16:06:20 2015 -0800
+++ b/mercurial/hgweb/__init__.py	Sat Oct 31 22:26:50 2015 +0900
@@ -104,12 +104,12 @@
         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)