changeset 38427:4b73f316ba0e

templatefuncs: minimize resource requirements
author Yuya Nishihara <yuya@tcha.org>
date Thu, 14 Jun 2018 21:17:56 +0900
parents 00368bc0a614
children aa98392eb5b0
files mercurial/templatefuncs.py tests/test-command-template.t
diffstat 2 files changed, 4 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templatefuncs.py	Thu Jun 21 09:32:31 2018 -0700
+++ b/mercurial/templatefuncs.py	Thu Jun 14 21:17:56 2018 +0900
@@ -512,7 +512,7 @@
         # i18n: "relpath" is a keyword
         raise error.ParseError(_("relpath expects one argument"))
 
-    repo = context.resource(mapping, 'ctx').repo()
+    repo = context.resource(mapping, 'repo')
     path = evalstring(context, mapping, args[0])
     return repo.pathto(path)
 
@@ -525,8 +525,7 @@
         raise error.ParseError(_("revset expects one or more arguments"))
 
     raw = evalstring(context, mapping, args[0])
-    ctx = context.resource(mapping, 'ctx')
-    repo = ctx.repo()
+    repo = context.resource(mapping, 'repo')
 
     def query(expr):
         m = revsetmod.match(repo.ui, expr, lookup=revsetmod.lookupfn(repo))
@@ -594,7 +593,7 @@
                                 # i18n: "shortest" is a keyword
                                 _("shortest() expects an integer minlength"))
 
-    repo = context.resource(mapping, 'ctx')._repo
+    repo = context.resource(mapping, 'repo')
     if len(hexnode) > 40:
         return hexnode
     elif len(hexnode) == 40:
--- a/tests/test-command-template.t	Thu Jun 21 09:32:31 2018 -0700
+++ b/tests/test-command-template.t	Thu Jun 14 21:17:56 2018 +0900
@@ -229,7 +229,7 @@
 Never crash on internal resource not available:
 
   $ hg --cwd .. debugtemplate '{"c0bebeef"|shortest}\n'
-  abort: template resource not available: ctx
+  abort: template resource not available: repo
   [255]
 
   $ hg config -T '{author}'