changeset 38541:475f5f86eaed

files: automatically populate fields referenced from template
author Yuya Nishihara <yuya@tcha.org>
date Sun, 01 Jul 2018 21:55:37 +0900
parents 1e25782a7583
children 7ae0ea739770
files mercurial/cmdutil.py tests/test-manifest.t
diffstat 2 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Sun Jul 01 22:02:53 2018 +0900
+++ b/mercurial/cmdutil.py	Sun Jul 01 21:55:37 2018 +0900
@@ -2141,9 +2141,10 @@
 def files(ui, ctx, m, fm, fmt, subrepos):
     ret = 1
 
+    needsfctx = ui.verbose or {'size', 'flags'} & fm.datahint()
     for f in ctx.matches(m):
         fm.startitem()
-        if ui.verbose:
+        if needsfctx:
             fc = ctx[f]
             fm.write('size flags', '% 10d % 1s ', fc.size(), fc.flags())
         fm.data(abspath=f)
--- a/tests/test-manifest.t	Sun Jul 01 22:02:53 2018 +0900
+++ b/tests/test-manifest.t	Sun Jul 01 21:55:37 2018 +0900
@@ -37,6 +37,10 @@
   $ hg files -r . -X b
   a
   l
+  $ hg files -T '{path} {size} {flags}\n'
+  a 2 
+  b/a 2 x
+  l 1 l
 
   $ hg manifest -v
   644   a