Patchwork [2,of,4] hgweb: always compute all entries and latestentry in filelog

login
register
mail settings
Submitter Alexander Plavin
Date Nov. 10, 2013, 2:25 p.m.
Message ID <8bddf654c880f12052fa.1384093522@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2896/
State Accepted
Commit d85dfe211c7128ca1cf8625e57b0ba3de3459475
Headers show

Comments

Alexander Plavin - Nov. 10, 2013, 2:25 p.m.
# HG changeset patch
# User Alexander Plavin <alexander@plav.in>
# Date 1384092476 -14400
#      Sun Nov 10 18:07:56 2013 +0400
# Node ID 8bddf654c880f12052fa13efb07fedf7c2cf74c6
# Parent  cdfc1979e2b57be3029407c38d39eda0805b91a2
hgweb: always compute all entries and latestentry in filelog

This is the same thing which was done for changelog earlier, and it doesn't
affect performance at all. This change will make it possible to get the first
entry of the next page easily without computing the list twice.

Patch

diff -r cdfc1979e2b5 -r 8bddf654c880 mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	Sun Nov 10 18:05:53 2013 +0400
+++ b/mercurial/hgweb/webcommands.py	Sun Nov 10 18:07:56 2013 +0400
@@ -837,15 +837,11 @@ 
     end = min(count, start + revcount) # last rev on this page
     parity = paritygen(web.stripecount, offset=start - end)
 
-    def entries(latestonly):
+    def entries():
         l = []
 
         repo = web.repo
         revs = repo.changelog.revs(start, end - 1)
-        if latestonly:
-            for r in revs:
-                pass
-            revs = (r,)
         for i in revs:
             iterfctx = fctx.filectx(i)
 
@@ -869,11 +865,14 @@ 
         for e in reversed(l):
             yield e
 
+    entries = list(entries())
+    latestentry = entries[:1]
+
     revnav = webutil.filerevnav(web.repo, fctx.path())
     nav = revnav.gen(end - 1, revcount, count)
     return tmpl("filelog", file=f, node=fctx.hex(), nav=nav,
-                entries=lambda **x: entries(latestonly=False),
-                latestentry=lambda **x: entries(latestonly=True),
+                entries=entries,
+                latestentry=latestentry,
                 revcount=revcount, morevars=morevars, lessvars=lessvars)
 
 def archive(web, req, tmpl):