From patchwork Tue Jul 3 13:26:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3, of, 8] grep: add support for log-like template keywords and functions From: Yuya Nishihara X-Patchwork-Id: 32582 Message-Id: <32caef1aff8134dc1ca3.1530624366@mimosa> To: mercurial-devel@mercurial-scm.org Date: Tue, 03 Jul 2018 22:26:06 +0900 # HG changeset patch # User Yuya Nishihara # Date 1530450173 -32400 # Sun Jul 01 22:02:53 2018 +0900 # Node ID 32caef1aff8134dc1ca37a7da9129fc865a4329d # Parent e86b388c13242726e2734a92e3b5ebaf6f6e6e48 grep: add support for log-like template keywords and functions diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2634,6 +2634,7 @@ def grep(ui, repo, pattern, *pats, **opt iter = [('', l) for l in states] for change, l in iter: fm.startitem() + fm.context(ctx=ctx) fm.data(node=fm.hexfunc(scmutil.binnode(ctx))) cols = [ diff --git a/tests/test-grep.t b/tests/test-grep.t --- a/tests/test-grep.t +++ b/tests/test-grep.t @@ -53,6 +53,11 @@ simple templated port:4:vaportight port:4:import/export + $ hg grep port -T '{file}:{tags}:{texts}\n' + port:tip:export + port:tip:vaportight + port:tip:import/export + simple JSON (no "change" field) $ hg grep -Tjson port