[PATCH 2 of 4] templates: add support for summary webcommand in json style
Anton Shestakov
engored at ya.ru
Wed Jun 15 08:36:01 EDT 2016
15.06.2016, 20:16, "Laura Médioni" <laura.medioni at logilab.fr>:
> # HG changeset patch
> # User Laura Médioni <laura.medioni at logilab.fr>
> # Date 1465218851 -7200
> # Mon Jun 06 15:14:11 2016 +0200
> # Node ID 8a068602ddea1d5021acd55b8d5d13c436900fda
> # Parent 21e855b309f5c1527938874ededc8168fa387c17
> templates: add support for summary webcommand in json style
>
> Change summary webcommand to yield each element of the sortlog instead of the
"shortlog"
> entire list.
> This makes generated json more readable since each entry can be formatted
(probably missing a blank line between the blocks)
> 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
> @@ -705,12 +705,12 @@ def summary(web, req, tmpl):
> l.append(tmpl(
> 'shortlogentry',
> 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)
> start = max(0, count - web.maxchanges)
> end = min(count, start + web.maxchanges)
> diff --git a/mercurial/templates/json/map b/mercurial/templates/json/map
> --- a/mercurial/templates/json/map
> +++ b/mercurial/templates/json/map
> @@ -83,11 +83,30 @@ branchentry = '\{
> "branch": {branch|utf8|json},
> "node": {node|json},
> "date": {date|json},
> "status": {status|json}
> }'
> -summary = '"not yet implemented"'
> +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}
> + }'
> +shortlogentry = '\{
> + "node": {node|json},
> + "date": {date|json},
> + "desc": {desc|utf8|json},
> + "author": {author|utf8|json}
> + }'
There are already changelistentry and changeset defined in json/map, and they expose a lot more info. Any reason not to use them?
This question applies to other patches in the series too.
More information about the Mercurial-devel
mailing list