# HG changeset patch # User Laura Médioni # Date 1465218851 -7200 # Node ID e4b777fe1576fdb48db5b906878fdfffe3b5e3d9 # Parent 8bfe44494a0d662a1b1259c05e83fb094d050e1b templates: add support for summary webcommand in json style Change summary webcommand to yield each element of the shortlog instead of the entire list. This makes generated json more readable since each entry can be formatted separately, instead of returning all the shortlog content in a single string. diff -r 8bfe44494a0d -r e4b777fe1576 mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py Fri Jun 03 12:32:42 2016 +0200 +++ b/mercurial/hgweb/webcommands.py Mon Jun 06 15:14:11 2016 +0200 @@ -707,8 +707,8 @@ parity=next(parity), **webutil.commonentry(web.repo, ctx))) - l.reverse() - yield l + for entry in reversed(l): + yield entry tip = web.repo['tip'] count = len(web.repo) diff -r 8bfe44494a0d -r e4b777fe1576 mercurial/templates/json/map --- a/mercurial/templates/json/map Fri Jun 03 12:32:42 2016 +0200 +++ b/mercurial/templates/json/map Mon Jun 06 15:14:11 2016 +0200 @@ -96,7 +96,21 @@ "date": {date|json}, "status": {status|json} }' -summary = '"not yet implemented"' +shortlogentry = '{changelistentry}' +summary = '\{ + "node": {node|json}, + "lastchange": {lastchange|json}, + "bookmarks": [{join(bookmarks%bookmarkentry, ", ")}], + "branches": [{join(branches%branchentry, ", ")}], + "shortlog": [{join(shortlog%shortlogentry, ", ")}], + "tags": [{join(tags%tagentry, ", ")}], + "archives": [{join(archives%archiveentry, ", ")}] + }' +archiveentry = '\{ + "node": {node|json}, + "extension": {extension|json}, + "type": {type|json} + }' filediff = '\{ "path": {file|json}, "node": {node|json}, diff -r 8bfe44494a0d -r e4b777fe1576 tests/test-hgweb-json.t --- a/tests/test-hgweb-json.t Fri Jun 03 12:32:42 2016 +0200 +++ b/tests/test-hgweb-json.t Mon Jun 06 15:14:11 2016 +0200 @@ -799,7 +799,241 @@ $ request json-summary 200 Script output follows - "not yet implemented" + { + "archives": [], + "bookmarks": [ + { + "bookmark": "bookmark2", + "date": [ + 0.0, + 0 + ], + "node": "ceed296fe500c3fac9541e31dad860cb49c89e45" + }, + { + "bookmark": "bookmark1", + "date": [ + 0.0, + 0 + ], + "node": "8d7c456572acf3557e8ed8a07286b10c408bcec5" + } + ], + "branches": [ + { + "branch": "default", + "date": [ + 0.0, + 0 + ], + "node": "cc725e08502a79dd1eda913760fbe06ed7a9abc7", + "status": "open" + }, + { + "branch": "test-branch", + "date": [ + 0.0, + 0 + ], + "node": "ed66c30e87eb65337c05a4229efaa5f1d5285a90", + "status": "inactive" + } + ], + "lastchange": [ + 0.0, + 0 + ], + "node": "cc725e08502a79dd1eda913760fbe06ed7a9abc7", + "shortlog": [ + { + "bookmarks": [], + "branch": "default", + "date": [ + 0.0, + 0 + ], + "desc": "merge test-branch into default", + "node": "cc725e08502a79dd1eda913760fbe06ed7a9abc7", + "parents": [ + "ceed296fe500c3fac9541e31dad860cb49c89e45", + "ed66c30e87eb65337c05a4229efaa5f1d5285a90" + ], + "phase": "draft", + "tags": [ + "tip" + ], + "user": "test" + }, + { + "bookmarks": [], + "branch": "test-branch", + "date": [ + 0.0, + 0 + ], + "desc": "another commit in test-branch", + "node": "ed66c30e87eb65337c05a4229efaa5f1d5285a90", + "parents": [ + "6ab967a8ab3489227a83f80e920faa039a71819f" + ], + "phase": "draft", + "tags": [], + "user": "test" + }, + { + "bookmarks": [], + "branch": "test-branch", + "date": [ + 0.0, + 0 + ], + "desc": "create test branch", + "node": "6ab967a8ab3489227a83f80e920faa039a71819f", + "parents": [ + "06e557f3edf66faa1ccaba5dd8c203c21cc79f1e" + ], + "phase": "draft", + "tags": [], + "user": "test" + }, + { + "bookmarks": [ + "bookmark2" + ], + "branch": "default", + "date": [ + 0.0, + 0 + ], + "desc": "create tag2", + "node": "ceed296fe500c3fac9541e31dad860cb49c89e45", + "parents": [ + "f2890a05fea49bfaf9fb27ed5490894eba32da78" + ], + "phase": "draft", + "tags": [], + "user": "test" + }, + { + "bookmarks": [], + "branch": "default", + "date": [ + 0.0, + 0 + ], + "desc": "another commit to da/foo", + "node": "f2890a05fea49bfaf9fb27ed5490894eba32da78", + "parents": [ + "93a8ce14f89156426b7fa981af8042da53f03aa0" + ], + "phase": "draft", + "tags": [ + "tag2" + ], + "user": "test" + }, + { + "bookmarks": [], + "branch": "default", + "date": [ + 0.0, + 0 + ], + "desc": "create tag", + "node": "93a8ce14f89156426b7fa981af8042da53f03aa0", + "parents": [ + "78896eb0e102174ce9278438a95e12543e4367a7" + ], + "phase": "public", + "tags": [], + "user": "test" + }, + { + "bookmarks": [], + "branch": "default", + "date": [ + 0.0, + 0 + ], + "desc": "move foo", + "node": "78896eb0e102174ce9278438a95e12543e4367a7", + "parents": [ + "8d7c456572acf3557e8ed8a07286b10c408bcec5" + ], + "phase": "public", + "tags": [ + "tag1" + ], + "user": "test" + }, + { + "bookmarks": [ + "bookmark1" + ], + "branch": "default", + "date": [ + 0.0, + 0 + ], + "desc": "modify da/foo", + "node": "8d7c456572acf3557e8ed8a07286b10c408bcec5", + "parents": [ + "f8bbb9024b10f93cdbb8d940337398291d40dea8" + ], + "phase": "public", + "tags": [], + "user": "test" + }, + { + "bookmarks": [], + "branch": "default", + "date": [ + 0.0, + 0 + ], + "desc": "modify foo", + "node": "f8bbb9024b10f93cdbb8d940337398291d40dea8", + "parents": [ + "06e557f3edf66faa1ccaba5dd8c203c21cc79f1e" + ], + "phase": "public", + "tags": [], + "user": "test" + }, + { + "bookmarks": [], + "branch": "default", + "date": [ + 0.0, + 0 + ], + "desc": "initial", + "node": "06e557f3edf66faa1ccaba5dd8c203c21cc79f1e", + "parents": [], + "phase": "public", + "tags": [], + "user": "test" + } + ], + "tags": [ + { + "date": [ + 0.0, + 0 + ], + "node": "f2890a05fea49bfaf9fb27ed5490894eba32da78", + "tag": "tag2" + }, + { + "date": [ + 0.0, + 0 + ], + "node": "78896eb0e102174ce9278438a95e12543e4367a7", + "tag": "tag1" + } + ] + } filediff/{revision}/{path} shows changes to a file in a revision