Mercurial > public > mercurial-scm > hg-stable
diff mercurial/templater.py @ 9842:d3dbdca92458
hgweb: don't choke when an inexistent style is requested (issue1901)
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Thu, 12 Nov 2009 16:39:11 +0100 |
parents | 2484868cffde |
children | 9e2ab10728a2 25e572394f5c |
line wrap: on
line diff
--- a/mercurial/templater.py Thu Nov 12 10:29:40 2009 -0500 +++ b/mercurial/templater.py Thu Nov 12 16:39:11 2009 +0100 @@ -220,7 +220,7 @@ return normpaths -def stylemap(style, paths=None): +def stylemap(styles, paths=None): """Return path to mapfile for a given style. Searches mapfile in the following locations: @@ -234,12 +234,20 @@ elif isinstance(paths, str): paths = [paths] - locations = style and [os.path.join(style, "map"), "map-" + style] or [] - locations.append("map") - for path in paths: - for location in locations: - mapfile = os.path.join(path, location) - if os.path.isfile(mapfile): - return mapfile + if isinstance(styles, str): + styles = [styles] + + for style in styles: + + if not style: + continue + locations = [os.path.join(style, 'map'), 'map-' + style] + locations.append('map') + + for path in paths: + for location in locations: + mapfile = os.path.join(path, location) + if os.path.isfile(mapfile): + return style, mapfile raise RuntimeError("No hgweb templates found in %r" % paths)