# HG changeset patch # User Yuya Nishihara # Date 1525316676 -32400 # Node ID 57dc72b56b6c4262c9f4e484078a7cd9980f15d3 # Parent 31ed65f9c5adf1e00c7d794585eed0fed334c33d annotate: automatically populate fields referenced from template If '{line_number}' is in the template, we'll probably need it. No --line-number option should be required in such cases. diff -r 31ed65f9c5ad -r 57dc72b56b6c mercurial/commands.py --- a/mercurial/commands.py Thu May 03 12:10:47 2018 +0900 +++ b/mercurial/commands.py Thu May 03 12:04:36 2018 +0900 @@ -359,11 +359,12 @@ else: def makefunc(get, fmt): return get + datahint = rootfm.datahint() funcmap = [(makefunc(get, fmt), sep) for fn, sep, get, fmt in opmap - if opts.get(opnamemap.get(fn, fn))] + if opts.get(opnamemap.get(fn, fn)) or fn in datahint] funcmap[0] = (funcmap[0][0], '') # no separator in front of first column fields = ' '.join(fn for fn, sep, get, fmt in opmap - if opts.get(opnamemap.get(fn, fn))) + if opts.get(opnamemap.get(fn, fn)) or fn in datahint) def bad(x, y): raise error.Abort("%s: %s" % (x, y)) diff -r 31ed65f9c5ad -r 57dc72b56b6c tests/test-annotate.t --- a/tests/test-annotate.t Thu May 03 12:10:47 2018 +0900 +++ b/tests/test-annotate.t Thu May 03 12:04:36 2018 +0900 @@ -76,6 +76,11 @@ $ hg annotate -T'{lines % "{rev} {node|shortest}: {line}"}' a 0 8435: a +'{line_number}' field should be populated as necessary + + $ hg annotate -T'{lines % "{rev}:{line_number}: {line}"}' a + 0:1: a + $ cat <>a > a > a