Patchwork [4,of,8] files: automatically populate fields referenced from template

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

Comments

Yuya Nishihara - July 3, 2018, 1:26 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1530449737 -32400
#      Sun Jul 01 21:55:37 2018 +0900
# Node ID 9afe500ac808e74f2d1535ffc44d089b7cd729e5
# Parent  32caef1aff8134dc1ca37a7da9129fc865a4329d
files: automatically populate fields referenced from template

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2141,9 +2141,10 @@  def forget(ui, repo, match, prefix, expl
 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)
diff --git a/tests/test-manifest.t b/tests/test-manifest.t
--- a/tests/test-manifest.t
+++ b/tests/test-manifest.t
@@ -37,6 +37,10 @@  The next call is expected to return noth
   $ 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