Patchwork [3,of,8] grep: add support for log-like template keywords and functions

login
register
mail settings
Submitter Yuya Nishihara
Date July 3, 2018, 1:26 p.m.
Message ID <32caef1aff8134dc1ca3.1530624366@mimosa>
Download mbox | patch
Permalink /patch/32582/
State Accepted
Headers show

Comments

Yuya Nishihara - July 3, 2018, 1:26 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# 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

Patch

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