diff 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
line wrap: on
line diff
--- a/mercurial/hgweb/webcommands.py	Thu Mar 31 14:23:27 2016 +0800
+++ b/mercurial/hgweb/webcommands.py	Thu Mar 31 15:22:06 2016 +0800
@@ -606,7 +606,8 @@
     The ``bookmarks`` template is rendered.
     """
     i = [b for b in web.repo._bookmarks.items() if b[1] in web.repo]
-    i = sorted(i)
+    sortkey = lambda b: (web.repo[b[1]].rev(), b[0])
+    i = sorted(i, key=sortkey, reverse=True)
     parity = paritygen(web.stripecount)
 
     def entries(latestonly, **map):
@@ -678,7 +679,9 @@
     def bookmarks(**map):
         parity = paritygen(web.stripecount)
         marks = [b for b in web.repo._bookmarks.items() if b[1] in web.repo]
-        for k, n in sorted(marks)[:10]:  # limit to 10 bookmarks
+        sortkey = lambda b: (web.repo[b[1]].rev(), b[0])
+        marks = sorted(marks, key=sortkey, reverse=True)
+        for k, n in marks[:10]:  # limit to 10 bookmarks
             yield {'parity': parity.next(),
                    'bookmark': k,
                    'date': web.repo[n].date(),