diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2256,7 +2256,7 @@ def debuginstall(ui): # templates import templater - p = templater.templatepath() + p = templater.templatepaths() ui.status(_("checking templates (%s)...\n") % ' '.join(p)) if p: m = templater.templatepath("map-cmdline.default") diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py +++ b/mercurial/hgweb/hgwebdir_mod.py @@ -193,7 +193,7 @@ class hgwebdir(object): static = self.ui.config("web", "static", None, untrusted=False) if not static: - tp = self.templatepath or templater.templatepath() + tp = self.templatepath or templater.templatepaths() if isinstance(tp, str): tp = [tp] static = [os.path.join(p, 'static') for p in tp] diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -933,7 +933,7 @@ def static(web, req, tmpl): # readable by the user running the CGI script static = web.config("web", "static", None, untrusted=False) if not static: - tp = web.templatepath or templater.templatepath() + tp = web.templatepath or templater.templatepaths() if isinstance(tp, str): tp = [tp] static = [os.path.join(p, 'static') for p in tp] diff --git a/mercurial/templater.py b/mercurial/templater.py --- a/mercurial/templater.py +++ b/mercurial/templater.py @@ -625,7 +625,7 @@ class engine(object): engines = {'default': engine} def stylelist(): - paths = templatepath() + paths = templatepaths() if not paths: return _('no templates found, try `hg debuginstall` for more info') dirlist = os.listdir(paths[0]) @@ -710,25 +710,26 @@ class templater(object): max=self.maxchunk) return stream -def templatepath(name=None): - '''return location of template file or directory (if no name). - returns None if not found.''' +def templatepaths(): + '''return locations used for template files.''' normpaths = [] - for f in path: if f.startswith('/'): p = f else: fl = f.split('/') p = os.path.join(util.datapath, *fl) - if name: - p = os.path.join(p, name) - if name and os.path.exists(p): - return os.path.normpath(p) - elif os.path.isdir(p): + if os.path.isdir(p): normpaths.append(os.path.normpath(p)) + return normpaths - return normpaths +def templatepath(name): + '''return location of template file. returns None if not found.''' + for p in templatepaths(): + f = os.path.join(p, name) + if os.path.exists(f): + return f + return None def stylemap(styles, paths=None): """Return path to mapfile for a given style. @@ -740,7 +741,7 @@ def stylemap(styles, paths=None): """ if paths is None: - paths = templatepath() + paths = templatepaths() elif isinstance(paths, str): paths = [paths]