##// END OF EJS Templates
test-fileset: remove bashism, use test instead of '[[ ]]'...
Yuya Nishihara -
r25587:49fb24f7 default
parent child Browse files
Show More
@@ -1,306 +1,306 b''
1 $ fileset() {
1 $ fileset() {
2 > hg debugfileset "$@"
2 > hg debugfileset "$@"
3 > }
3 > }
4
4
5 $ hg init repo
5 $ hg init repo
6 $ cd repo
6 $ cd repo
7 $ echo a > a1
7 $ echo a > a1
8 $ echo a > a2
8 $ echo a > a2
9 $ echo b > b1
9 $ echo b > b1
10 $ echo b > b2
10 $ echo b > b2
11 $ hg ci -Am addfiles
11 $ hg ci -Am addfiles
12 adding a1
12 adding a1
13 adding a2
13 adding a2
14 adding b1
14 adding b1
15 adding b2
15 adding b2
16
16
17 Test operators and basic patterns
17 Test operators and basic patterns
18
18
19 $ fileset -v a1
19 $ fileset -v a1
20 ('symbol', 'a1')
20 ('symbol', 'a1')
21 a1
21 a1
22 $ fileset -v 'a*'
22 $ fileset -v 'a*'
23 ('symbol', 'a*')
23 ('symbol', 'a*')
24 a1
24 a1
25 a2
25 a2
26 $ fileset -v '"re:a\d"'
26 $ fileset -v '"re:a\d"'
27 ('string', 're:a\\d')
27 ('string', 're:a\\d')
28 a1
28 a1
29 a2
29 a2
30 $ fileset -v 'a1 or a2'
30 $ fileset -v 'a1 or a2'
31 (or
31 (or
32 ('symbol', 'a1')
32 ('symbol', 'a1')
33 ('symbol', 'a2'))
33 ('symbol', 'a2'))
34 a1
34 a1
35 a2
35 a2
36 $ fileset 'a1 | a2'
36 $ fileset 'a1 | a2'
37 a1
37 a1
38 a2
38 a2
39 $ fileset 'a* and "*1"'
39 $ fileset 'a* and "*1"'
40 a1
40 a1
41 $ fileset 'a* & "*1"'
41 $ fileset 'a* & "*1"'
42 a1
42 a1
43 $ fileset 'not (r"a*")'
43 $ fileset 'not (r"a*")'
44 b1
44 b1
45 b2
45 b2
46 $ fileset '! ("a*")'
46 $ fileset '! ("a*")'
47 b1
47 b1
48 b2
48 b2
49 $ fileset 'a* - a1'
49 $ fileset 'a* - a1'
50 a2
50 a2
51 $ fileset 'a_b'
51 $ fileset 'a_b'
52
52
53 Test files status
53 Test files status
54
54
55 $ rm a1
55 $ rm a1
56 $ hg rm a2
56 $ hg rm a2
57 $ echo b >> b2
57 $ echo b >> b2
58 $ hg cp b1 c1
58 $ hg cp b1 c1
59 $ echo c > c2
59 $ echo c > c2
60 $ echo c > c3
60 $ echo c > c3
61 $ cat > .hgignore <<EOF
61 $ cat > .hgignore <<EOF
62 > \.hgignore
62 > \.hgignore
63 > 2$
63 > 2$
64 > EOF
64 > EOF
65 $ fileset 'modified()'
65 $ fileset 'modified()'
66 b2
66 b2
67 $ fileset 'added()'
67 $ fileset 'added()'
68 c1
68 c1
69 $ fileset 'removed()'
69 $ fileset 'removed()'
70 a2
70 a2
71 $ fileset 'deleted()'
71 $ fileset 'deleted()'
72 a1
72 a1
73 $ fileset 'unknown()'
73 $ fileset 'unknown()'
74 c3
74 c3
75 $ fileset 'ignored()'
75 $ fileset 'ignored()'
76 .hgignore
76 .hgignore
77 c2
77 c2
78 $ fileset 'hgignore()'
78 $ fileset 'hgignore()'
79 a2
79 a2
80 b2
80 b2
81 $ fileset 'clean()'
81 $ fileset 'clean()'
82 b1
82 b1
83 $ fileset 'copied()'
83 $ fileset 'copied()'
84 c1
84 c1
85
85
86 Test files properties
86 Test files properties
87
87
88 >>> file('bin', 'wb').write('\0a')
88 >>> file('bin', 'wb').write('\0a')
89 $ fileset 'binary()'
89 $ fileset 'binary()'
90 $ fileset 'binary() and unknown()'
90 $ fileset 'binary() and unknown()'
91 bin
91 bin
92 $ echo '^bin$' >> .hgignore
92 $ echo '^bin$' >> .hgignore
93 $ fileset 'binary() and ignored()'
93 $ fileset 'binary() and ignored()'
94 bin
94 bin
95 $ hg add bin
95 $ hg add bin
96 $ fileset 'binary()'
96 $ fileset 'binary()'
97 bin
97 bin
98
98
99 $ fileset 'grep("b{1}")'
99 $ fileset 'grep("b{1}")'
100 b2
100 b2
101 c1
101 c1
102 b1
102 b1
103 $ fileset 'grep("missingparens(")'
103 $ fileset 'grep("missingparens(")'
104 hg: parse error: invalid match pattern: unbalanced parenthesis
104 hg: parse error: invalid match pattern: unbalanced parenthesis
105 [255]
105 [255]
106
106
107 #if execbit
107 #if execbit
108 $ chmod +x b2
108 $ chmod +x b2
109 $ fileset 'exec()'
109 $ fileset 'exec()'
110 b2
110 b2
111 #endif
111 #endif
112
112
113 #if symlink
113 #if symlink
114 $ ln -s b2 b2link
114 $ ln -s b2 b2link
115 $ fileset 'symlink() and unknown()'
115 $ fileset 'symlink() and unknown()'
116 b2link
116 b2link
117 $ hg add b2link
117 $ hg add b2link
118 #endif
118 #endif
119
119
120 #if no-windows
120 #if no-windows
121 $ echo foo > con.xml
121 $ echo foo > con.xml
122 $ fileset 'not portable()'
122 $ fileset 'not portable()'
123 con.xml
123 con.xml
124 $ hg --config ui.portablefilenames=ignore add con.xml
124 $ hg --config ui.portablefilenames=ignore add con.xml
125 #endif
125 #endif
126
126
127 >>> file('1k', 'wb').write(' '*1024)
127 >>> file('1k', 'wb').write(' '*1024)
128 >>> file('2k', 'wb').write(' '*2048)
128 >>> file('2k', 'wb').write(' '*2048)
129 $ hg add 1k 2k
129 $ hg add 1k 2k
130 $ fileset 'size("bar")'
130 $ fileset 'size("bar")'
131 hg: parse error: couldn't parse size: bar
131 hg: parse error: couldn't parse size: bar
132 [255]
132 [255]
133 $ fileset 'size(1k)'
133 $ fileset 'size(1k)'
134 1k
134 1k
135 $ fileset '(1k or 2k) and size("< 2k")'
135 $ fileset '(1k or 2k) and size("< 2k")'
136 1k
136 1k
137 $ fileset '(1k or 2k) and size("<=2k")'
137 $ fileset '(1k or 2k) and size("<=2k")'
138 1k
138 1k
139 2k
139 2k
140 $ fileset '(1k or 2k) and size("> 1k")'
140 $ fileset '(1k or 2k) and size("> 1k")'
141 2k
141 2k
142 $ fileset '(1k or 2k) and size(">=1K")'
142 $ fileset '(1k or 2k) and size(">=1K")'
143 1k
143 1k
144 2k
144 2k
145 $ fileset '(1k or 2k) and size(".5KB - 1.5kB")'
145 $ fileset '(1k or 2k) and size(".5KB - 1.5kB")'
146 1k
146 1k
147
147
148 Test merge states
148 Test merge states
149
149
150 $ hg ci -m manychanges
150 $ hg ci -m manychanges
151 $ hg up -C 0
151 $ hg up -C 0
152 * files updated, 0 files merged, * files removed, 0 files unresolved (glob)
152 * files updated, 0 files merged, * files removed, 0 files unresolved (glob)
153 $ echo c >> b2
153 $ echo c >> b2
154 $ hg ci -m diverging b2
154 $ hg ci -m diverging b2
155 created new head
155 created new head
156 $ fileset 'resolved()'
156 $ fileset 'resolved()'
157 $ fileset 'unresolved()'
157 $ fileset 'unresolved()'
158 $ hg merge
158 $ hg merge
159 merging b2
159 merging b2
160 warning: conflicts during merge.
160 warning: conflicts during merge.
161 merging b2 incomplete! (edit conflicts, then use 'hg resolve --mark')
161 merging b2 incomplete! (edit conflicts, then use 'hg resolve --mark')
162 * files updated, 0 files merged, * files removed, 1 files unresolved (glob)
162 * files updated, 0 files merged, * files removed, 1 files unresolved (glob)
163 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
163 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
164 [1]
164 [1]
165 $ fileset 'resolved()'
165 $ fileset 'resolved()'
166 $ fileset 'unresolved()'
166 $ fileset 'unresolved()'
167 b2
167 b2
168 $ echo e > b2
168 $ echo e > b2
169 $ hg resolve -m b2
169 $ hg resolve -m b2
170 (no more unresolved files)
170 (no more unresolved files)
171 $ fileset 'resolved()'
171 $ fileset 'resolved()'
172 b2
172 b2
173 $ fileset 'unresolved()'
173 $ fileset 'unresolved()'
174 $ hg ci -m merge
174 $ hg ci -m merge
175
175
176 Test subrepo predicate
176 Test subrepo predicate
177
177
178 $ hg init sub
178 $ hg init sub
179 $ echo a > sub/suba
179 $ echo a > sub/suba
180 $ hg -R sub add sub/suba
180 $ hg -R sub add sub/suba
181 $ hg -R sub ci -m sub
181 $ hg -R sub ci -m sub
182 $ echo 'sub = sub' > .hgsub
182 $ echo 'sub = sub' > .hgsub
183 $ hg init sub2
183 $ hg init sub2
184 $ echo b > sub2/b
184 $ echo b > sub2/b
185 $ hg -R sub2 ci -Am sub2
185 $ hg -R sub2 ci -Am sub2
186 adding b
186 adding b
187 $ echo 'sub2 = sub2' >> .hgsub
187 $ echo 'sub2 = sub2' >> .hgsub
188 $ fileset 'subrepo()'
188 $ fileset 'subrepo()'
189 $ hg add .hgsub
189 $ hg add .hgsub
190 $ fileset 'subrepo()'
190 $ fileset 'subrepo()'
191 sub
191 sub
192 sub2
192 sub2
193 $ fileset 'subrepo("sub")'
193 $ fileset 'subrepo("sub")'
194 sub
194 sub
195 $ fileset 'subrepo("glob:*")'
195 $ fileset 'subrepo("glob:*")'
196 sub
196 sub
197 sub2
197 sub2
198 $ hg ci -m subrepo
198 $ hg ci -m subrepo
199
199
200 Test that .hgsubstate is updated as appropriate during a conversion. The
200 Test that .hgsubstate is updated as appropriate during a conversion. The
201 saverev property is enough to alter the hashes of the subrepo.
201 saverev property is enough to alter the hashes of the subrepo.
202
202
203 $ hg init ../converted
203 $ hg init ../converted
204 $ hg --config extensions.convert= convert --config convert.hg.saverev=True \
204 $ hg --config extensions.convert= convert --config convert.hg.saverev=True \
205 > sub ../converted/sub
205 > sub ../converted/sub
206 initializing destination ../converted/sub repository
206 initializing destination ../converted/sub repository
207 scanning source...
207 scanning source...
208 sorting...
208 sorting...
209 converting...
209 converting...
210 0 sub
210 0 sub
211 $ hg clone -U sub2 ../converted/sub2
211 $ hg clone -U sub2 ../converted/sub2
212 $ hg --config extensions.convert= convert --config convert.hg.saverev=True \
212 $ hg --config extensions.convert= convert --config convert.hg.saverev=True \
213 > . ../converted
213 > . ../converted
214 scanning source...
214 scanning source...
215 sorting...
215 sorting...
216 converting...
216 converting...
217 4 addfiles
217 4 addfiles
218 3 manychanges
218 3 manychanges
219 2 diverging
219 2 diverging
220 1 merge
220 1 merge
221 0 subrepo
221 0 subrepo
222 no ".hgsubstate" updates will be made for "sub2"
222 no ".hgsubstate" updates will be made for "sub2"
223 $ hg up -q -R ../converted -r tip
223 $ hg up -q -R ../converted -r tip
224 $ hg --cwd ../converted cat sub/suba sub2/b -r tip
224 $ hg --cwd ../converted cat sub/suba sub2/b -r tip
225 a
225 a
226 b
226 b
227 $ oldnode=`hg log -r tip -T "{node}\n"`
227 $ oldnode=`hg log -r tip -T "{node}\n"`
228 $ newnode=`hg log -R ../converted -r tip -T "{node}\n"`
228 $ newnode=`hg log -R ../converted -r tip -T "{node}\n"`
229 $ [[ "$oldnode" != "$newnode" ]] || echo "nothing changed"
229 $ [ "$oldnode" != "$newnode" ] || echo "nothing changed"
230
230
231 Test with a revision
231 Test with a revision
232
232
233 $ hg log -G --template '{rev} {desc}\n'
233 $ hg log -G --template '{rev} {desc}\n'
234 @ 4 subrepo
234 @ 4 subrepo
235 |
235 |
236 o 3 merge
236 o 3 merge
237 |\
237 |\
238 | o 2 diverging
238 | o 2 diverging
239 | |
239 | |
240 o | 1 manychanges
240 o | 1 manychanges
241 |/
241 |/
242 o 0 addfiles
242 o 0 addfiles
243
243
244 $ echo unknown > unknown
244 $ echo unknown > unknown
245 $ fileset -r1 'modified()'
245 $ fileset -r1 'modified()'
246 b2
246 b2
247 $ fileset -r1 'added() and c1'
247 $ fileset -r1 'added() and c1'
248 c1
248 c1
249 $ fileset -r1 'removed()'
249 $ fileset -r1 'removed()'
250 a2
250 a2
251 $ fileset -r1 'deleted()'
251 $ fileset -r1 'deleted()'
252 $ fileset -r1 'unknown()'
252 $ fileset -r1 'unknown()'
253 $ fileset -r1 'ignored()'
253 $ fileset -r1 'ignored()'
254 $ fileset -r1 'hgignore()'
254 $ fileset -r1 'hgignore()'
255 b2
255 b2
256 bin
256 bin
257 $ fileset -r1 'binary()'
257 $ fileset -r1 'binary()'
258 bin
258 bin
259 $ fileset -r1 'size(1k)'
259 $ fileset -r1 'size(1k)'
260 1k
260 1k
261 $ fileset -r3 'resolved()'
261 $ fileset -r3 'resolved()'
262 $ fileset -r3 'unresolved()'
262 $ fileset -r3 'unresolved()'
263
263
264 #if execbit
264 #if execbit
265 $ fileset -r1 'exec()'
265 $ fileset -r1 'exec()'
266 b2
266 b2
267 #endif
267 #endif
268
268
269 #if symlink
269 #if symlink
270 $ fileset -r1 'symlink()'
270 $ fileset -r1 'symlink()'
271 b2link
271 b2link
272 #endif
272 #endif
273
273
274 #if no-windows
274 #if no-windows
275 $ fileset -r1 'not portable()'
275 $ fileset -r1 'not portable()'
276 con.xml
276 con.xml
277 $ hg forget 'con.xml'
277 $ hg forget 'con.xml'
278 #endif
278 #endif
279
279
280 $ fileset -r4 'subrepo("re:su.*")'
280 $ fileset -r4 'subrepo("re:su.*")'
281 sub
281 sub
282 sub2
282 sub2
283 $ fileset -r4 'subrepo("sub")'
283 $ fileset -r4 'subrepo("sub")'
284 sub
284 sub
285 $ fileset -r4 'b2 or c1'
285 $ fileset -r4 'b2 or c1'
286 b2
286 b2
287 c1
287 c1
288
288
289 >>> open('dos', 'wb').write("dos\r\n")
289 >>> open('dos', 'wb').write("dos\r\n")
290 >>> open('mixed', 'wb').write("dos\r\nunix\n")
290 >>> open('mixed', 'wb').write("dos\r\nunix\n")
291 >>> open('mac', 'wb').write("mac\r")
291 >>> open('mac', 'wb').write("mac\r")
292 $ hg add dos mixed mac
292 $ hg add dos mixed mac
293
293
294 $ fileset 'eol(dos)'
294 $ fileset 'eol(dos)'
295 dos
295 dos
296 mixed
296 mixed
297 $ fileset 'eol(unix)'
297 $ fileset 'eol(unix)'
298 .hgsub
298 .hgsub
299 .hgsubstate
299 .hgsubstate
300 a1
300 a1
301 b1
301 b1
302 b2
302 b2
303 c1
303 c1
304 mixed
304 mixed
305 $ fileset 'eol(mac)'
305 $ fileset 'eol(mac)'
306 mac
306 mac
General Comments 0
You need to be logged in to leave comments. Login now