Patchwork [6,of,7] hgweb: wrap {fentries} and {dentries} of manifest with mappinggenerator

login
register
mail settings
Submitter Yuya Nishihara
Date May 13, 2018, 3:20 a.m.
Message ID <a4560b4d1b0ea2d1c81e.1526181603@mimosa>
Download mbox | patch
Permalink /patch/31574/
State Accepted
Headers show

Comments

Yuya Nishihara - May 13, 2018, 3:20 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1522840459 -32400
#      Wed Apr 04 20:14:19 2018 +0900
# Node ID a4560b4d1b0ea2d1c81e0ac0baca0e0ce2070557
# Parent  fbec01b4ef2287ede8255e14ac42ac3e6ef79906
hgweb: wrap {fentries} and {dentries} of manifest with mappinggenerator

They were functions returning a generator of mappings.

Patch

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -562,7 +562,7 @@  def manifest(web):
     if mf and not files and not dirs:
         raise ErrorResponse(HTTP_NOT_FOUND, 'path not found: ' + path)
 
-    def filelist(**map):
+    def filelist(context):
         for f in sorted(files):
             full = files[f]
 
@@ -574,7 +574,7 @@  def manifest(web):
                    "size": fctx.size(),
                    "permissions": mf.flags(full)}
 
-    def dirlist(**map):
+    def dirlist(context):
         for d in sorted(dirs):
 
             emptydirs = []
@@ -597,8 +597,8 @@  def manifest(web):
         path=abspath,
         up=webutil.up(abspath),
         upparity=next(parity),
-        fentries=filelist,
-        dentries=dirlist,
+        fentries=templateutil.mappinggenerator(filelist),
+        dentries=templateutil.mappinggenerator(dirlist),
         archives=web.archivelist(hex(node)),
         **pycompat.strkwargs(webutil.commonentry(web.repo, ctx)))