comparison mercurial/hgweb/webcommands.py @ 18030:ebc0fa067c07 stable

hgweb: avoid generator exhaustion with branches
author Matt Mackall <mpm@selenic.com>
date Thu, 06 Dec 2012 13:21:27 -0600
parents 109a6a9dcca8
children c8326ffdcb4f
comparison
equal deleted inserted replaced
18029:109a6a9dcca8 18030:ebc0fa067c07
435 node=hex(web.repo.changelog.tip()), 435 node=hex(web.repo.changelog.tip()),
436 entries=lambda **x: entries(0, **x), 436 entries=lambda **x: entries(0, **x),
437 latestentry=lambda **x: entries(1, **x)) 437 latestentry=lambda **x: entries(1, **x))
438 438
439 def branches(web, req, tmpl): 439 def branches(web, req, tmpl):
440 tips = (web.repo[n] for t, n in web.repo.branchtags().iteritems()) 440 tips = []
441 heads = web.repo.heads() 441 heads = web.repo.heads()
442 parity = paritygen(web.stripecount) 442 parity = paritygen(web.stripecount)
443 sortkey = lambda ctx: (not ctx.closesbranch(), ctx.rev()) 443 sortkey = lambda ctx: (not ctx.closesbranch(), ctx.rev())
444 444
445 def entries(limit, **map): 445 def entries(limit, **map):
446 count = 0 446 count = 0
447 if not tips:
448 for t, n in web.repo.branchtags().iteritems():
449 tips.append(web.repo[n])
447 for ctx in sorted(tips, key=sortkey, reverse=True): 450 for ctx in sorted(tips, key=sortkey, reverse=True):
448 if limit > 0 and count >= limit: 451 if limit > 0 and count >= limit:
449 return 452 return
450 count += 1 453 count += 1
451 if not web.repo.branchheads(ctx.branch()): 454 if not web.repo.branchheads(ctx.branch()):