comparison 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
comparison
equal deleted inserted replaced
32583:7bfa1b199972 32584:746e12a767b3
61 tmp/c_p 61 tmp/c_p
62 tmp/c_s 62 tmp/c_s
63 tmp/h_45116003780e 63 tmp/h_45116003780e
64 tmp/r_2 64 tmp/r_2
65 65
66 Test template output
67
68 $ hg --cwd tmp cat ../b ../c -T '== {path} ({abspath}) ==\n{data}'
69 == ../b (b) == (glob)
70 1
71 == ../c (c) == (glob)
72 3
73
74 $ hg cat b c -Tjson --output -
75 [
76 {
77 "abspath": "b",
78 "data": "1\n",
79 "path": "b"
80 },
81 {
82 "abspath": "c",
83 "data": "3\n",
84 "path": "c"
85 }
86 ]
87
88 $ hg cat b c -Tjson --output 'tmp/%p.json'
89 $ cat tmp/b.json
90 [
91 {
92 "abspath": "b",
93 "data": "1\n",
94 "path": "b"
95 }
96 ]
97 $ cat tmp/c.json
98 [
99 {
100 "abspath": "c",
101 "data": "3\n",
102 "path": "c"
103 }
104 ]
105
66 Test working directory 106 Test working directory
67 107
68 $ echo b-wdir > b 108 $ echo b-wdir > b
69 $ hg cat -r 'wdir()' b 109 $ hg cat -r 'wdir()' b
70 b-wdir 110 b-wdir