comparison mercurial/hgweb/webcommands.py @ 37401:7d94fe3ea0ac

hgweb: fix summary {tags} and {shortlog} to not forcibly expand template The same sort of bug as the previous patch. In this case, JSON template was wrong.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 18 Mar 2018 21:35:43 +0900
parents 47aea60d114d
children 448f7ec247e2
comparison
equal deleted inserted replaced
37400:47aea60d114d 37401:7d94fe3ea0ac
711 711
712 The ``summary`` template is rendered. 712 The ``summary`` template is rendered.
713 """ 713 """
714 i = reversed(web.repo.tagslist()) 714 i = reversed(web.repo.tagslist())
715 715
716 def tagentries(**map): 716 def tagentries(context):
717 parity = paritygen(web.stripecount) 717 parity = paritygen(web.stripecount)
718 count = 0 718 count = 0
719 for k, n in i: 719 for k, n in i:
720 if k == "tip": # skip tip 720 if k == "tip": # skip tip
721 continue 721 continue
722 722
723 count += 1 723 count += 1
724 if count > 10: # limit to 10 tags 724 if count > 10: # limit to 10 tags
725 break 725 break
726 726
727 yield web.tmpl.generate('tagentry', { 727 yield {
728 'parity': next(parity), 728 'parity': next(parity),
729 'tag': k, 729 'tag': k,
730 'node': hex(n), 730 'node': hex(n),
731 'date': web.repo[n].date(), 731 'date': web.repo[n].date(),
732 }) 732 }
733 733
734 def bookmarks(**map): 734 def bookmarks(**map):
735 parity = paritygen(web.stripecount) 735 parity = paritygen(web.stripecount)
736 marks = [b for b in web.repo._bookmarks.items() if b[1] in web.repo] 736 marks = [b for b in web.repo._bookmarks.items() if b[1] in web.repo]
737 sortkey = lambda b: (web.repo[b[1]].rev(), b[0]) 737 sortkey = lambda b: (web.repo[b[1]].rev(), b[0])
740 yield {'parity': next(parity), 740 yield {'parity': next(parity),
741 'bookmark': k, 741 'bookmark': k,
742 'date': web.repo[n].date(), 742 'date': web.repo[n].date(),
743 'node': hex(n)} 743 'node': hex(n)}
744 744
745 def changelist(**map): 745 def changelist(context):
746 parity = paritygen(web.stripecount, offset=start - end) 746 parity = paritygen(web.stripecount, offset=start - end)
747 l = [] # build a list in forward order for efficiency 747 l = [] # build a list in forward order for efficiency
748 revs = [] 748 revs = []
749 if start < end: 749 if start < end:
750 revs = web.repo.changelog.revs(start, end - 1) 750 revs = web.repo.changelog.revs(start, end - 1)
751 for i in revs: 751 for i in revs:
752 ctx = web.repo[i] 752 ctx = web.repo[i]
753 lm = webutil.commonentry(web.repo, ctx) 753 lm = webutil.commonentry(web.repo, ctx)
754 lm['parity'] = next(parity) 754 lm['parity'] = next(parity)
755 l.append(web.tmpl.generate('shortlogentry', lm)) 755 l.append(lm)
756 756
757 for entry in reversed(l): 757 for entry in reversed(l):
758 yield entry 758 yield entry
759 759
760 tip = web.repo['tip'] 760 tip = web.repo['tip']
769 return web.sendtemplate( 769 return web.sendtemplate(
770 'summary', 770 'summary',
771 desc=desc, 771 desc=desc,
772 owner=get_contact(web.config) or 'unknown', 772 owner=get_contact(web.config) or 'unknown',
773 lastchange=tip.date(), 773 lastchange=tip.date(),
774 tags=tagentries, 774 tags=templateutil.mappinggenerator(tagentries, name='tagentry'),
775 bookmarks=bookmarks, 775 bookmarks=bookmarks,
776 branches=webutil.branchentries(web.repo, web.stripecount, 10), 776 branches=webutil.branchentries(web.repo, web.stripecount, 10),
777 shortlog=changelist, 777 shortlog=templateutil.mappinggenerator(changelist,
778 name='shortlogentry'),
778 node=tip.hex(), 779 node=tip.hex(),
779 symrev='tip', 780 symrev='tip',
780 archives=web.archivelist('tip'), 781 archives=web.archivelist('tip'),
781 labels=web.configlist('web', 'labels')) 782 labels=web.configlist('web', 'labels'))
782 783