Patchwork D8785: templater: simplify templatepaths() to avoid iterating a singleton list

login
register
mail settings
Submitter phabricator
Date July 22, 2020, 5:24 a.m.
Message ID <differential-rev-PHID-DREV-nmts4gejepajl7ujmvwo-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46829/
State Superseded
Headers show

Comments

phabricator - July 22, 2020, 5:24 a.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The function iterates over a hard-coded list of one element since
  d844e220792a <https://phab.mercurial-scm.org/rHGd844e220792a2a5d5506dce7caecc07635ed881e> (templater: don't search randomly for templates - trust
  util.datapath, 2014-09-28).

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8785

AFFECTED FILES
  mercurial/templater.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -1047,12 +1047,8 @@ 
 
 def templatepaths():
     '''return locations used for template files.'''
-    pathsrel = [b'templates']
-    paths = [
-        os.path.normpath(os.path.join(resourceutil.datapath, f))
-        for f in pathsrel
-    ]
-    return [p for p in paths if os.path.isdir(p)]
+    path = os.path.normpath(os.path.join(resourceutil.datapath, b'templates'))
+    return [path] if os.path.isdir(path) else []
 
 
 def templatepath(name):