hgweb: always compute all entries and latestentry in changelog
authorAlexander Plavin <alexander@plav.in>
Fri, 06 Sep 2013 13:30:57 +0400
changeset 19737 ab5442f45441
parent 19736 f08e542ce918
child 19738 93b8544c4482
hgweb: always compute all entries and latestentry in changelog Get the whole list of entries before rendering instead of using lazy evaluation. This doesn't affect the performance for usual case when the entries are shown anyway. When both entries and latestentry are used, this performs unnoticeably faster, and for pages which use only latestentry (quite uncommon case) it would be a bit slower. This change will make it possible to get the first entry of the next page easily without computing the list twice.
mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	Tue Sep 17 17:42:13 2013 +0200
+++ b/mercurial/hgweb/webcommands.py	Fri Sep 06 13:30:57 2013 +0400
@@ -259,12 +259,10 @@
     else:
         ctx = web.repo['tip']
 
-    def changelist(latestonly):
+    def changelist():
         revs = []
         if pos != -1:
             revs = web.repo.changelog.revs(pos, 0)
-        if latestonly:
-            revs = (revs.next(),)
         curcount = 0
         for i in revs:
             ctx = web.repo[i]
@@ -309,10 +307,13 @@
 
     changenav = webutil.revnav(web.repo).gen(pos, revcount, count)
 
+    entries = list(changelist())
+    latestentry = entries[:1]
+
     return tmpl(shortlog and 'shortlog' or 'changelog', changenav=changenav,
                 node=ctx.hex(), rev=pos, changesets=count,
-                entries=lambda **x: changelist(latestonly=False),
-                latestentry=lambda **x: changelist(latestonly=True),
+                entries=entries,
+                latestentry=latestentry,
                 archives=web.archivelist("tip"), revcount=revcount,
                 morevars=morevars, lessvars=lessvars, query=query)