##// END OF EJS Templates
tests: test basic template support for status
Matt Mackall -
r25515:e8075329 default
parent child Browse files
Show More
@@ -1,458 +1,485 b''
1 $ hg init repo1
1 $ hg init repo1
2 $ cd repo1
2 $ cd repo1
3 $ mkdir a b a/1 b/1 b/2
3 $ mkdir a b a/1 b/1 b/2
4 $ touch in_root a/in_a b/in_b a/1/in_a_1 b/1/in_b_1 b/2/in_b_2
4 $ touch in_root a/in_a b/in_b a/1/in_a_1 b/1/in_b_1 b/2/in_b_2
5
5
6 hg status in repo root:
6 hg status in repo root:
7
7
8 $ hg status
8 $ hg status
9 ? a/1/in_a_1
9 ? a/1/in_a_1
10 ? a/in_a
10 ? a/in_a
11 ? b/1/in_b_1
11 ? b/1/in_b_1
12 ? b/2/in_b_2
12 ? b/2/in_b_2
13 ? b/in_b
13 ? b/in_b
14 ? in_root
14 ? in_root
15
15
16 hg status . in repo root:
16 hg status . in repo root:
17
17
18 $ hg status .
18 $ hg status .
19 ? a/1/in_a_1
19 ? a/1/in_a_1
20 ? a/in_a
20 ? a/in_a
21 ? b/1/in_b_1
21 ? b/1/in_b_1
22 ? b/2/in_b_2
22 ? b/2/in_b_2
23 ? b/in_b
23 ? b/in_b
24 ? in_root
24 ? in_root
25
25
26 $ hg status --cwd a
26 $ hg status --cwd a
27 ? a/1/in_a_1
27 ? a/1/in_a_1
28 ? a/in_a
28 ? a/in_a
29 ? b/1/in_b_1
29 ? b/1/in_b_1
30 ? b/2/in_b_2
30 ? b/2/in_b_2
31 ? b/in_b
31 ? b/in_b
32 ? in_root
32 ? in_root
33 $ hg status --cwd a .
33 $ hg status --cwd a .
34 ? 1/in_a_1
34 ? 1/in_a_1
35 ? in_a
35 ? in_a
36 $ hg status --cwd a ..
36 $ hg status --cwd a ..
37 ? 1/in_a_1
37 ? 1/in_a_1
38 ? in_a
38 ? in_a
39 ? ../b/1/in_b_1
39 ? ../b/1/in_b_1
40 ? ../b/2/in_b_2
40 ? ../b/2/in_b_2
41 ? ../b/in_b
41 ? ../b/in_b
42 ? ../in_root
42 ? ../in_root
43
43
44 $ hg status --cwd b
44 $ hg status --cwd b
45 ? a/1/in_a_1
45 ? a/1/in_a_1
46 ? a/in_a
46 ? a/in_a
47 ? b/1/in_b_1
47 ? b/1/in_b_1
48 ? b/2/in_b_2
48 ? b/2/in_b_2
49 ? b/in_b
49 ? b/in_b
50 ? in_root
50 ? in_root
51 $ hg status --cwd b .
51 $ hg status --cwd b .
52 ? 1/in_b_1
52 ? 1/in_b_1
53 ? 2/in_b_2
53 ? 2/in_b_2
54 ? in_b
54 ? in_b
55 $ hg status --cwd b ..
55 $ hg status --cwd b ..
56 ? ../a/1/in_a_1
56 ? ../a/1/in_a_1
57 ? ../a/in_a
57 ? ../a/in_a
58 ? 1/in_b_1
58 ? 1/in_b_1
59 ? 2/in_b_2
59 ? 2/in_b_2
60 ? in_b
60 ? in_b
61 ? ../in_root
61 ? ../in_root
62
62
63 $ hg status --cwd a/1
63 $ hg status --cwd a/1
64 ? a/1/in_a_1
64 ? a/1/in_a_1
65 ? a/in_a
65 ? a/in_a
66 ? b/1/in_b_1
66 ? b/1/in_b_1
67 ? b/2/in_b_2
67 ? b/2/in_b_2
68 ? b/in_b
68 ? b/in_b
69 ? in_root
69 ? in_root
70 $ hg status --cwd a/1 .
70 $ hg status --cwd a/1 .
71 ? in_a_1
71 ? in_a_1
72 $ hg status --cwd a/1 ..
72 $ hg status --cwd a/1 ..
73 ? in_a_1
73 ? in_a_1
74 ? ../in_a
74 ? ../in_a
75
75
76 $ hg status --cwd b/1
76 $ hg status --cwd b/1
77 ? a/1/in_a_1
77 ? a/1/in_a_1
78 ? a/in_a
78 ? a/in_a
79 ? b/1/in_b_1
79 ? b/1/in_b_1
80 ? b/2/in_b_2
80 ? b/2/in_b_2
81 ? b/in_b
81 ? b/in_b
82 ? in_root
82 ? in_root
83 $ hg status --cwd b/1 .
83 $ hg status --cwd b/1 .
84 ? in_b_1
84 ? in_b_1
85 $ hg status --cwd b/1 ..
85 $ hg status --cwd b/1 ..
86 ? in_b_1
86 ? in_b_1
87 ? ../2/in_b_2
87 ? ../2/in_b_2
88 ? ../in_b
88 ? ../in_b
89
89
90 $ hg status --cwd b/2
90 $ hg status --cwd b/2
91 ? a/1/in_a_1
91 ? a/1/in_a_1
92 ? a/in_a
92 ? a/in_a
93 ? b/1/in_b_1
93 ? b/1/in_b_1
94 ? b/2/in_b_2
94 ? b/2/in_b_2
95 ? b/in_b
95 ? b/in_b
96 ? in_root
96 ? in_root
97 $ hg status --cwd b/2 .
97 $ hg status --cwd b/2 .
98 ? in_b_2
98 ? in_b_2
99 $ hg status --cwd b/2 ..
99 $ hg status --cwd b/2 ..
100 ? ../1/in_b_1
100 ? ../1/in_b_1
101 ? in_b_2
101 ? in_b_2
102 ? ../in_b
102 ? ../in_b
103
103
104 combining patterns with root and patterns without a root works
104 combining patterns with root and patterns without a root works
105
105
106 $ hg st a/in_a re:.*b$
106 $ hg st a/in_a re:.*b$
107 ? a/in_a
107 ? a/in_a
108 ? b/in_b
108 ? b/in_b
109
109
110 $ cd ..
110 $ cd ..
111
111
112 $ hg init repo2
112 $ hg init repo2
113 $ cd repo2
113 $ cd repo2
114 $ touch modified removed deleted ignored
114 $ touch modified removed deleted ignored
115 $ echo "^ignored$" > .hgignore
115 $ echo "^ignored$" > .hgignore
116 $ hg ci -A -m 'initial checkin'
116 $ hg ci -A -m 'initial checkin'
117 adding .hgignore
117 adding .hgignore
118 adding deleted
118 adding deleted
119 adding modified
119 adding modified
120 adding removed
120 adding removed
121 $ touch modified added unknown ignored
121 $ touch modified added unknown ignored
122 $ hg add added
122 $ hg add added
123 $ hg remove removed
123 $ hg remove removed
124 $ rm deleted
124 $ rm deleted
125
125
126 hg status:
126 hg status:
127
127
128 $ hg status
128 $ hg status
129 A added
129 A added
130 R removed
130 R removed
131 ! deleted
131 ! deleted
132 ? unknown
132 ? unknown
133
133
134 hg status modified added removed deleted unknown never-existed ignored:
134 hg status modified added removed deleted unknown never-existed ignored:
135
135
136 $ hg status modified added removed deleted unknown never-existed ignored
136 $ hg status modified added removed deleted unknown never-existed ignored
137 never-existed: * (glob)
137 never-existed: * (glob)
138 A added
138 A added
139 R removed
139 R removed
140 ! deleted
140 ! deleted
141 ? unknown
141 ? unknown
142
142
143 $ hg copy modified copied
143 $ hg copy modified copied
144
144
145 hg status -C:
145 hg status -C:
146
146
147 $ hg status -C
147 $ hg status -C
148 A added
148 A added
149 A copied
149 A copied
150 modified
150 modified
151 R removed
151 R removed
152 ! deleted
152 ! deleted
153 ? unknown
153 ? unknown
154
154
155 hg status -A:
155 hg status -A:
156
156
157 $ hg status -A
157 $ hg status -A
158 A added
158 A added
159 A copied
159 A copied
160 modified
160 modified
161 R removed
161 R removed
162 ! deleted
162 ! deleted
163 ? unknown
163 ? unknown
164 I ignored
164 I ignored
165 C .hgignore
165 C .hgignore
166 C modified
166 C modified
167
167
168 $ hg status -A -Tjson
168 $ hg status -A -Tjson
169 [
169 [
170 {
170 {
171 "path": "added",
171 "path": "added",
172 "status": "A"
172 "status": "A"
173 },
173 },
174 {
174 {
175 "copy": "modified",
175 "copy": "modified",
176 "path": "copied",
176 "path": "copied",
177 "status": "A"
177 "status": "A"
178 },
178 },
179 {
179 {
180 "path": "removed",
180 "path": "removed",
181 "status": "R"
181 "status": "R"
182 },
182 },
183 {
183 {
184 "path": "deleted",
184 "path": "deleted",
185 "status": "!"
185 "status": "!"
186 },
186 },
187 {
187 {
188 "path": "unknown",
188 "path": "unknown",
189 "status": "?"
189 "status": "?"
190 },
190 },
191 {
191 {
192 "path": "ignored",
192 "path": "ignored",
193 "status": "I"
193 "status": "I"
194 },
194 },
195 {
195 {
196 "path": ".hgignore",
196 "path": ".hgignore",
197 "status": "C"
197 "status": "C"
198 },
198 },
199 {
199 {
200 "path": "modified",
200 "path": "modified",
201 "status": "C"
201 "status": "C"
202 }
202 }
203 ]
203 ]
204
204
205 $ hg status -A -Tpickle > pickle
205 $ hg status -A -Tpickle > pickle
206 >>> import pickle
206 >>> import pickle
207 >>> print sorted((x['status'], x['path']) for x in pickle.load(open("pickle")))
207 >>> print sorted((x['status'], x['path']) for x in pickle.load(open("pickle")))
208 [('!', 'deleted'), ('?', 'pickle'), ('?', 'unknown'), ('A', 'added'), ('A', 'copied'), ('C', '.hgignore'), ('C', 'modified'), ('I', 'ignored'), ('R', 'removed')]
208 [('!', 'deleted'), ('?', 'pickle'), ('?', 'unknown'), ('A', 'added'), ('A', 'copied'), ('C', '.hgignore'), ('C', 'modified'), ('I', 'ignored'), ('R', 'removed')]
209 $ rm pickle
209 $ rm pickle
210
210
211 $ echo "^ignoreddir$" > .hgignore
211 $ echo "^ignoreddir$" > .hgignore
212 $ mkdir ignoreddir
212 $ mkdir ignoreddir
213 $ touch ignoreddir/file
213 $ touch ignoreddir/file
214
214
215 Test templater support:
216
217 $ hg status -AT "[{status}]\t{if(copy, '{copy} -> ')}{path}\n"
218 [M] .hgignore
219 [A] added
220 [A] modified -> copied
221 [R] removed
222 [!] deleted
223 [?] ignored
224 [?] unknown
225 [I] ignoreddir/file
226 [C] modified
227 $ hg status -AT default
228 M .hgignore
229 A added
230 A copied
231 modified
232 R removed
233 ! deleted
234 ? ignored
235 ? unknown
236 I ignoreddir/file
237 C modified
238 $ hg status -T compact
239 abort: "status" not in template map
240 [255]
241
215 hg status ignoreddir/file:
242 hg status ignoreddir/file:
216
243
217 $ hg status ignoreddir/file
244 $ hg status ignoreddir/file
218
245
219 hg status -i ignoreddir/file:
246 hg status -i ignoreddir/file:
220
247
221 $ hg status -i ignoreddir/file
248 $ hg status -i ignoreddir/file
222 I ignoreddir/file
249 I ignoreddir/file
223 $ cd ..
250 $ cd ..
224
251
225 Check 'status -q' and some combinations
252 Check 'status -q' and some combinations
226
253
227 $ hg init repo3
254 $ hg init repo3
228 $ cd repo3
255 $ cd repo3
229 $ touch modified removed deleted ignored
256 $ touch modified removed deleted ignored
230 $ echo "^ignored$" > .hgignore
257 $ echo "^ignored$" > .hgignore
231 $ hg commit -A -m 'initial checkin'
258 $ hg commit -A -m 'initial checkin'
232 adding .hgignore
259 adding .hgignore
233 adding deleted
260 adding deleted
234 adding modified
261 adding modified
235 adding removed
262 adding removed
236 $ touch added unknown ignored
263 $ touch added unknown ignored
237 $ hg add added
264 $ hg add added
238 $ echo "test" >> modified
265 $ echo "test" >> modified
239 $ hg remove removed
266 $ hg remove removed
240 $ rm deleted
267 $ rm deleted
241 $ hg copy modified copied
268 $ hg copy modified copied
242
269
243 Specify working directory revision explicitly, that should be the same as
270 Specify working directory revision explicitly, that should be the same as
244 "hg status"
271 "hg status"
245
272
246 $ hg status --change "wdir()"
273 $ hg status --change "wdir()"
247 M modified
274 M modified
248 A added
275 A added
249 A copied
276 A copied
250 R removed
277 R removed
251 ! deleted
278 ! deleted
252 ? unknown
279 ? unknown
253
280
254 Run status with 2 different flags.
281 Run status with 2 different flags.
255 Check if result is the same or different.
282 Check if result is the same or different.
256 If result is not as expected, raise error
283 If result is not as expected, raise error
257
284
258 $ assert() {
285 $ assert() {
259 > hg status $1 > ../a
286 > hg status $1 > ../a
260 > hg status $2 > ../b
287 > hg status $2 > ../b
261 > if diff ../a ../b > /dev/null; then
288 > if diff ../a ../b > /dev/null; then
262 > out=0
289 > out=0
263 > else
290 > else
264 > out=1
291 > out=1
265 > fi
292 > fi
266 > if [ $3 -eq 0 ]; then
293 > if [ $3 -eq 0 ]; then
267 > df="same"
294 > df="same"
268 > else
295 > else
269 > df="different"
296 > df="different"
270 > fi
297 > fi
271 > if [ $out -ne $3 ]; then
298 > if [ $out -ne $3 ]; then
272 > echo "Error on $1 and $2, should be $df."
299 > echo "Error on $1 and $2, should be $df."
273 > fi
300 > fi
274 > }
301 > }
275
302
276 Assert flag1 flag2 [0-same | 1-different]
303 Assert flag1 flag2 [0-same | 1-different]
277
304
278 $ assert "-q" "-mard" 0
305 $ assert "-q" "-mard" 0
279 $ assert "-A" "-marduicC" 0
306 $ assert "-A" "-marduicC" 0
280 $ assert "-qA" "-mardcC" 0
307 $ assert "-qA" "-mardcC" 0
281 $ assert "-qAui" "-A" 0
308 $ assert "-qAui" "-A" 0
282 $ assert "-qAu" "-marducC" 0
309 $ assert "-qAu" "-marducC" 0
283 $ assert "-qAi" "-mardicC" 0
310 $ assert "-qAi" "-mardicC" 0
284 $ assert "-qu" "-u" 0
311 $ assert "-qu" "-u" 0
285 $ assert "-q" "-u" 1
312 $ assert "-q" "-u" 1
286 $ assert "-m" "-a" 1
313 $ assert "-m" "-a" 1
287 $ assert "-r" "-d" 1
314 $ assert "-r" "-d" 1
288 $ cd ..
315 $ cd ..
289
316
290 $ hg init repo4
317 $ hg init repo4
291 $ cd repo4
318 $ cd repo4
292 $ touch modified removed deleted
319 $ touch modified removed deleted
293 $ hg ci -q -A -m 'initial checkin'
320 $ hg ci -q -A -m 'initial checkin'
294 $ touch added unknown
321 $ touch added unknown
295 $ hg add added
322 $ hg add added
296 $ hg remove removed
323 $ hg remove removed
297 $ rm deleted
324 $ rm deleted
298 $ echo x > modified
325 $ echo x > modified
299 $ hg copy modified copied
326 $ hg copy modified copied
300 $ hg ci -m 'test checkin' -d "1000001 0"
327 $ hg ci -m 'test checkin' -d "1000001 0"
301 $ rm *
328 $ rm *
302 $ touch unrelated
329 $ touch unrelated
303 $ hg ci -q -A -m 'unrelated checkin' -d "1000002 0"
330 $ hg ci -q -A -m 'unrelated checkin' -d "1000002 0"
304
331
305 hg status --change 1:
332 hg status --change 1:
306
333
307 $ hg status --change 1
334 $ hg status --change 1
308 M modified
335 M modified
309 A added
336 A added
310 A copied
337 A copied
311 R removed
338 R removed
312
339
313 hg status --change 1 unrelated:
340 hg status --change 1 unrelated:
314
341
315 $ hg status --change 1 unrelated
342 $ hg status --change 1 unrelated
316
343
317 hg status -C --change 1 added modified copied removed deleted:
344 hg status -C --change 1 added modified copied removed deleted:
318
345
319 $ hg status -C --change 1 added modified copied removed deleted
346 $ hg status -C --change 1 added modified copied removed deleted
320 M modified
347 M modified
321 A added
348 A added
322 A copied
349 A copied
323 modified
350 modified
324 R removed
351 R removed
325
352
326 hg status -A --change 1 and revset:
353 hg status -A --change 1 and revset:
327
354
328 $ hg status -A --change '1|1'
355 $ hg status -A --change '1|1'
329 M modified
356 M modified
330 A added
357 A added
331 A copied
358 A copied
332 modified
359 modified
333 R removed
360 R removed
334 C deleted
361 C deleted
335
362
336 $ cd ..
363 $ cd ..
337
364
338 hg status of binary file starting with '\1\n', a separator for metadata:
365 hg status of binary file starting with '\1\n', a separator for metadata:
339
366
340 $ hg init repo5
367 $ hg init repo5
341 $ cd repo5
368 $ cd repo5
342 >>> open("010a", "wb").write("\1\nfoo")
369 >>> open("010a", "wb").write("\1\nfoo")
343 $ hg ci -q -A -m 'initial checkin'
370 $ hg ci -q -A -m 'initial checkin'
344 $ hg status -A
371 $ hg status -A
345 C 010a
372 C 010a
346
373
347 >>> open("010a", "wb").write("\1\nbar")
374 >>> open("010a", "wb").write("\1\nbar")
348 $ hg status -A
375 $ hg status -A
349 M 010a
376 M 010a
350 $ hg ci -q -m 'modify 010a'
377 $ hg ci -q -m 'modify 010a'
351 $ hg status -A --rev 0:1
378 $ hg status -A --rev 0:1
352 M 010a
379 M 010a
353
380
354 $ touch empty
381 $ touch empty
355 $ hg ci -q -A -m 'add another file'
382 $ hg ci -q -A -m 'add another file'
356 $ hg status -A --rev 1:2 010a
383 $ hg status -A --rev 1:2 010a
357 C 010a
384 C 010a
358
385
359 $ cd ..
386 $ cd ..
360
387
361 test "hg status" with "directory pattern" which matches against files
388 test "hg status" with "directory pattern" which matches against files
362 only known on target revision.
389 only known on target revision.
363
390
364 $ hg init repo6
391 $ hg init repo6
365 $ cd repo6
392 $ cd repo6
366
393
367 $ echo a > a.txt
394 $ echo a > a.txt
368 $ hg add a.txt
395 $ hg add a.txt
369 $ hg commit -m '#0'
396 $ hg commit -m '#0'
370 $ mkdir -p 1/2/3/4/5
397 $ mkdir -p 1/2/3/4/5
371 $ echo b > 1/2/3/4/5/b.txt
398 $ echo b > 1/2/3/4/5/b.txt
372 $ hg add 1/2/3/4/5/b.txt
399 $ hg add 1/2/3/4/5/b.txt
373 $ hg commit -m '#1'
400 $ hg commit -m '#1'
374
401
375 $ hg update -C 0 > /dev/null
402 $ hg update -C 0 > /dev/null
376 $ hg status -A
403 $ hg status -A
377 C a.txt
404 C a.txt
378
405
379 the directory matching against specified pattern should be removed,
406 the directory matching against specified pattern should be removed,
380 because directory existence prevents 'dirstate.walk()' from showing
407 because directory existence prevents 'dirstate.walk()' from showing
381 warning message about such pattern.
408 warning message about such pattern.
382
409
383 $ test ! -d 1
410 $ test ! -d 1
384 $ hg status -A --rev 1 1/2/3/4/5/b.txt
411 $ hg status -A --rev 1 1/2/3/4/5/b.txt
385 R 1/2/3/4/5/b.txt
412 R 1/2/3/4/5/b.txt
386 $ hg status -A --rev 1 1/2/3/4/5
413 $ hg status -A --rev 1 1/2/3/4/5
387 R 1/2/3/4/5/b.txt
414 R 1/2/3/4/5/b.txt
388 $ hg status -A --rev 1 1/2/3
415 $ hg status -A --rev 1 1/2/3
389 R 1/2/3/4/5/b.txt
416 R 1/2/3/4/5/b.txt
390 $ hg status -A --rev 1 1
417 $ hg status -A --rev 1 1
391 R 1/2/3/4/5/b.txt
418 R 1/2/3/4/5/b.txt
392
419
393 $ hg status --config ui.formatdebug=True --rev 1 1
420 $ hg status --config ui.formatdebug=True --rev 1 1
394 status = [
421 status = [
395 {*'path': '1/2/3/4/5/b.txt'*}, (glob)
422 {*'path': '1/2/3/4/5/b.txt'*}, (glob)
396 ]
423 ]
397
424
398 #if windows
425 #if windows
399 $ hg --config ui.slash=false status -A --rev 1 1
426 $ hg --config ui.slash=false status -A --rev 1 1
400 R 1\2\3\4\5\b.txt
427 R 1\2\3\4\5\b.txt
401 #endif
428 #endif
402
429
403 $ cd ..
430 $ cd ..
404
431
405 Status after move overwriting a file (issue4458)
432 Status after move overwriting a file (issue4458)
406 =================================================
433 =================================================
407
434
408
435
409 $ hg init issue4458
436 $ hg init issue4458
410 $ cd issue4458
437 $ cd issue4458
411 $ echo a > a
438 $ echo a > a
412 $ echo b > b
439 $ echo b > b
413 $ hg commit -Am base
440 $ hg commit -Am base
414 adding a
441 adding a
415 adding b
442 adding b
416
443
417
444
418 with --force
445 with --force
419
446
420 $ hg mv b --force a
447 $ hg mv b --force a
421 $ hg st --copies
448 $ hg st --copies
422 M a
449 M a
423 b
450 b
424 R b
451 R b
425 $ hg revert --all
452 $ hg revert --all
426 reverting a
453 reverting a
427 undeleting b
454 undeleting b
428 $ rm *.orig
455 $ rm *.orig
429
456
430 without force
457 without force
431
458
432 $ hg rm a
459 $ hg rm a
433 $ hg st --copies
460 $ hg st --copies
434 R a
461 R a
435 $ hg mv b a
462 $ hg mv b a
436 $ hg st --copies
463 $ hg st --copies
437 M a
464 M a
438 b
465 b
439 R b
466 R b
440
467
441 using ui.statuscopies setting
468 using ui.statuscopies setting
442 $ hg st --config ui.statuscopies=true
469 $ hg st --config ui.statuscopies=true
443 M a
470 M a
444 b
471 b
445 R b
472 R b
446 $ hg st --config ui.statuscopies=false
473 $ hg st --config ui.statuscopies=false
447 M a
474 M a
448 R b
475 R b
449
476
450 Other "bug" highlight, the revision status does not report the copy information.
477 Other "bug" highlight, the revision status does not report the copy information.
451 This is buggy behavior.
478 This is buggy behavior.
452
479
453 $ hg commit -m 'blah'
480 $ hg commit -m 'blah'
454 $ hg st --copies --change .
481 $ hg st --copies --change .
455 M a
482 M a
456 R b
483 R b
457
484
458 $ cd ..
485 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now