[PATCH 4 of 7] templater: inline global 'path' list in templatepaths

Mads Kiilerich mads at kiilerich.com
Sun Sep 28 10:03:01 CDT 2014


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1411916257 -7200
#      Sun Sep 28 16:57:37 2014 +0200
# Node ID bfb29147145157d7f8f0c312867cddda4f0ab72d
# Parent  6bdef4ab93246c687a4811b7bf496ae90f19ef43
templater: inline global 'path' list in templatepaths

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -553,7 +553,6 @@ funcs = {
 
 # template engine
 
-path = ['templates', '../templates']
 stringify = templatefilters.stringify
 
 def _flatten(thing):
@@ -712,16 +711,10 @@ class templater(object):
 
 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 os.path.isdir(p):
-            normpaths.append(os.path.normpath(p))
-    return normpaths
+    pathsrel = ['templates', '../templates']
+    paths = [os.path.normpath(os.path.join(util.datapath, f))
+             for f in pathsrel]
+    return [p for p in paths if os.path.isdir(p)]
 
 def templatepath(name):
     '''return location of template file. returns None if not found.'''


More information about the Mercurial-devel mailing list