From patchwork Sat Aug 17 22:27:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2, of, 3, V2] hgweb: always compute all entries and latestentry in changelog From: Alexander Plavin X-Patchwork-Id: 2201 Message-Id: <75805f44a32239ec77e7.1376778474@debian-alexander.dolgopa> To: mercurial-devel@selenic.com Date: Sun, 18 Aug 2013 02:27:54 +0400 # HG changeset patch # User Alexander Plavin # 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. 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)