[PATCH 3 of 7] annotate: rename {line_number} to {lineno} (BC)

Yuya Nishihara yuya at tcha.org
Sun Sep 30 09:43:47 EDT 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1538289317 -32400
#      Sun Sep 30 15:35:17 2018 +0900
# Node ID bed3e1312e6e620e6dc642a060bba6c88ee6c287
# Parent  4ee07da344653b4bcfea8214c20e713cfd307d86
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 the {_|splitlines} filter.

https://www.mercurial-scm.org/wiki/GenericTemplatingPlan#Dictionary

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -342,9 +342,10 @@ def annotate(ui, repo, *pats, **opts):
              ('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 --git a/tests/test-annotate.t b/tests/test-annotate.t
--- a/tests/test-annotate.t
+++ b/tests/test-annotate.t
@@ -65,7 +65,7 @@ annotate (JSON)
   [
    {
     "path": "a",
-    "texts": [{"date": [1.0, 0], "line_number": 1, "node": "8435f90966e442695d2ded29fdade2bac5ad8065", "path": "a", "rev": 0, "text": "a\n", "user": "nobody"}]
+    "texts": [{"date": [1.0, 0], "lineno": 1, "node": "8435f90966e442695d2ded29fdade2bac5ad8065", "path": "a", "rev": 0, "text": "a\n", "user": "nobody"}]
    }
   ]
 
@@ -74,12 +74,12 @@ log-like templating
   $ hg annotate -T'{texts % "{rev} {node|shortest}: {text}"}' a
   0 8435: a
 
-'{line_number}' field should be populated as necessary
+'{lineno}' field should be populated as necessary
 
-  $ hg annotate -T'{texts % "{rev}:{line_number}: {text}"}' a
+  $ hg annotate -T'{texts % "{rev}:{lineno}: {text}"}' a
   0:1: a
   $ hg annotate -Ta a \
-  > --config templates.a='"{texts % "{rev}:{line_number}: {text}"}"'
+  > --config templates.a='"{texts % "{rev}:{lineno}: {text}"}"'
   0:1: a
 
   $ cat <<EOF >>a
diff --git a/tests/test-fastannotate-hg.t b/tests/test-fastannotate-hg.t
--- a/tests/test-fastannotate-hg.t
+++ b/tests/test-fastannotate-hg.t
@@ -78,7 +78,7 @@ annotate (JSON)
   [
    {
     "path": "a",
-    "texts": [{"date": [1.0, 0], "line_number": 1, "node": "8435f90966e442695d2ded29fdade2bac5ad8065", "path": "a", "rev": 0, "text": "a\n", "user": "nobody"}]
+    "texts": [{"date": [1.0, 0], "lineno": 1, "node": "8435f90966e442695d2ded29fdade2bac5ad8065", "path": "a", "rev": 0, "text": "a\n", "user": "nobody"}]
    }
   ]
 


More information about the Mercurial-devel mailing list