[PATCH 4 of 5 V2] templates: add support for search webcommand in json style

Yuya Nishihara yuya at tcha.org
Mon Jun 20 10:55:03 EDT 2016


On Mon, 20 Jun 2016 21:41:53 +0800, Anton Shestakov wrote:
> 20.06.2016, 21:25, "Yuya Nishihara" <yuya at tcha.org>:
> > On Mon, 20 Jun 2016 10:49:13 +0200, Laura Médioni wrote:  
> >>  On 06/16/2016 12:07 PM, Anton Shestakov wrote:  
> >>  > 15.06.2016, 22:48, "Laura Médioni" <laura.medioni at logilab.fr>:  
> >>  >> # HG changeset patch
> >>  >> # User Laura Médioni <laura.medioni at logilab.fr>
> >>  >> # Date 1465547502 -7200
> >>  >> # Fri Jun 10 10:31:42 2016 +0200
> >>  >> # Node ID 33c362973b2ab07b2e20d6818b7e72473e682fd4
> >>  >> # Parent f4aad36209542e836d91477ce330b2dbb5181443
> >>  >> templates: add support for search webcommand in json style
> >>  >>
> >>  >> diff --git a/mercurial/templates/json/map b/mercurial/templates/json/map
> >>  >> --- a/mercurial/templates/json/map
> >>  >> +++ b/mercurial/templates/json/map
> >>  >> @@ -13,11 +13,16 @@ filerevision = '\{
> >>  >> "lines": [{join(text%lineentry, ", ")}]
> >>  >> }'
> >>  >> lineentry = '\{
> >>  >> "line": {line|json}
> >>  >> }'
> >>  >> -search = '"not yet implemented"'
> >>  >> +search = '\{
> >>  >> + "node": {node|json},
> >>  >> + "query": {query|json},
> >>  >> + "entries": [{join(entries%searchentry, ", ")}]
> >>  >> + }'
> >>  >> +searchentry = '{changeset}'  
> >>  > It's better to use a template directly for clarity, since searchentry doesn't do anything on its own.  
> >>
> >>  If I directly write something like " "entries":
> >>  [{join(entries%changelistentry, ", ")}] ", I got a json decoding error.
> >>  I guess that is because the template is named "searchentry".  
> >
> > Yep, you can write it as 'entries % changeset' or 'entries % "{changeset}"',
> > but still "searchentry" key is required.  
> 
> Looks like it's because of a changelist function in hgweb/webcommands.py (line 280-ish). It does "yield tmpl('searchentry', ..." instead of just "yield {'key': 'value'}" like most of the generators in that file. This way it allows writing just "{entries}" instead of "{entries%searchentry}". A shortcut that sort of backfires now.
> 
> I assume there is no easy way to not require "searchentry" template to exist and maintain compatibility with custom hgweb themes at the same time.

templatekw._hybrid might help, but it wouldn't be easy task.


More information about the Mercurial-devel mailing list