[PATCH 4 of 4] identify: change {parents} to a list of nodes (BC)
Yuya Nishihara
yuya at tcha.org
Fri Sep 14 10:00:24 EDT 2018
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1535771702 -32400
# Sat Sep 01 12:15:02 2018 +0900
# Node ID 1cf8eddbb91a4520d29b7c0c7e0c63bc44d0329a
# Parent 604fb529bf149da0637f355b00920a2b39e20e2d
identify: change {parents} to a list of nodes (BC)
This is a part of the name unification. {parents} is a list of nodes in
"hg log -Tjson" output. Since {rev} can be computed from (repo, node) pair,
we no longer need to put it to provide {rev} to user templates.
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
@@ -3058,13 +3058,8 @@ def identify(ui, repo, source=None, rev=
numoutput = ["%d" % p.rev() for p in parents]
output.append("%s%s" % ('+'.join(numoutput), dirty))
- fn = fm.nested('parents', tmpl='{rev}:{node|formatnode}', sep=' ')
- for p in parents:
- fn.startitem()
- fn.data(rev=p.rev())
- fn.data(node=p.hex())
- fn.context(ctx=p)
- fn.end()
+ fm.data(parents=fm.formatlist([fm.hexfunc(p.node())
+ for p in parents], name='node'))
else:
hexoutput = fm.hexfunc(ctx.node())
if default or id:
diff --git a/tests/test-identify.t b/tests/test-identify.t
--- a/tests/test-identify.t
+++ b/tests/test-identify.t
@@ -51,7 +51,7 @@ with options
"dirty": "",
"id": "cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b",
"node": "ffffffffffffffffffffffffffffffffffffffff",
- "parents": [{"node": "cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b", "rev": 0}],
+ "parents": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"],
"tags": ["tip"]
}
]
@@ -63,7 +63,7 @@ test template keywords and functions whi
$ hg id -T '{parents % "{rev} {node|shortest} {desc}\n"}'
0 cb9a a
$ hg id -T '{parents}\n'
- 0:cb9a9f314b8b
+ cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
test nested template: '{tags}'/'{node}' constants shouldn't override the
default keywords, but '{id}' persists because there's no default keyword
@@ -88,7 +88,7 @@ with modifications
"dirty": "+",
"id": "cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b+",
"node": "ffffffffffffffffffffffffffffffffffffffff",
- "parents": [{"node": "cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b", "rev": 0}],
+ "parents": ["cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b"],
"tags": ["tip"]
}
]
diff --git a/tests/test-merge-default.t b/tests/test-merge-default.t
--- a/tests/test-merge-default.t
+++ b/tests/test-merge-default.t
@@ -57,7 +57,7 @@ Should succeed:
"dirty": "+",
"id": "f25cbe84d8b320e298e7703f18a25a3959518c23+2d95304fed5d89bc9d70b2a0d02f0d567469c3ab+",
"node": "ffffffffffffffffffffffffffffffffffffffff",
- "parents": [{"node": "f25cbe84d8b320e298e7703f18a25a3959518c23", "rev": 4}, {"node": "2d95304fed5d89bc9d70b2a0d02f0d567469c3ab", "rev": 2}],
+ "parents": ["f25cbe84d8b320e298e7703f18a25a3959518c23", "2d95304fed5d89bc9d70b2a0d02f0d567469c3ab"],
"tags": ["tip"]
}
]
More information about the Mercurial-devel
mailing list