Mercurial > hg
comparison mercurial/hgweb/webcommands.py @ 19737:ab5442f45441
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.
author | Alexander Plavin <alexander@plav.in> |
---|---|
date | Fri, 06 Sep 2013 13:30:57 +0400 |
parents | 6907251122e3 |
children | 93b8544c4482 |
comparison
equal
deleted
inserted
replaced
19736:f08e542ce918 | 19737:ab5442f45441 |
---|---|
257 elif 'rev' in req.form: | 257 elif 'rev' in req.form: |
258 return _search(web, req, tmpl) | 258 return _search(web, req, tmpl) |
259 else: | 259 else: |
260 ctx = web.repo['tip'] | 260 ctx = web.repo['tip'] |
261 | 261 |
262 def changelist(latestonly): | 262 def changelist(): |
263 revs = [] | 263 revs = [] |
264 if pos != -1: | 264 if pos != -1: |
265 revs = web.repo.changelog.revs(pos, 0) | 265 revs = web.repo.changelog.revs(pos, 0) |
266 if latestonly: | |
267 revs = (revs.next(),) | |
268 curcount = 0 | 266 curcount = 0 |
269 for i in revs: | 267 for i in revs: |
270 ctx = web.repo[i] | 268 ctx = web.repo[i] |
271 n = ctx.node() | 269 n = ctx.node() |
272 showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n) | 270 showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n) |
307 pos = ctx.rev() | 305 pos = ctx.rev() |
308 parity = paritygen(web.stripecount) | 306 parity = paritygen(web.stripecount) |
309 | 307 |
310 changenav = webutil.revnav(web.repo).gen(pos, revcount, count) | 308 changenav = webutil.revnav(web.repo).gen(pos, revcount, count) |
311 | 309 |
310 entries = list(changelist()) | |
311 latestentry = entries[:1] | |
312 | |
312 return tmpl(shortlog and 'shortlog' or 'changelog', changenav=changenav, | 313 return tmpl(shortlog and 'shortlog' or 'changelog', changenav=changenav, |
313 node=ctx.hex(), rev=pos, changesets=count, | 314 node=ctx.hex(), rev=pos, changesets=count, |
314 entries=lambda **x: changelist(latestonly=False), | 315 entries=entries, |
315 latestentry=lambda **x: changelist(latestonly=True), | 316 latestentry=latestentry, |
316 archives=web.archivelist("tip"), revcount=revcount, | 317 archives=web.archivelist("tip"), revcount=revcount, |
317 morevars=morevars, lessvars=lessvars, query=query) | 318 morevars=morevars, lessvars=lessvars, query=query) |
318 | 319 |
319 def shortlog(web, req, tmpl): | 320 def shortlog(web, req, tmpl): |
320 return changelog(web, req, tmpl, shortlog = True) | 321 return changelog(web, req, tmpl, shortlog = True) |