# HG changeset patch # User Laura Médioni # Date 2016-06-06 13:14:11 # 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 --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -707,8 +707,8 @@ def summary(web, req, tmpl): 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 --git a/mercurial/templates/json/map b/mercurial/templates/json/map --- a/mercurial/templates/json/map +++ b/mercurial/templates/json/map @@ -96,7 +96,21 @@ branchentry = '\{ "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 --git a/tests/test-hgweb-json.t b/tests/test-hgweb-json.t --- a/tests/test-hgweb-json.t +++ b/tests/test-hgweb-json.t @@ -799,7 +799,241 @@ summary/ shows a summary of repository s $ 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