hgweb: make hgweb.hgweb a unified interface to hgweb/hgwebdir
authorMatt Mackall <mpm@selenic.com>
Mon, 26 Apr 2010 11:03:40 -0500
changeset 10996 f6d41bfc189e
parent 10995 5efbfa662b3c
child 10997 b3a1f535ce4f
hgweb: make hgweb.hgweb a unified interface to hgweb/hgwebdir
mercurial/hgweb/__init__.py
--- a/mercurial/hgweb/__init__.py	Mon Apr 26 11:03:40 2010 -0500
+++ b/mercurial/hgweb/__init__.py	Mon Apr 26 11:03:40 2010 -0500
@@ -6,10 +6,25 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
+import os
 import hgweb_mod, hgwebdir_mod
 
-def hgweb(repo, name=None, baseui=None):
-    return hgweb_mod.hgweb(repo, name=name, baseui=baseui)
+def hgweb(config, name=None, baseui=None):
+    '''create an hgweb wsgi object
+
+    config can be one of:
+    - repo object (single repo view)
+    - path to repo (single repo view)
+    - path to config file (multi-repo view)
+    - dict of virtual:real pairs (multi-repo view)
+    - list of virtual:real tuples (multi-repo view)
+    '''
+
+    if ((isinstance(config, str) and not os.path.isdir(config)) or
+        isinstance(config, dict) or isinstance(config, list)):
+        # create a multi-dir interface
+        return hgwebdir_mod.hgwebdir(config, baseui=baseui)
+    return hgweb_mod.hgweb(config, name=name, baseui=baseui)
 
 def hgwebdir(config, baseui=None):
     return hgwebdir_mod.hgwebdir(config, baseui=baseui)