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

login
register
mail settings
Submitter Mads Kiilerich
Date Sept. 28, 2014, 3:03 p.m.
Message ID <bfb29147145157d7f8f0.1411916581@localhost.localdomain>
Download mbox | patch
Permalink /patch/6010/
State Accepted
Headers show

Comments

Mads Kiilerich - Sept. 28, 2014, 3:03 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@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

Patch

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.'''