# HG changeset patch # User Yuya Nishihara <y...@tcha.org> # Date 1521373899 -32400 # Sun Mar 18 20:51:39 2018 +0900 # Node ID 083ce2cf66079739b029f7e067a2e9339704c006 # Parent 41f4b8e798c8c46261aa4b6060f5aae4954c1b24 hgweb: fix search {entries} to not return results of template expansion
"{entries%changelogentry}" in raw/search.tmpl was utterly wrong because "{entries}" here was a generator yielding results of template expansion. That's why we have a weird hack in runmap(), which I'm going to get rid of. https://www.mercurial-scm.org/repo/hg/file/4.5.2/mercurial/templater.py#l469 We have two choices: a) drop "%changelogentry" from raw/search.tmpl b) fix "{entries}" to yield mappings I take (b) because that's what the other log-like "{entries}" do. The "entries" keyword is wrapped by mappinggenerator so "{entries}" without "%searchentry" still works. diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -36,6 +36,7 @@ from .. import ( scmutil, smartset, templater, + templateutil, ) from ..utils import ( @@ -287,7 +288,7 @@ def _search(web): LookupError): return MODE_KEYWORD, query - def changelist(**map): + def changelist(context): count = 0 for ctx in searchfunc[0](funcarg): @@ -303,7 +304,7 @@ def _search(web): 'changelogtag': showtags, 'files': files, }) - yield web.tmpl.generate('searchentry', lm) + yield lm if count >= revcount: break @@ -349,7 +350,7 @@ def _search(web): query=query, node=tip.hex(), symrev='tip', - entries=changelist, + entries=templateutil.mappinggenerator(changelist, name='searchentry'), archives=web.archivelist('tip'), morevars=morevars, lessvars=lessvars, diff --git a/mercurial/templates/gitweb/map b/mercurial/templates/gitweb/map --- a/mercurial/templates/gitweb/map +++ b/mercurial/templates/gitweb/map @@ -57,7 +57,6 @@ filenav = '{before%filenaventry}{after%f fileellipses = '...' changelogentry = changelogentry.tmpl -searchentry = changelogentry.tmpl changeset = changeset.tmpl manifest = manifest.tmpl direntry = ' diff --git a/mercurial/templates/gitweb/search.tmpl b/mercurial/templates/gitweb/search.tmpl --- a/mercurial/templates/gitweb/search.tmpl +++ b/mercurial/templates/gitweb/search.tmpl @@ -30,6 +30,6 @@ <div class="title">searching for {query|escape}</div> -{entries} +{entries%changelogentry} {footer} diff --git a/mercurial/templates/json/map b/mercurial/templates/json/map --- a/mercurial/templates/json/map +++ b/mercurial/templates/json/map @@ -18,9 +18,8 @@ lineentry = '\{ search = '\{ "node": {node|json}, "query": {query|json}, - "entries": [{join(entries%searchentry, ", ")}] + "entries": [{join(entries%changelistentry, ", ")}] }' -searchentry = '{changelistentry}' # changelog and shortlog are the same web API but with different # number of entries. changelog = changelist.tmpl diff --git a/mercurial/templates/monoblue/map b/mercurial/templates/monoblue/map --- a/mercurial/templates/monoblue/map +++ b/mercurial/templates/monoblue/map @@ -57,7 +57,6 @@ filenav = '{before%filenaventry}{after%f fileellipses = '...' changelogentry = changelogentry.tmpl -searchentry = changelogentry.tmpl changeset = changeset.tmpl manifest = manifest.tmpl direntry = ' diff --git a/mercurial/templates/monoblue/search.tmpl b/mercurial/templates/monoblue/search.tmpl --- a/mercurial/templates/monoblue/search.tmpl +++ b/mercurial/templates/monoblue/search.tmpl @@ -26,6 +26,6 @@ </div> <h2 class="no-link no-border">searching for {query|escape}</h2> - {entries} + {entries%changelogentry} {footer} diff --git a/mercurial/templates/paper/map b/mercurial/templates/paper/map --- a/mercurial/templates/paper/map +++ b/mercurial/templates/paper/map @@ -33,7 +33,6 @@ fileellipses = '...' diffstatlink = diffstat.tmpl diffstatnolink = diffstat.tmpl changelogentry = shortlogentry.tmpl -searchentry = shortlogentry.tmpl changeset = changeset.tmpl manifest = manifest.tmpl diff --git a/mercurial/templates/paper/search.tmpl b/mercurial/templates/paper/search.tmpl --- a/mercurial/templates/paper/search.tmpl +++ b/mercurial/templates/paper/search.tmpl @@ -49,7 +49,7 @@ Use {showunforcekw}</a> instead.')} </tr> </thead> <tbody class="stripes2"> -{entries} +{entries%changelogentry} </tbody> </table> diff --git a/mercurial/templates/raw/map b/mercurial/templates/raw/map --- a/mercurial/templates/raw/map +++ b/mercurial/templates/raw/map @@ -3,7 +3,6 @@ shortlog = "'raw' is not a browsable sty changelog = changelog.tmpl changelogentry = logentry.tmpl search = search.tmpl -searchentry = logentry.tmpl mimetype = 'text/plain; charset={encoding}' header = '' footer = '' diff --git a/mercurial/templates/spartan/map b/mercurial/templates/spartan/map --- a/mercurial/templates/spartan/map +++ b/mercurial/templates/spartan/map @@ -17,7 +17,6 @@ filenodelink = '<a href="{url|urlescape} filenolink = '{file|escape} ' fileellipses = '...' changelogentry = changelogentry.tmpl -searchentry = changelogentry.tmpl changeset = changeset.tmpl manifest = manifest.tmpl diff --git a/mercurial/templates/spartan/search.tmpl b/mercurial/templates/spartan/search.tmpl --- a/mercurial/templates/spartan/search.tmpl +++ b/mercurial/templates/spartan/search.tmpl @@ -24,7 +24,7 @@ search: </p> </form> -{entries} +{entries%changelogentry} <form> {sessionvars%hiddenformentry} _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel