##// END OF EJS Templates
templater: drop support for old style keywords (API)...
Matt Harbison -
r42524:832c59d1 default
parent child Browse files
Show More
@@ -409,12 +409,6 b' def whyunstable(context, mapping):'
409 409
410 410 whyunstable._requires = {'repo', 'ctx'}
411 411
412 # helper to mark a function as a new-style template keyword; can be removed
413 # once old-style function gets unsupported and new-style becomes the default
414 def _kwfunc(f):
415 f._requires = ()
416 return f
417
418 412 def commonentry(repo, ctx):
419 413 node = scmutil.binnode(ctx)
420 414 return {
@@ -439,8 +433,8 b' def commonentry(repo, ctx):'
439 433 'branches': nodebranchdict(repo, ctx),
440 434 'tags': nodetagsdict(repo, node),
441 435 'bookmarks': nodebookmarksdict(repo, node),
442 'parent': _kwfunc(lambda context, mapping: parents(ctx)),
443 'child': _kwfunc(lambda context, mapping: children(ctx)),
436 'parent': lambda context, mapping: parents(ctx),
437 'child': lambda context, mapping: children(ctx),
444 438 }
445 439
446 440 def changelistentry(web, ctx):
@@ -457,9 +451,9 b' def changelistentry(web, ctx):'
457 451
458 452 entry = commonentry(repo, ctx)
459 453 entry.update({
460 'allparents': _kwfunc(lambda context, mapping: parents(ctx)),
461 'parent': _kwfunc(lambda context, mapping: parents(ctx, rev - 1)),
462 'child': _kwfunc(lambda context, mapping: children(ctx, rev + 1)),
454 'allparents': lambda context, mapping: parents(ctx),
455 'parent': lambda context, mapping: parents(ctx, rev - 1),
456 'child': lambda context, mapping: children(ctx, rev + 1),
463 457 'changelogtag': showtags,
464 458 'files': files,
465 459 })
@@ -529,7 +523,7 b' def changesetentry(web, ctx):'
529 523 changesetbranch=showbranch,
530 524 files=templateutil.mappedgenerator(_listfilesgen,
531 525 args=(ctx, web.stripecount)),
532 diffsummary=_kwfunc(lambda context, mapping: diffsummary(diffstatsgen)),
526 diffsummary=lambda context, mapping: diffsummary(diffstatsgen),
533 527 diffstat=diffstats,
534 528 archives=web.archivelist(ctx.hex()),
535 529 **pycompat.strkwargs(commonentry(web.repo, ctx)))
@@ -338,13 +338,6 b' class templatekeyword(_templateregistrar'
338 338 '''
339 339 pass
340 340
341 # old API (DEPRECATED)
342 @templatekeyword('mykeyword')
343 def mykeywordfunc(repo, ctx, templ, cache, revcache, **args):
344 '''Explanation of this template keyword ....
345 '''
346 pass
347
348 341 The first string argument is used also in online help.
349 342
350 343 Optional argument 'requires' should be a collection of resource names
@@ -874,7 +874,6 b' def runstring(context, mapping, data):'
874 874 def _recursivesymbolblocker(key):
875 875 def showrecursion(context, mapping):
876 876 raise error.Abort(_("recursive reference '%s' in template") % key)
877 showrecursion._requires = () # mark as new-style templatekw
878 877 return showrecursion
879 878
880 879 def runsymbol(context, mapping, key, default=''):
@@ -888,19 +887,6 b' def runsymbol(context, mapping, key, def'
888 887 v = context.process(key, safemapping)
889 888 except TemplateNotFound:
890 889 v = default
891 if callable(v) and getattr(v, '_requires', None) is None:
892 # old templatekw: expand all keywords and resources
893 # (TODO: drop support for old-style functions. 'f._requires = ()'
894 # can be removed.)
895 props = {k: context._resources.lookup(mapping, k)
896 for k in context._resources.knownkeys()}
897 # pass context to _showcompatlist() through templatekw._showlist()
898 props['templ'] = context
899 props.update(mapping)
900 ui = props.get('ui')
901 if ui:
902 ui.deprecwarn("old-style template keyword '%s'" % key, '4.8')
903 return v(**pycompat.strkwargs(props))
904 890 if callable(v):
905 891 # new templatekw
906 892 try:
General Comments 0
You need to be logged in to leave comments. Login now