[PATCH 3 of 5 V3] templates: add support for summary webcommand in json style

Anton Shestakov engored at ya.ru
Mon Jun 20 10:20:20 EDT 2016


20.06.2016, 17:25, "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 ad0ee6b2ebd8a442b308c3148fc18c2235aa7a88
> # Parent 7e920504e0310edef1f2565ba4cf7edd309c6434
> 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
> @@ -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
> @@ -94,11 +94,25 @@ branchentry = '\{
>    "branch": {branch|utf8|json},
>    "node": {node|json},
>    "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},
>    "date": {date|json},
>    "desc": {desc|utf8|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
> @@ -797,11 +797,245 @@ branches/ shows branches info
>  summary/ shows a summary of repository state
>
>    $ request json-summary
>    200 Script output follows
>
> - "not yet implemented"
> + {
> + "archives": [],

Can we have a list of archives in the test here? You can put something like this in the setup phase:

  $ echo "[web]" >> .hg/hgrc
  $ echo "allow_archive = gz bz2 zip" >> .hg/hgrc


More information about the Mercurial-devel mailing list