# HG changeset patch # User Anton Shestakov # Date 1456573998 -28800 # Node ID 3643b66d7f7135050e5e79a47084934995212aaa # Parent 5408e532e50a51974e2e8c9ff91792e56a387db4 hgweb: add index template to json/map This template allows showing the list of all repos in an hgweb instance (in hgwebdir mode) as json. The test has "lastchange" globbed because hgweb uses here file modification time and not the last commit time. diff -r 5408e532e50a -r 3643b66d7f71 mercurial/templates/json/map --- a/mercurial/templates/json/map Fri Feb 26 19:13:10 2016 +0000 +++ b/mercurial/templates/json/map Sat Feb 27 19:53:18 2016 +0800 @@ -172,3 +172,12 @@ }' filenodelink = '' filenolink = '' +index = '\{ + "entries": [{join(entries%indexentry, ", ")}] + }' +indexentry = '\{ + "name": {name|utf8|json}, + "description": {description|utf8|json}, + "contact": {contact|utf8|json}, + "lastchange": {lastchange|json} + }' diff -r 5408e532e50a -r 3643b66d7f71 tests/test-hgwebdir.t --- a/tests/test-hgwebdir.t Fri Feb 26 19:13:10 2016 +0000 +++ b/tests/test-hgwebdir.t Sat Feb 27 19:53:18 2016 +0800 @@ -100,6 +100,23 @@ /a/ /b/ + $ get-with-headers.py localhost:$HGPORT '?style=json' + 200 Script output follows + + { + "entries": [{ + "name": "a", + "description": "unknown", + "contact": "Foo Bar \u003cfoo.bar@example.com\u003e", + "lastchange": [*, *] (glob) + }, { + "name": "b", + "description": "unknown", + "contact": "Foo Bar \u003cfoo.bar@example.com\u003e", + "lastchange": [*, *] (glob) + }] + } (no-eol) + $ get-with-headers.py localhost:$HGPORT 'a/file/tip/a?style=raw' 200 Script output follows