changeset 20022:d85dfe211c71

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.
author Alexander Plavin <alexander@plav.in>
date Sun, 10 Nov 2013 18:07:56 +0400
parents 4830763f825c
children 2771e59afac4
files mercurial/hgweb/webcommands.py
diffstat 1 files changed, 6 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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
@@ -836,15 +836,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)
 
@@ -868,11 +864,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):