Patchwork [2,of,8] cat: 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 <e86b388c13242726e273.1530624365@mimosa>
Download mbox | patch
Permalink /patch/32581/
State Accepted
Headers show

Comments

Yuya Nishihara - July 3, 2018, 1:26 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1530449263 -32400
#      Sun Jul 01 21:47:43 2018 +0900
# Node ID e86b388c13242726e2734a92e3b5ebaf6f6e6e48
# Parent  65ebef5548276d61a95e949d8ef2fd1b82947bc6
cat: add support for log-like template keywords and functions

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2290,6 +2290,7 @@  def _updatecatformatter(fm, ctx, matcher
     if decode:
         data = ctx.repo().wwritedata(path, data)
     fm.startitem()
+    fm.context(ctx=ctx)
     fm.write('data', '%s', data)
     fm.data(abspath=path, path=matcher.rel(path))
 
diff --git a/tests/test-cat.t b/tests/test-cat.t
--- a/tests/test-cat.t
+++ b/tests/test-cat.t
@@ -65,10 +65,10 @@  Test fileset
 
 Test template output
 
-  $ hg --cwd tmp cat ../b ../c -T '== {path} ({abspath}) ==\n{data}'
-  == ../b (b) ==
+  $ hg --cwd tmp cat ../b ../c -T '== {path} ({abspath}) r{rev} ==\n{data}'
+  == ../b (b) r2 ==
   1
-  == ../c (c) ==
+  == ../c (c) r2 ==
   3
 
   $ hg cat b c -Tjson --output -