##// END OF EJS Templates
cat: test output path behvaior when target path does not exist...
Ryan McElroy -
r35009:8154119e default
parent child Browse files
Show More
@@ -1,121 +1,132 b''
1 $ hg init
1 $ hg init
2 $ echo 0 > a
2 $ echo 0 > a
3 $ echo 0 > b
3 $ echo 0 > b
4 $ hg ci -A -m m
4 $ hg ci -A -m m
5 adding a
5 adding a
6 adding b
6 adding b
7 $ hg rm a
7 $ hg rm a
8 $ hg cat a
8 $ hg cat a
9 0
9 0
10 $ hg cat --decode a # more tests in test-encode
10 $ hg cat --decode a # more tests in test-encode
11 0
11 0
12 $ echo 1 > b
12 $ echo 1 > b
13 $ hg ci -m m
13 $ hg ci -m m
14 $ echo 2 > b
14 $ echo 2 > b
15 $ hg cat -r 0 a
15 $ hg cat -r 0 a
16 0
16 0
17 $ hg cat -r 0 b
17 $ hg cat -r 0 b
18 0
18 0
19 $ hg cat -r 1 a
19 $ hg cat -r 1 a
20 a: no such file in rev 7040230c159c
20 a: no such file in rev 7040230c159c
21 [1]
21 [1]
22 $ hg cat -r 1 b
22 $ hg cat -r 1 b
23 1
23 1
24
24
25 Test multiple files
25 Test multiple files
26
26
27 $ echo 3 > c
27 $ echo 3 > c
28 $ hg ci -Am addmore c
28 $ hg ci -Am addmore c
29 $ hg cat b c
29 $ hg cat b c
30 1
30 1
31 3
31 3
32 $ hg cat .
32 $ hg cat .
33 1
33 1
34 3
34 3
35 $ hg cat . c
35 $ hg cat . c
36 1
36 1
37 3
37 3
38
38
39 Test fileset
39 Test fileset
40
40
41 $ hg cat 'set:not(b) or a'
41 $ hg cat 'set:not(b) or a'
42 3
42 3
43 $ hg cat 'set:c or b'
43 $ hg cat 'set:c or b'
44 1
44 1
45 3
45 3
46
46
47 $ mkdir tmp
47 $ mkdir tmp
48 $ hg cat --output tmp/HH_%H c
48 $ hg cat --output tmp/HH_%H c
49 $ hg cat --output tmp/RR_%R c
49 $ hg cat --output tmp/RR_%R c
50 $ hg cat --output tmp/h_%h c
50 $ hg cat --output tmp/h_%h c
51 $ hg cat --output tmp/r_%r c
51 $ hg cat --output tmp/r_%r c
52 $ hg cat --output tmp/%s_s c
52 $ hg cat --output tmp/%s_s c
53 $ hg cat --output tmp/%d%%_d c
53 $ hg cat --output tmp/%d%%_d c
54 $ hg cat --output tmp/%p_p c
54 $ hg cat --output tmp/%p_p c
55 $ hg log -r . --template "{rev}: {node|short}\n"
55 $ hg log -r . --template "{rev}: {node|short}\n"
56 2: 45116003780e
56 2: 45116003780e
57 $ find tmp -type f | sort
57 $ find tmp -type f | sort
58 tmp/.%_d
58 tmp/.%_d
59 tmp/HH_45116003780e3678b333fb2c99fa7d559c8457e9
59 tmp/HH_45116003780e3678b333fb2c99fa7d559c8457e9
60 tmp/RR_2
60 tmp/RR_2
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
66 Test template output
67
67
68 $ hg --cwd tmp cat ../b ../c -T '== {path} ({abspath}) ==\n{data}'
68 $ hg --cwd tmp cat ../b ../c -T '== {path} ({abspath}) ==\n{data}'
69 == ../b (b) == (glob)
69 == ../b (b) == (glob)
70 1
70 1
71 == ../c (c) == (glob)
71 == ../c (c) == (glob)
72 3
72 3
73
73
74 $ hg cat b c -Tjson --output -
74 $ hg cat b c -Tjson --output -
75 [
75 [
76 {
76 {
77 "abspath": "b",
77 "abspath": "b",
78 "data": "1\n",
78 "data": "1\n",
79 "path": "b"
79 "path": "b"
80 },
80 },
81 {
81 {
82 "abspath": "c",
82 "abspath": "c",
83 "data": "3\n",
83 "data": "3\n",
84 "path": "c"
84 "path": "c"
85 }
85 }
86 ]
86 ]
87
87
88 $ hg cat b c -Tjson --output 'tmp/%p.json'
88 $ hg cat b c -Tjson --output 'tmp/%p.json'
89 $ cat tmp/b.json
89 $ cat tmp/b.json
90 [
90 [
91 {
91 {
92 "abspath": "b",
92 "abspath": "b",
93 "data": "1\n",
93 "data": "1\n",
94 "path": "b"
94 "path": "b"
95 }
95 }
96 ]
96 ]
97 $ cat tmp/c.json
97 $ cat tmp/c.json
98 [
98 [
99 {
99 {
100 "abspath": "c",
100 "abspath": "c",
101 "data": "3\n",
101 "data": "3\n",
102 "path": "c"
102 "path": "c"
103 }
103 }
104 ]
104 ]
105
105
106 Test working directory
106 Test working directory
107
107
108 $ echo b-wdir > b
108 $ echo b-wdir > b
109 $ hg cat -r 'wdir()' b
109 $ hg cat -r 'wdir()' b
110 b-wdir
110 b-wdir
111
111
112 Environment variables are not visible by default
112 Environment variables are not visible by default
113
113
114 $ PATTERN='t4' hg log -r '.' -T "{ifcontains('PATTERN', envvars, 'yes', 'no')}\n"
114 $ PATTERN='t4' hg log -r '.' -T "{ifcontains('PATTERN', envvars, 'yes', 'no')}\n"
115 no
115 no
116
116
117 Environment variable visibility can be explicit
117 Environment variable visibility can be explicit
118
118
119 $ PATTERN='t4' hg log -r '.' -T "{envvars % '{key} -> {value}\n'}" \
119 $ PATTERN='t4' hg log -r '.' -T "{envvars % '{key} -> {value}\n'}" \
120 > --config "experimental.exportableenviron=PATTERN"
120 > --config "experimental.exportableenviron=PATTERN"
121 PATTERN -> t4
121 PATTERN -> t4
122
123 Test behavior of output when directory structure does not already exist
124
125 $ mkdir foo
126 $ echo a > foo/a
127 $ hg add foo/a
128 $ hg commit -qm "add foo/a"
129 $ mkdir output
130 $ hg cat --output "output/%p" foo/a
131 abort: No such file or directory: output/foo/a
132 [255]
General Comments 0
You need to be logged in to leave comments. Login now