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