# HG changeset patch # User Yuya Nishihara # Date 1538289317 -32400 # Node ID 47cb6750dea3d1b2d652c2b56d730acd1dab6311 # Parent f07ab9ddc0c0a5056ae363b6cd2e25ce4fb119eb annotate: rename {line_number} to {lineno} (BC) I think {lineno} looks more like a common template keyword. It isn't called a {line} to avoid conflicts with the element name of {lines} and the {_|splitlines} filter. https://www.mercurial-scm.org/wiki/GenericTemplatingPlan#Dictionary diff -r f07ab9ddc0c0 -r 47cb6750dea3 mercurial/commands.py --- a/mercurial/commands.py Sun Sep 30 15:15:27 2018 +0900 +++ b/mercurial/commands.py Sun Sep 30 15:35:17 2018 +0900 @@ -342,9 +342,10 @@ ('node', ' ', lambda x: hex(scmutil.binnode(x.fctx)), formathex), ('date', ' ', lambda x: x.fctx.date(), util.cachefunc(datefunc)), ('path', ' ', lambda x: x.fctx.path(), pycompat.bytestr), - ('line_number', ':', lambda x: x.lineno, pycompat.bytestr), + ('lineno', ':', lambda x: x.lineno, pycompat.bytestr), ] - opnamemap = {'rev': 'number', 'node': 'changeset', 'path': 'file'} + opnamemap = {'rev': 'number', 'node': 'changeset', 'path': 'file', + 'lineno': 'line_number'} if (not opts.get('user') and not opts.get('changeset') and not opts.get('date') and not opts.get('file')): diff -r f07ab9ddc0c0 -r 47cb6750dea3 tests/test-annotate.t --- a/tests/test-annotate.t Sun Sep 30 15:15:27 2018 +0900 +++ b/tests/test-annotate.t Sun Sep 30 15:35:17 2018 +0900 @@ -64,7 +64,7 @@ $ hg annotate -Tjson -cdfnul a [ { - "lines": [{"date": [1.0, 0], "line": "a\n", "line_number": 1, "node": "8435f90966e442695d2ded29fdade2bac5ad8065", "path": "a", "rev": 0, "user": "nobody"}], + "lines": [{"date": [1.0, 0], "line": "a\n", "lineno": 1, "node": "8435f90966e442695d2ded29fdade2bac5ad8065", "path": "a", "rev": 0, "user": "nobody"}], "path": "a" } ] @@ -74,12 +74,12 @@ $ hg annotate -T'{lines % "{rev} {node|shortest}: {line}"}' a 0 8435: a -'{line_number}' field should be populated as necessary +'{lineno}' field should be populated as necessary - $ hg annotate -T'{lines % "{rev}:{line_number}: {line}"}' a + $ hg annotate -T'{lines % "{rev}:{lineno}: {line}"}' a 0:1: a $ hg annotate -Ta a \ - > --config templates.a='"{lines % "{rev}:{line_number}: {line}"}"' + > --config templates.a='"{lines % "{rev}:{lineno}: {line}"}"' 0:1: a $ cat <>a diff -r f07ab9ddc0c0 -r 47cb6750dea3 tests/test-fastannotate-hg.t --- a/tests/test-fastannotate-hg.t Sun Sep 30 15:15:27 2018 +0900 +++ b/tests/test-fastannotate-hg.t Sun Sep 30 15:35:17 2018 +0900 @@ -77,7 +77,7 @@ $ hg annotate -Tjson -cdfnul a [ { - "lines": [{"date": [1.0, 0], "line": "a\n", "line_number": 1, "node": "8435f90966e442695d2ded29fdade2bac5ad8065", "path": "a", "rev": 0, "user": "nobody"}], + "lines": [{"date": [1.0, 0], "line": "a\n", "lineno": 1, "node": "8435f90966e442695d2ded29fdade2bac5ad8065", "path": "a", "rev": 0, "user": "nobody"}], "path": "a" } ]