comparison mercurial/hgweb/webcommands.py @ 28711:06ae7a6daad0

hgweb: sort bookmarks in revlog order of their nodes Changes, branches and tags are already in revlog order on /summary, /branches and /tags, let's now make bookmarks be sorted by the same principle. It's more helpful to show more "recent" bookmarks on top. This will affect /bookmarks page in all styles, including atom, rss and raw, and also /summary page. Bookmarks are sorted using a (revision number, bookmark name) tuple.
author Anton Shestakov <av6@dwimlabs.net>
date Thu, 31 Mar 2016 15:22:06 +0800
parents ca0c0ca30c62
children 80e922479891
comparison
equal deleted inserted replaced
28710:ca0c0ca30c62 28711:06ae7a6daad0
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 sortkey = lambda b: (web.repo[b[1]].rev(), b[0])
610 i = sorted(i, key=sortkey, reverse=True)
610 parity = paritygen(web.stripecount) 611 parity = paritygen(web.stripecount)
611 612
612 def entries(latestonly, **map): 613 def entries(latestonly, **map):
613 t = i 614 t = i
614 if latestonly: 615 if latestonly:
676 date=web.repo[n].date()) 677 date=web.repo[n].date())
677 678
678 def bookmarks(**map): 679 def bookmarks(**map):
679 parity = paritygen(web.stripecount) 680 parity = paritygen(web.stripecount)
680 marks = [b for b in web.repo._bookmarks.items() if b[1] in web.repo] 681 marks = [b for b in web.repo._bookmarks.items() if b[1] in web.repo]
681 for k, n in sorted(marks)[:10]: # limit to 10 bookmarks 682 sortkey = lambda b: (web.repo[b[1]].rev(), b[0])
683 marks = sorted(marks, key=sortkey, reverse=True)
684 for k, n in marks[:10]: # limit to 10 bookmarks
682 yield {'parity': parity.next(), 685 yield {'parity': parity.next(),
683 'bookmark': k, 686 'bookmark': k,
684 'date': web.repo[n].date(), 687 'date': web.repo[n].date(),
685 'node': hex(n)} 688 'node': hex(n)}
686 689