Patchwork [1,of,8] hgweb: wrap {entries}* of bookmarks with mappinggenerator

login
register
mail settings
Submitter Yuya Nishihara
Date May 21, 2018, 12:22 p.m.
Message ID <56e8ac64a7a3d529a596.1526905358@mimosa>
Download mbox | patch
Permalink /patch/31768/
State Accepted
Headers show

Comments

Yuya Nishihara - May 21, 2018, 12:22 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1522840791 -32400
#      Wed Apr 04 20:19:51 2018 +0900
# Node ID 56e8ac64a7a3d529a596778d16ffc442a87f96e6
# Parent  9bf0bd4d7a2e44be4b15f8e1d51eb6d562e509e8
hgweb: wrap {entries}* of bookmarks with mappinggenerator

They were functions returning a generator of mappings. The laziness is
handled by the mappinggenerator class.
Gregory Szorc - May 24, 2018, 12:54 a.m.
On Mon, May 21, 2018 at 5:22 AM, Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1522840791 -32400
> #      Wed Apr 04 20:19:51 2018 +0900
> # Node ID 56e8ac64a7a3d529a596778d16ffc442a87f96e6
> # Parent  9bf0bd4d7a2e44be4b15f8e1d51eb6d562e509e8
> hgweb: wrap {entries}* of bookmarks with mappinggenerator
>

Queued this series. Thanks.


>
> They were functions returning a generator of mappings. The laziness is
> handled by the mappinggenerator class.
>
> diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.
> py
> --- a/mercurial/hgweb/webcommands.py
> +++ b/mercurial/hgweb/webcommands.py
> @@ -648,7 +648,7 @@ def bookmarks(web):
>      i = sorted(i, key=sortkey, reverse=True)
>      parity = paritygen(web.stripecount)
>
> -    def entries(latestonly, **map):
> +    def entries(context, latestonly):
>          t = i
>          if latestonly:
>              t = i[:1]
> @@ -667,8 +667,8 @@ def bookmarks(web):
>          'bookmarks',
>          node=hex(web.repo.changelog.tip()),
>          lastchange=[{'date': web.repo[latestrev].date()}],
> -        entries=lambda **x: entries(latestonly=False, **x),
> -        latestentry=lambda **x: entries(latestonly=True, **x))
> +        entries=templateutil.mappinggenerator(entries, args=(False,)),
> +        latestentry=templateutil.mappinggenerator(entries, args=(True,)))
>
>  @webcommand('branches')
>  def branches(web):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -648,7 +648,7 @@  def bookmarks(web):
     i = sorted(i, key=sortkey, reverse=True)
     parity = paritygen(web.stripecount)
 
-    def entries(latestonly, **map):
+    def entries(context, latestonly):
         t = i
         if latestonly:
             t = i[:1]
@@ -667,8 +667,8 @@  def bookmarks(web):
         'bookmarks',
         node=hex(web.repo.changelog.tip()),
         lastchange=[{'date': web.repo[latestrev].date()}],
-        entries=lambda **x: entries(latestonly=False, **x),
-        latestentry=lambda **x: entries(latestonly=True, **x))
+        entries=templateutil.mappinggenerator(entries, args=(False,)),
+        latestentry=templateutil.mappinggenerator(entries, args=(True,)))
 
 @webcommand('branches')
 def branches(web):