comparison mercurial/hgweb/webcommands.py @ 28710:ca0c0ca30c62

hgweb: sort bookmarks early Let's do the same thing that /tags page does. It gets sorted tags and then if it needs the latest only, it just slices the first item from the list. Since it's a slice and not a min(), it doesn't throw an exception if the list is empty. This fixes HTTP 500 error from issue5022.
author Anton Shestakov <av6@dwimlabs.net>
date Thu, 31 Mar 2016 14:23:27 +0800
parents d4419c01532b
children 06ae7a6daad0
comparison
equal deleted inserted replaced
28709:94494031f659 28710:ca0c0ca30c62
604 No arguments are accepted. 604 No arguments are accepted.
605 605
606 The ``bookmarks`` template is rendered. 606 The ``bookmarks`` template is rendered.
607 """ 607 """
608 i = [b for b in web.repo._bookmarks.items() if b[1] in web.repo] 608 i = [b for b in web.repo._bookmarks.items() if b[1] in web.repo]
609 i = sorted(i)
609 parity = paritygen(web.stripecount) 610 parity = paritygen(web.stripecount)
610 611
611 def entries(latestonly, **map): 612 def entries(latestonly, **map):
613 t = i
612 if latestonly: 614 if latestonly:
613 t = [min(i)] 615 t = i[:1]
614 else:
615 t = sorted(i)
616 for k, n in t: 616 for k, n in t:
617 yield {"parity": parity.next(), 617 yield {"parity": parity.next(),
618 "bookmark": k, 618 "bookmark": k,
619 "date": web.repo[n].date(), 619 "date": web.repo[n].date(),
620 "node": hex(n)} 620 "node": hex(n)}