Mercurial > public > mercurial-scm > hg
diff tests/test-command-template.t @ 31928:277b3e2d711b
templater: add shorthand for building a dict like {"key": key}
Like field init shorthand of Rust. This is convenient for building a JSON
object from selected keywords.
This means dict() won't support Python-like dict(iterable) syntax because
it's ambiguous. Perhaps it could be implemented as 'mapdict(xs % (k, v))'.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 03 Apr 2017 23:13:49 +0900 |
parents | 2abc556dbe92 |
children | 2ab7578e685b |
line wrap: on
line diff
--- a/tests/test-command-template.t Sat Apr 08 23:33:32 2017 +0900 +++ b/tests/test-command-template.t Mon Apr 03 23:13:49 2017 +0900 @@ -3424,6 +3424,21 @@ $ hg log -r 0 -T '{dict()|json}\n' {} + $ hg log -r 0 -T '{dict(rev, node=node|short)}\n' + rev=0 node=f7769ec2ab97 + $ hg log -r 0 -T '{dict(rev, node|short)}\n' + rev=0 node=f7769ec2ab97 + + $ hg log -r 0 -T '{dict(rev, rev=rev)}\n' + hg: parse error: duplicated dict key 'rev' inferred + [255] + $ hg log -r 0 -T '{dict(node, node|short)}\n' + hg: parse error: duplicated dict key 'node' inferred + [255] + $ hg log -r 0 -T '{dict(1 + 2)}' + hg: parse error: dict key cannot be inferred + [255] + $ hg log -r 0 -T '{dict(x=rev, x=node)}' hg: parse error: dict got multiple values for keyword argument 'x' [255]