comparison mercurial/hgweb/webcommands.py @ 38134:edacd831afab

hgweb: wrap {entries}* of bookmarks with mappinggenerator They were functions returning a generator of mappings. The laziness is handled by the mappinggenerator class.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 04 Apr 2018 20:19:51 +0900
parents 3c995af3066e
children 5e94d07b290a
comparison
equal deleted inserted replaced
38133:dce718404ce6 38134:edacd831afab
646 i = [b for b in web.repo._bookmarks.items() if b[1] in web.repo] 646 i = [b for b in web.repo._bookmarks.items() if b[1] in web.repo]
647 sortkey = lambda b: (web.repo[b[1]].rev(), b[0]) 647 sortkey = lambda b: (web.repo[b[1]].rev(), b[0])
648 i = sorted(i, key=sortkey, reverse=True) 648 i = sorted(i, key=sortkey, reverse=True)
649 parity = paritygen(web.stripecount) 649 parity = paritygen(web.stripecount)
650 650
651 def entries(latestonly, **map): 651 def entries(context, latestonly):
652 t = i 652 t = i
653 if latestonly: 653 if latestonly:
654 t = i[:1] 654 t = i[:1]
655 for k, n in t: 655 for k, n in t:
656 yield {"parity": next(parity), 656 yield {"parity": next(parity),
665 665
666 return web.sendtemplate( 666 return web.sendtemplate(
667 'bookmarks', 667 'bookmarks',
668 node=hex(web.repo.changelog.tip()), 668 node=hex(web.repo.changelog.tip()),
669 lastchange=[{'date': web.repo[latestrev].date()}], 669 lastchange=[{'date': web.repo[latestrev].date()}],
670 entries=lambda **x: entries(latestonly=False, **x), 670 entries=templateutil.mappinggenerator(entries, args=(False,)),
671 latestentry=lambda **x: entries(latestonly=True, **x)) 671 latestentry=templateutil.mappinggenerator(entries, args=(True,)))
672 672
673 @webcommand('branches') 673 @webcommand('branches')
674 def branches(web): 674 def branches(web):
675 """ 675 """
676 /branches 676 /branches