comparison mercurial/hgweb/webcommands.py @ 38063:3c995af3066e

hgweb: wrap {entries}* of tags 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:18:28 +0900
parents 17f7b44367bb
children edacd831afab
comparison
equal deleted inserted replaced
38062:17f7b44367bb 38063:3c995af3066e
609 The ``tags`` template is rendered. 609 The ``tags`` template is rendered.
610 """ 610 """
611 i = list(reversed(web.repo.tagslist())) 611 i = list(reversed(web.repo.tagslist()))
612 parity = paritygen(web.stripecount) 612 parity = paritygen(web.stripecount)
613 613
614 def entries(notip, latestonly, **map): 614 def entries(context, notip, latestonly):
615 t = i 615 t = i
616 if notip: 616 if notip:
617 t = [(k, n) for k, n in i if k != "tip"] 617 t = [(k, n) for k, n in i if k != "tip"]
618 if latestonly: 618 if latestonly:
619 t = t[:1] 619 t = t[:1]
624 "node": hex(n)} 624 "node": hex(n)}
625 625
626 return web.sendtemplate( 626 return web.sendtemplate(
627 'tags', 627 'tags',
628 node=hex(web.repo.changelog.tip()), 628 node=hex(web.repo.changelog.tip()),
629 entries=lambda **x: entries(False, False, **x), 629 entries=templateutil.mappinggenerator(entries, args=(False, False)),
630 entriesnotip=lambda **x: entries(True, False, **x), 630 entriesnotip=templateutil.mappinggenerator(entries,
631 latestentry=lambda **x: entries(True, True, **x)) 631 args=(True, False)),
632 latestentry=templateutil.mappinggenerator(entries, args=(True, True)))
632 633
633 @webcommand('bookmarks') 634 @webcommand('bookmarks')
634 def bookmarks(web): 635 def bookmarks(web):
635 """ 636 """
636 /bookmarks 637 /bookmarks