Patchwork [2,of,3,V2] hgweb: always compute all entries and latestentry in changelog

login
register
mail settings
Submitter Alexander Plavin
Date Aug. 17, 2013, 10:27 p.m.
Message ID <75805f44a32239ec77e7.1376778474@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2201/
State Superseded
Commit ab5442f45441b055650e90aa13167ff47df66161
Headers show

Comments

Alexander Plavin - Aug. 17, 2013, 10:27 p.m.
# HG changeset patch
# User Alexander Plavin <alexander@plav.in>
# Date 1376018556 -14400
#      Fri Aug 09 07:22:36 2013 +0400
# Node ID 75805f44a32239ec77e7f4c1bc7232c85c7b8d7b
# Parent  77ffac585b5fe680fc30c9bb4437d63f0cad96f4
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.

Patch

diff -r 77ffac585b5f -r 75805f44a322 mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	Fri Aug 09 07:16:04 2013 +0400
+++ b/mercurial/hgweb/webcommands.py	Fri Aug 09 07:22:36 2013 +0400
@@ -271,12 +271,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]
@@ -321,10 +319,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)