Mercurial > hg
changeset 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 | 94494031f659 |
children | 06ae7a6daad0 |
files | mercurial/hgweb/webcommands.py tests/test-hgweb-empty.t |
diffstat | 2 files changed, 19 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hgweb/webcommands.py Thu Mar 31 18:09:09 2016 +0800 +++ b/mercurial/hgweb/webcommands.py Thu Mar 31 14:23:27 2016 +0800 @@ -606,13 +606,13 @@ The ``bookmarks`` template is rendered. """ i = [b for b in web.repo._bookmarks.items() if b[1] in web.repo] + i = sorted(i) parity = paritygen(web.stripecount) def entries(latestonly, **map): + t = i if latestonly: - t = [min(i)] - else: - t = sorted(i) + t = i[:1] for k, n in t: yield {"parity": parity.next(), "bookmark": k,
--- a/tests/test-hgweb-empty.t Thu Mar 31 18:09:09 2016 +0800 +++ b/tests/test-hgweb-empty.t Thu Mar 31 14:23:27 2016 +0800 @@ -461,4 +461,20 @@ </html> + $ (get-with-headers.py localhost:$HGPORT 'atom-bookmarks') + 200 Script output follows + + <?xml version="1.0" encoding="ascii"?> + <feed xmlns="http://www.w3.org/2005/Atom"> + <id>http://*:$HGPORT/</id> (glob) + <link rel="self" href="http://*:$HGPORT/atom-bookmarks"/> (glob) + <link rel="alternate" href="http://*:$HGPORT/bookmarks"/> (glob) + <title>test: bookmarks</title> + <summary>test bookmark history</summary> + <author><name>Mercurial SCM</name></author> + + + + </feed> + $ cd ..