Patchwork [02,of,20] hgweb: always compute all entries and latestentry in changelog

login
register
mail settings
Submitter Alexander Plavin
Date Aug. 9, 2013, 6:57 p.m.
Message ID <952b2d0f6f1eeed1b2cd.1376074647@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2113/
State Superseded
Commit ab5442f45441b055650e90aa13167ff47df66161
Headers show

Comments

Alexander Plavin - Aug. 9, 2013, 6:57 p.m.
# HG changeset patch
# User Alexander Plavin <alexander@plav.in>
# Date 1376018556 -14400
#      Fri Aug 09 07:22:36 2013 +0400
# Node ID 952b2d0f6f1eeed1b2cd40214097b44e2d72b256
# Parent  f2329fe540ffd386eb59ec606515740802a331a5
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 f2329fe540ff -r 952b2d0f6f1e 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
@@ -260,12 +260,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]
@@ -310,10 +308,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)