Patchwork [5,of,8] hgweb: wrap {parents} of {annotate} with mappinggenerator

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

Comments

Yuya Nishihara - May 21, 2018, 12:22 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1522841398 -32400
#      Wed Apr 04 20:29:58 2018 +0900
# Node ID e58591b37eada3d982d2db29901c73e8b084c4f9
# Parent  6970d3a9c6a4ee333a1a10abccfa40a8771af471
hgweb: wrap {parents} of {annotate} with mappinggenerator

It's a generator of at most two mappings, which has to be wrapped.

Patch

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -929,7 +929,7 @@  def annotate(web):
     # TODO there are still redundant operations within basefilectx.parents()
     # and from the fctx.annotate() call itself that could be cached.
     parentscache = {}
-    def parents(f):
+    def parents(context, f):
         rev = f.rev()
         if rev not in parentscache:
             parentscache[rev] = []
@@ -967,7 +967,7 @@  def annotate(web):
                    "node": f.hex(),
                    "rev": rev,
                    "author": f.user(),
-                   "parents": parents(f),
+                   "parents": templateutil.mappinggenerator(parents, args=(f,)),
                    "desc": f.description(),
                    "extra": f.extra(),
                    "file": f.path(),