diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py --- a/mercurial/templatekw.py +++ b/mercurial/templatekw.py @@ -582,6 +582,12 @@ def showreporoot(context, mapping): repo = context.resource(mapping, 'repo') return repo.root +@templatekeyword('size', requires={'fctx'}) +def showsize(context, mapping): + """Integer. Size of the current file in bytes. (EXPERIMENTAL)""" + fctx = context.resource(mapping, 'fctx') + return fctx.size() + @templatekeyword("successorssets", requires={'repo', 'ctx'}) def showsuccessorssets(context, mapping): """Returns a string of sets of successors for a changectx. Format used diff --git a/tests/test-template-keywords.t b/tests/test-template-keywords.t --- a/tests/test-template-keywords.t +++ b/tests/test-template-keywords.t @@ -787,6 +787,15 @@ Test file copies dict: $ hg log -r8 -C -T '{file_copies_switch % "{path} <- {source}\n"}' fourth <- second +Test file attributes: + + $ hg log -l1 -T '{files % "{pad(size, 3, left=True)} {path}\n"}' + a + 0 b + 7 fifth + fourth + 13 third + Test index keyword: $ hg log -l 2 -T '{index + 10}{files % " {index}:{file}"}\n'