comparison mercurial/hgweb/webcommands.py @ 26129:a103ecb8a04a

hgweb: move branchentries code from webcommands to webutil
author Anton Shestakov <av6@dwimlabs.net>
date Tue, 01 Sep 2015 22:28:45 +0800
parents 328739ea70c3
children e466c15597a3
comparison
equal deleted inserted replaced
26128:51f6940d3b4f 26129:a103ecb8a04a
637 637
638 No arguments are accepted. 638 No arguments are accepted.
639 639
640 The ``branches`` template is rendered. 640 The ``branches`` template is rendered.
641 """ 641 """
642 tips = [] 642 entries = webutil.branchentries(web.repo, web.stripecount)
643 heads = web.repo.heads() 643 latestentry = webutil.branchentries(web.repo, web.stripecount, 1)
644 parity = paritygen(web.stripecount)
645 sortkey = lambda item: (not item[1], item[0].rev())
646
647 def entries(limit, **map):
648 count = 0
649 if not tips:
650 for tag, hs, tip, closed in web.repo.branchmap().iterbranches():
651 tips.append((web.repo[tip], closed))
652 for ctx, closed in sorted(tips, key=sortkey, reverse=True):
653 if limit > 0 and count >= limit:
654 return
655 count += 1
656 if closed:
657 status = 'closed'
658 elif ctx.node() not in heads:
659 status = 'inactive'
660 else:
661 status = 'open'
662 yield {'parity': parity.next(),
663 'branch': ctx.branch(),
664 'status': status,
665 'node': ctx.hex(),
666 'date': ctx.date()}
667
668 return tmpl('branches', node=hex(web.repo.changelog.tip()), 644 return tmpl('branches', node=hex(web.repo.changelog.tip()),
669 entries=lambda **x: entries(0, **x), 645 entries=entries, latestentry=latestentry)
670 latestentry=lambda **x: entries(1, **x))
671 646
672 @webcommand('summary') 647 @webcommand('summary')
673 def summary(web, req, tmpl): 648 def summary(web, req, tmpl):
674 """ 649 """
675 /summary 650 /summary