changeset 37949:1129e444fd6c

hgweb: extract generator of {files} from changesetentry() This will be wrapped with mappedgenerator.
author Yuya Nishihara <yuya@tcha.org>
date Tue, 03 Apr 2018 23:25:32 +0900
parents a25513263075
children 790ca0c11fd4
files mercurial/hgweb/webutil.py
diffstat 1 files changed, 12 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/webutil.py	Sat Jan 16 19:23:53 2016 +0900
+++ b/mercurial/hgweb/webutil.py	Tue Apr 03 23:25:32 2018 +0900
@@ -463,6 +463,17 @@
     else:
         return short(ctx.node())
 
+def _listfilesgen(tmpl, ctx, stripecount):
+    parity = paritygen(stripecount)
+    for blockno, f in enumerate(ctx.files()):
+        template = 'filenodelink' if f in ctx else 'filenolink'
+        yield tmpl.generate(template, {
+            'node': ctx.hex(),
+            'file': f,
+            'blockno': blockno + 1,
+            'parity': next(parity),
+        })
+
 def changesetentry(web, ctx):
     '''Obtain a dictionary to be used to render the "changeset" template.'''
 
@@ -470,17 +481,6 @@
     showbookmarks = showbookmark(web.repo, 'changesetbookmark', ctx.node())
     showbranch = nodebranchnodefault(ctx)
 
-    files = []
-    parity = paritygen(web.stripecount)
-    for blockno, f in enumerate(ctx.files()):
-        template = 'filenodelink' if f in ctx else 'filenolink'
-        files.append(web.tmpl.generate(template, {
-            'node': ctx.hex(),
-            'file': f,
-            'blockno': blockno + 1,
-            'parity': next(parity),
-        }))
-
     basectx = basechangectx(web.repo, web.req)
     if basectx is None:
         basectx = ctx.p1()
@@ -502,7 +502,7 @@
         changesettag=showtags,
         changesetbookmark=showbookmarks,
         changesetbranch=showbranch,
-        files=files,
+        files=list(_listfilesgen(web.tmpl, ctx, web.stripecount)),
         diffsummary=lambda **x: diffsummary(diffstatsgen),
         diffstat=diffstats,
         archives=web.archivelist(ctx.hex()),