diff mercurial/hgweb/webcommands.py @ 37019:c97b936d8bb5

templater: use named function to expand template against mapping dict (API) And replace __call__(t, **mapping) in favor of generate(t, mapping). I prefer a named function here since the templater isn't a simple function-like object. .. api:: The templater is no longer callable. Use ``templater.generate(t, mapping)`` instead of ``templater(t, **pycompat.strkwargs(mapping))``.
author Yuya Nishihara <yuya@tcha.org>
date Fri, 16 Mar 2018 21:39:32 +0900
parents a82fc3922446
children b33b91ca2ec2
line wrap: on
line diff
--- a/mercurial/hgweb/webcommands.py	Mon Mar 19 21:09:23 2018 +0900
+++ b/mercurial/hgweb/webcommands.py	Fri Mar 16 21:39:32 2018 +0900
@@ -294,12 +294,13 @@
             files = webutil.listfilediffs(web.tmpl, ctx.files(), n,
                                           web.maxfiles)
 
-            yield web.tmpl(
-                'searchentry',
-                parity=next(parity),
-                changelogtag=showtags,
-                files=files,
-                **pycompat.strkwargs(webutil.commonentry(web.repo, ctx)))
+            lm = webutil.commonentry(web.repo, ctx)
+            lm.update({
+                'parity': next(parity),
+                'changelogtag': showtags,
+                'files': files,
+            })
+            yield web.tmpl.generate('searchentry', lm)
 
             if count >= revcount:
                 break
@@ -719,12 +720,12 @@
             if count > 10: # limit to 10 tags
                 break
 
-            yield web.tmpl(
-                'tagentry',
-                parity=next(parity),
-                tag=k,
-                node=hex(n),
-                date=web.repo[n].date())
+            yield web.tmpl.generate('tagentry', {
+                'parity': next(parity),
+                'tag': k,
+                'node': hex(n),
+                'date': web.repo[n].date(),
+            })
 
     def bookmarks(**map):
         parity = paritygen(web.stripecount)
@@ -745,11 +746,9 @@
             revs = web.repo.changelog.revs(start, end - 1)
         for i in revs:
             ctx = web.repo[i]
-
-            l.append(web.tmpl(
-                'shortlogentry',
-                parity=next(parity),
-                **pycompat.strkwargs(webutil.commonentry(web.repo, ctx))))
+            lm = webutil.commonentry(web.repo, ctx)
+            lm['parity'] = next(parity)
+            l.append(web.tmpl.generate('shortlogentry', lm))
 
         for entry in reversed(l):
             yield entry