changeset 30816:96f811bceb85

hgweb: build the "entries" list directly in filelog command There's no apparent reason to have this "entries" generator function that builds a list and then yields its elements in reverse order and which is only called to build the "entries" list. So just build the list directly, in reverse order. Adjust "parity" generator's offset to keep rendering the same.
author Denis Laxalde <denis.laxalde@logilab.fr>
date Fri, 13 Jan 2017 10:22:25 +0100
parents c5bf2e8ec18c
children 2b279126b8f5
files mercurial/hgweb/webcommands.py
diffstat 1 files changed, 12 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/webcommands.py	Sat Jan 14 10:11:19 2017 -0800
+++ b/mercurial/hgweb/webcommands.py	Fri Jan 13 10:22:25 2017 +0100
@@ -974,26 +974,20 @@
     count = fctx.filerev() + 1
     start = max(0, fctx.filerev() - revcount + 1) # first rev on this page
     end = min(count, start + revcount) # last rev on this page
-    parity = paritygen(web.stripecount, offset=start - end)
-
-    def entries():
-        l = []
-
-        repo = web.repo
-        revs = fctx.filelog().revs(start, end - 1)
-        for i in revs:
-            iterfctx = fctx.filectx(i)
+    parity = paritygen(web.stripecount, offset=start - end + 1)
 
-            l.append(dict(
-                parity=next(parity),
-                filerev=i,
-                file=f,
-                rename=webutil.renamelink(iterfctx),
-                **webutil.commonentry(repo, iterfctx)))
-        for e in reversed(l):
-            yield e
+    repo = web.repo
+    revs = fctx.filelog().revs(start, end - 1)
+    entries = []
+    for i in reversed(revs):
+        iterfctx = fctx.filectx(i)
+        entries.append(dict(
+            parity=next(parity),
+            filerev=i,
+            file=f,
+            rename=webutil.renamelink(iterfctx),
+            **webutil.commonentry(repo, iterfctx)))
 
-    entries = list(entries())
     latestentry = entries[:1]
 
     revnav = webutil.filerevnav(web.repo, fctx.path())