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

Alexander Plavin alexander at plav.in
Sun Nov 10 08:25:22 CST 2013


# HG changeset patch
# User Alexander Plavin <alexander at 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.

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):


More information about the Mercurial-devel mailing list