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

Yuya Nishihara yuya at tcha.org
Tue Jul 3 09:26:07 EDT 2018


# HG changeset patch
# User Yuya Nishihara <yuya at 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

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


More information about the Mercurial-devel mailing list