# HG changeset patch # User Matt Mackall # Date 2010-04-26 16:03:40 # Node ID f6d41bfc189e4fea467c2a3612790d10cda33af9 # Parent 5efbfa662b3c6c5ec2c75a46d15071c560ec6d7a hgweb: make hgweb.hgweb a unified interface to hgweb/hgwebdir diff --git a/mercurial/hgweb/__init__.py b/mercurial/hgweb/__init__.py --- a/mercurial/hgweb/__init__.py +++ b/mercurial/hgweb/__init__.py @@ -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)