From patchwork Fri Aug 9 18:57:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [02, of, 20] hgweb: always compute all entries and latestentry in changelog From: Alexander Plavin X-Patchwork-Id: 2113 Message-Id: <952b2d0f6f1eeed1b2cd.1376074647@debian-alexander.dolgopa> To: mercurial-devel@selenic.com Date: Fri, 09 Aug 2013 22:57:27 +0400 # HG changeset patch # User Alexander Plavin # 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. 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)