templater: add context.preload(t) to test if the specified template exists
I'm going to remove 'templ' from the resources dict because it is the only
resource that the caller can't provide. This also implies that putting
'templ' into the resources dict creates a reference cycle.
context.preload(t) will be used in place of templater.__contains__().
--- a/mercurial/templater.py Sun Mar 18 12:28:19 2018 +0900
+++ b/mercurial/templater.py Fri Mar 16 22:36:40 2018 +0900
@@ -627,6 +627,14 @@
raise
return self._cache[t]
+ def preload(self, t):
+ """Load, parse, and cache the specified template if available"""
+ try:
+ self._load(t)
+ return True
+ except templateutil.TemplateNotFound:
+ return False
+
def process(self, t, mapping):
'''Perform expansion. t is name of map element to expand.
mapping contains added elements for use during expansion. Is a