##// END OF EJS Templates
templatefuncs: minimize resource requirements
Yuya Nishihara -
r38446:4b73f316 default
parent child Browse files
Show More
@@ -512,7 +512,7 b' def relpath(context, mapping, args):'
512 # i18n: "relpath" is a keyword
512 # i18n: "relpath" is a keyword
513 raise error.ParseError(_("relpath expects one argument"))
513 raise error.ParseError(_("relpath expects one argument"))
514
514
515 repo = context.resource(mapping, 'ctx').repo()
515 repo = context.resource(mapping, 'repo')
516 path = evalstring(context, mapping, args[0])
516 path = evalstring(context, mapping, args[0])
517 return repo.pathto(path)
517 return repo.pathto(path)
518
518
@@ -525,8 +525,7 b' def revset(context, mapping, args):'
525 raise error.ParseError(_("revset expects one or more arguments"))
525 raise error.ParseError(_("revset expects one or more arguments"))
526
526
527 raw = evalstring(context, mapping, args[0])
527 raw = evalstring(context, mapping, args[0])
528 ctx = context.resource(mapping, 'ctx')
528 repo = context.resource(mapping, 'repo')
529 repo = ctx.repo()
530
529
531 def query(expr):
530 def query(expr):
532 m = revsetmod.match(repo.ui, expr, lookup=revsetmod.lookupfn(repo))
531 m = revsetmod.match(repo.ui, expr, lookup=revsetmod.lookupfn(repo))
@@ -594,7 +593,7 b' def shortest(context, mapping, args):'
594 # i18n: "shortest" is a keyword
593 # i18n: "shortest" is a keyword
595 _("shortest() expects an integer minlength"))
594 _("shortest() expects an integer minlength"))
596
595
597 repo = context.resource(mapping, 'ctx')._repo
596 repo = context.resource(mapping, 'repo')
598 if len(hexnode) > 40:
597 if len(hexnode) > 40:
599 return hexnode
598 return hexnode
600 elif len(hexnode) == 40:
599 elif len(hexnode) == 40:
@@ -229,7 +229,7 b" Internal resources shouldn't be exposed "
229 Never crash on internal resource not available:
229 Never crash on internal resource not available:
230
230
231 $ hg --cwd .. debugtemplate '{"c0bebeef"|shortest}\n'
231 $ hg --cwd .. debugtemplate '{"c0bebeef"|shortest}\n'
232 abort: template resource not available: ctx
232 abort: template resource not available: repo
233 [255]
233 [255]
234
234
235 $ hg config -T '{author}'
235 $ hg config -T '{author}'
General Comments 0
You need to be logged in to leave comments. Login now