Mercurial > public > mercurial-scm > hg
diff tests/test-cat.t @ 32584:746e12a767b3
cat: add formatter support
This is an example showing how formatter can handle the --output option.
git subrepo isn't supported for now.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 25 May 2017 21:53:44 +0900 |
parents | bd5e9647f646 |
children | 8154119ed236 |
line wrap: on
line diff
--- a/tests/test-cat.t Sat May 27 17:58:36 2017 +0900 +++ b/tests/test-cat.t Thu May 25 21:53:44 2017 +0900 @@ -63,6 +63,46 @@ tmp/h_45116003780e tmp/r_2 +Test template output + + $ hg --cwd tmp cat ../b ../c -T '== {path} ({abspath}) ==\n{data}' + == ../b (b) == (glob) + 1 + == ../c (c) == (glob) + 3 + + $ hg cat b c -Tjson --output - + [ + { + "abspath": "b", + "data": "1\n", + "path": "b" + }, + { + "abspath": "c", + "data": "3\n", + "path": "c" + } + ] + + $ hg cat b c -Tjson --output 'tmp/%p.json' + $ cat tmp/b.json + [ + { + "abspath": "b", + "data": "1\n", + "path": "b" + } + ] + $ cat tmp/c.json + [ + { + "abspath": "c", + "data": "3\n", + "path": "c" + } + ] + Test working directory $ echo b-wdir > b