changeset 10996:f6d41bfc189e

hgweb: make hgweb.hgweb a unified interface to hgweb/hgwebdir
author Matt Mackall <mpm@selenic.com>
date Mon, 26 Apr 2010 11:03:40 -0500
parents 5efbfa662b3c
children b3a1f535ce4f
files mercurial/hgweb/__init__.py
diffstat 1 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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)