# HG changeset patch # User Matt Harbison # Date 2019-05-18 23:56:06 # Node ID 832c59d1196e8088102500992ee0e0a32e49226e # Parent fa4b13e81f60c925c3565f1c4df19ec18e3a0a58 templater: drop support for old style keywords (API) These changes originated from several commits over a period of time, so I'm slightly unsure if this is correct. But the tests pass. diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py --- a/mercurial/hgweb/webutil.py +++ b/mercurial/hgweb/webutil.py @@ -409,12 +409,6 @@ def whyunstable(context, mapping): whyunstable._requires = {'repo', 'ctx'} -# helper to mark a function as a new-style template keyword; can be removed -# once old-style function gets unsupported and new-style becomes the default -def _kwfunc(f): - f._requires = () - return f - def commonentry(repo, ctx): node = scmutil.binnode(ctx) return { @@ -439,8 +433,8 @@ def commonentry(repo, ctx): 'branches': nodebranchdict(repo, ctx), 'tags': nodetagsdict(repo, node), 'bookmarks': nodebookmarksdict(repo, node), - 'parent': _kwfunc(lambda context, mapping: parents(ctx)), - 'child': _kwfunc(lambda context, mapping: children(ctx)), + 'parent': lambda context, mapping: parents(ctx), + 'child': lambda context, mapping: children(ctx), } def changelistentry(web, ctx): @@ -457,9 +451,9 @@ def changelistentry(web, ctx): entry = commonentry(repo, ctx) entry.update({ - 'allparents': _kwfunc(lambda context, mapping: parents(ctx)), - 'parent': _kwfunc(lambda context, mapping: parents(ctx, rev - 1)), - 'child': _kwfunc(lambda context, mapping: children(ctx, rev + 1)), + 'allparents': lambda context, mapping: parents(ctx), + 'parent': lambda context, mapping: parents(ctx, rev - 1), + 'child': lambda context, mapping: children(ctx, rev + 1), 'changelogtag': showtags, 'files': files, }) @@ -529,7 +523,7 @@ def changesetentry(web, ctx): changesetbranch=showbranch, files=templateutil.mappedgenerator(_listfilesgen, args=(ctx, web.stripecount)), - diffsummary=_kwfunc(lambda context, mapping: diffsummary(diffstatsgen)), + diffsummary=lambda context, mapping: diffsummary(diffstatsgen), diffstat=diffstats, archives=web.archivelist(ctx.hex()), **pycompat.strkwargs(commonentry(web.repo, ctx))) diff --git a/mercurial/registrar.py b/mercurial/registrar.py --- a/mercurial/registrar.py +++ b/mercurial/registrar.py @@ -338,13 +338,6 @@ class templatekeyword(_templateregistrar ''' pass - # old API (DEPRECATED) - @templatekeyword('mykeyword') - def mykeywordfunc(repo, ctx, templ, cache, revcache, **args): - '''Explanation of this template keyword .... - ''' - pass - The first string argument is used also in online help. Optional argument 'requires' should be a collection of resource names diff --git a/mercurial/templateutil.py b/mercurial/templateutil.py --- a/mercurial/templateutil.py +++ b/mercurial/templateutil.py @@ -874,7 +874,6 @@ def runstring(context, mapping, data): def _recursivesymbolblocker(key): def showrecursion(context, mapping): raise error.Abort(_("recursive reference '%s' in template") % key) - showrecursion._requires = () # mark as new-style templatekw return showrecursion def runsymbol(context, mapping, key, default=''): @@ -888,19 +887,6 @@ def runsymbol(context, mapping, key, def v = context.process(key, safemapping) except TemplateNotFound: v = default - if callable(v) and getattr(v, '_requires', None) is None: - # old templatekw: expand all keywords and resources - # (TODO: drop support for old-style functions. 'f._requires = ()' - # can be removed.) - props = {k: context._resources.lookup(mapping, k) - for k in context._resources.knownkeys()} - # pass context to _showcompatlist() through templatekw._showlist() - props['templ'] = context - props.update(mapping) - ui = props.get('ui') - if ui: - ui.deprecwarn("old-style template keyword '%s'" % key, '4.8') - return v(**pycompat.strkwargs(props)) if callable(v): # new templatekw try: