hgweb: mark all lambda template keywords as new-style function
authorYuya Nishihara <yuya@tcha.org>
Sat, 28 Jul 2018 21:19:24 +0900
changeset 38929 d7e6e109eaae
parent 38928 4167437a45dd
child 38930 382b055cc358
hgweb: mark all lambda template keywords as new-style function This is just a temporary workaround, and will be removed in Mercurial 4.9.
mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py	Sat Jul 28 21:02:05 2018 +0900
+++ b/mercurial/hgweb/webutil.py	Sat Jul 28 21:19:24 2018 +0900
@@ -408,6 +408,12 @@
 
 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 = ctx.node()
     return {
@@ -432,8 +438,8 @@
         'branches': nodebranchdict(repo, ctx),
         'tags': nodetagsdict(repo, node),
         'bookmarks': nodebookmarksdict(repo, node),
-        'parent': lambda **x: parents(ctx),
-        'child': lambda **x: children(ctx),
+        'parent': _kwfunc(lambda context, mapping: parents(ctx)),
+        'child': _kwfunc(lambda context, mapping: children(ctx)),
     }
 
 def changelistentry(web, ctx):
@@ -450,9 +456,9 @@
 
     entry = commonentry(repo, ctx)
     entry.update(
-        allparents=lambda **x: parents(ctx),
-        parent=lambda **x: parents(ctx, rev - 1),
-        child=lambda **x: children(ctx, rev + 1),
+        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)),
         changelogtag=showtags,
         files=files,
     )
@@ -521,7 +527,7 @@
         changesetbranch=showbranch,
         files=templateutil.mappedgenerator(_listfilesgen,
                                            args=(ctx, web.stripecount)),
-        diffsummary=lambda **x: diffsummary(diffstatsgen),
+        diffsummary=_kwfunc(lambda context, mapping: diffsummary(diffstatsgen)),
         diffstat=diffstats,
         archives=web.archivelist(ctx.hex()),
         **pycompat.strkwargs(commonentry(web.repo, ctx)))