# HG changeset patch # User FUJIWARA Katsunori # Date 1498416006 -32400 # Node ID 9062458febcab017e03c95b79c69d229e6ee29e8 # Parent 7f569ce3021659eb66428978c1892c974f5c9789 keyword: restore kwtemplater.match at the end of wrapped webcommands Before this patch, kwweb_skip doesn't restore kwtemplater.match after wrapped webcommands. This suppresses keyword expansion at wrapped webcommands. Typical usecase of this issue is "file" webcommand after annotate, changeset, filediff or so on. To ensure kwtemplater.match=util.never while original webcommand running, this patch makes kwweb_skip yield values returned by it, because it returns generator object. diff -r 7f569ce30216 -r 9062458febca hgext/keyword.py --- a/hgext/keyword.py Mon Jun 26 03:38:12 2017 +0900 +++ b/hgext/keyword.py Mon Jun 26 03:40:06 2017 +0900 @@ -675,8 +675,13 @@ def kwweb_skip(orig, web, req, tmpl): '''Wraps webcommands.x turning off keyword expansion.''' + origmatch = kwt.match kwt.match = util.never - return orig(web, req, tmpl) + try: + for chunk in orig(web, req, tmpl): + yield chunk + finally: + kwt.match = origmatch def kw_amend(orig, ui, repo, commitfunc, old, extra, pats, opts): '''Wraps cmdutil.amend expanding keywords after amend.''' diff -r 7f569ce30216 -r 9062458febca tests/test-keyword.t --- a/tests/test-keyword.t Mon Jun 26 03:38:12 2017 +0900 +++ b/tests/test-keyword.t Mon Jun 26 03:40:06 2017 +0900 @@ -1019,6 +1019,7 @@ hg serve - expand with hgweb file - no expansion with hgweb annotate/changeset/filediff + - expand with hgweb file, again - check errors $ hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log @@ -1078,6 +1079,18 @@ + +(check "kwweb_skip"-ed webcommand doesn't suppress expanding keywords +at subsequent webcommands) + + $ get-with-headers.py localhost:$HGPORT 'file/tip/a/?style=raw' + 200 Script output follows + + expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $ + do not process $Id: + xxx $ + $Xinfo: User Name : firstline $ + $ cat errors.log #endif