##// END OF EJS Templates
tests: replace imported module to avoid check-code.py error...
FUJIWARA Katsunori -
r41882:67333663 default
parent child Browse files
Show More
@@ -1,654 +1,654
1 1 $ hg init repo1
2 2 $ cd repo1
3 3 $ mkdir a b a/1 b/1 b/2
4 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 6 hg status in repo root:
7 7
8 8 $ hg status
9 9 ? a/1/in_a_1
10 10 ? a/in_a
11 11 ? b/1/in_b_1
12 12 ? b/2/in_b_2
13 13 ? b/in_b
14 14 ? in_root
15 15
16 16 hg status . in repo root:
17 17
18 18 $ hg status .
19 19 ? a/1/in_a_1
20 20 ? a/in_a
21 21 ? b/1/in_b_1
22 22 ? b/2/in_b_2
23 23 ? b/in_b
24 24 ? in_root
25 25
26 26 $ hg status --cwd a
27 27 ? a/1/in_a_1
28 28 ? a/in_a
29 29 ? b/1/in_b_1
30 30 ? b/2/in_b_2
31 31 ? b/in_b
32 32 ? in_root
33 33 $ hg status --cwd a .
34 34 ? 1/in_a_1
35 35 ? in_a
36 36 $ hg status --cwd a ..
37 37 ? 1/in_a_1
38 38 ? in_a
39 39 ? ../b/1/in_b_1
40 40 ? ../b/2/in_b_2
41 41 ? ../b/in_b
42 42 ? ../in_root
43 43
44 44 $ hg status --cwd b
45 45 ? a/1/in_a_1
46 46 ? a/in_a
47 47 ? b/1/in_b_1
48 48 ? b/2/in_b_2
49 49 ? b/in_b
50 50 ? in_root
51 51 $ hg status --cwd b .
52 52 ? 1/in_b_1
53 53 ? 2/in_b_2
54 54 ? in_b
55 55 $ hg status --cwd b ..
56 56 ? ../a/1/in_a_1
57 57 ? ../a/in_a
58 58 ? 1/in_b_1
59 59 ? 2/in_b_2
60 60 ? in_b
61 61 ? ../in_root
62 62
63 63 $ hg status --cwd a/1
64 64 ? a/1/in_a_1
65 65 ? a/in_a
66 66 ? b/1/in_b_1
67 67 ? b/2/in_b_2
68 68 ? b/in_b
69 69 ? in_root
70 70 $ hg status --cwd a/1 .
71 71 ? in_a_1
72 72 $ hg status --cwd a/1 ..
73 73 ? in_a_1
74 74 ? ../in_a
75 75
76 76 $ hg status --cwd b/1
77 77 ? a/1/in_a_1
78 78 ? a/in_a
79 79 ? b/1/in_b_1
80 80 ? b/2/in_b_2
81 81 ? b/in_b
82 82 ? in_root
83 83 $ hg status --cwd b/1 .
84 84 ? in_b_1
85 85 $ hg status --cwd b/1 ..
86 86 ? in_b_1
87 87 ? ../2/in_b_2
88 88 ? ../in_b
89 89
90 90 $ hg status --cwd b/2
91 91 ? a/1/in_a_1
92 92 ? a/in_a
93 93 ? b/1/in_b_1
94 94 ? b/2/in_b_2
95 95 ? b/in_b
96 96 ? in_root
97 97 $ hg status --cwd b/2 .
98 98 ? in_b_2
99 99 $ hg status --cwd b/2 ..
100 100 ? ../1/in_b_1
101 101 ? in_b_2
102 102 ? ../in_b
103 103
104 104 combining patterns with root and patterns without a root works
105 105
106 106 $ hg st a/in_a re:.*b$
107 107 ? a/in_a
108 108 ? b/in_b
109 109
110 110 tweaking defaults works
111 111 $ hg status --cwd a --config ui.tweakdefaults=yes
112 112 ? 1/in_a_1
113 113 ? in_a
114 114 ? ../b/1/in_b_1
115 115 ? ../b/2/in_b_2
116 116 ? ../b/in_b
117 117 ? ../in_root
118 118 $ HGPLAIN=1 hg status --cwd a --config ui.tweakdefaults=yes
119 119 ? a/1/in_a_1 (glob)
120 120 ? a/in_a (glob)
121 121 ? b/1/in_b_1 (glob)
122 122 ? b/2/in_b_2 (glob)
123 123 ? b/in_b (glob)
124 124 ? in_root
125 125 $ HGPLAINEXCEPT=tweakdefaults hg status --cwd a --config ui.tweakdefaults=yes
126 126 ? 1/in_a_1
127 127 ? in_a
128 128 ? ../b/1/in_b_1
129 129 ? ../b/2/in_b_2
130 130 ? ../b/in_b
131 131 ? ../in_root (glob)
132 132
133 133 relative paths can be requested
134 134
135 135 $ hg status --cwd a --config ui.relative-paths=yes
136 136 ? 1/in_a_1
137 137 ? in_a
138 138 ? ../b/1/in_b_1
139 139 ? ../b/2/in_b_2
140 140 ? ../b/in_b
141 141 ? ../in_root
142 142
143 143 $ hg status --cwd a . --config ui.relative-paths=legacy
144 144 ? 1/in_a_1
145 145 ? in_a
146 146 $ hg status --cwd a . --config ui.relative-paths=no
147 147 ? a/1/in_a_1
148 148 ? a/in_a
149 149
150 150 commands.status.relative overrides ui.relative-paths
151 151
152 152 $ cat >> $HGRCPATH <<EOF
153 153 > [ui]
154 154 > relative-paths = False
155 155 > [commands]
156 156 > status.relative = True
157 157 > EOF
158 158 $ hg status --cwd a
159 159 ? 1/in_a_1
160 160 ? in_a
161 161 ? ../b/1/in_b_1
162 162 ? ../b/2/in_b_2
163 163 ? ../b/in_b
164 164 ? ../in_root
165 165 $ HGPLAIN=1 hg status --cwd a
166 166 ? a/1/in_a_1 (glob)
167 167 ? a/in_a (glob)
168 168 ? b/1/in_b_1 (glob)
169 169 ? b/2/in_b_2 (glob)
170 170 ? b/in_b (glob)
171 171 ? in_root
172 172
173 173 if relative paths are explicitly off, tweakdefaults doesn't change it
174 174 $ cat >> $HGRCPATH <<EOF
175 175 > [commands]
176 176 > status.relative = False
177 177 > EOF
178 178 $ hg status --cwd a --config ui.tweakdefaults=yes
179 179 ? a/1/in_a_1
180 180 ? a/in_a
181 181 ? b/1/in_b_1
182 182 ? b/2/in_b_2
183 183 ? b/in_b
184 184 ? in_root
185 185
186 186 $ cd ..
187 187
188 188 $ hg init repo2
189 189 $ cd repo2
190 190 $ touch modified removed deleted ignored
191 191 $ echo "^ignored$" > .hgignore
192 192 $ hg ci -A -m 'initial checkin'
193 193 adding .hgignore
194 194 adding deleted
195 195 adding modified
196 196 adding removed
197 197 $ touch modified added unknown ignored
198 198 $ hg add added
199 199 $ hg remove removed
200 200 $ rm deleted
201 201
202 202 hg status:
203 203
204 204 $ hg status
205 205 A added
206 206 R removed
207 207 ! deleted
208 208 ? unknown
209 209
210 210 hg status modified added removed deleted unknown never-existed ignored:
211 211
212 212 $ hg status modified added removed deleted unknown never-existed ignored
213 213 never-existed: * (glob)
214 214 A added
215 215 R removed
216 216 ! deleted
217 217 ? unknown
218 218
219 219 $ hg copy modified copied
220 220
221 221 hg status -C:
222 222
223 223 $ hg status -C
224 224 A added
225 225 A copied
226 226 modified
227 227 R removed
228 228 ! deleted
229 229 ? unknown
230 230
231 231 hg status -A:
232 232
233 233 $ hg status -A
234 234 A added
235 235 A copied
236 236 modified
237 237 R removed
238 238 ! deleted
239 239 ? unknown
240 240 I ignored
241 241 C .hgignore
242 242 C modified
243 243
244 244 $ hg status -A -T '{status} {path} {node|shortest}\n'
245 245 A added ffff
246 246 A copied ffff
247 247 R removed ffff
248 248 ! deleted ffff
249 249 ? unknown ffff
250 250 I ignored ffff
251 251 C .hgignore ffff
252 252 C modified ffff
253 253
254 254 $ hg status -A -Tjson
255 255 [
256 256 {
257 257 "path": "added",
258 258 "status": "A"
259 259 },
260 260 {
261 261 "path": "copied",
262 262 "source": "modified",
263 263 "status": "A"
264 264 },
265 265 {
266 266 "path": "removed",
267 267 "status": "R"
268 268 },
269 269 {
270 270 "path": "deleted",
271 271 "status": "!"
272 272 },
273 273 {
274 274 "path": "unknown",
275 275 "status": "?"
276 276 },
277 277 {
278 278 "path": "ignored",
279 279 "status": "I"
280 280 },
281 281 {
282 282 "path": ".hgignore",
283 283 "status": "C"
284 284 },
285 285 {
286 286 "path": "modified",
287 287 "status": "C"
288 288 }
289 289 ]
290 290
291 291 $ hg status -A -Tpickle > pickle
292 292 >>> from __future__ import print_function
293 >>> import pickle
293 >>> from mercurial.util import pickle
294 294 >>> data = sorted((x[b'status'].decode(), x[b'path'].decode()) for x in pickle.load(open("pickle", r"rb")))
295 295 >>> for s, p in data: print("%s %s" % (s, p))
296 296 ! deleted
297 297 ? pickle
298 298 ? unknown
299 299 A added
300 300 A copied
301 301 C .hgignore
302 302 C modified
303 303 I ignored
304 304 R removed
305 305 $ rm pickle
306 306
307 307 $ echo "^ignoreddir$" > .hgignore
308 308 $ mkdir ignoreddir
309 309 $ touch ignoreddir/file
310 310
311 311 Test templater support:
312 312
313 313 $ hg status -AT "[{status}]\t{if(source, '{source} -> ')}{path}\n"
314 314 [M] .hgignore
315 315 [A] added
316 316 [A] modified -> copied
317 317 [R] removed
318 318 [!] deleted
319 319 [?] ignored
320 320 [?] unknown
321 321 [I] ignoreddir/file
322 322 [C] modified
323 323 $ hg status -AT default
324 324 M .hgignore
325 325 A added
326 326 A copied
327 327 modified
328 328 R removed
329 329 ! deleted
330 330 ? ignored
331 331 ? unknown
332 332 I ignoreddir/file
333 333 C modified
334 334 $ hg status -T compact
335 335 abort: "status" not in template map
336 336 [255]
337 337
338 338 hg status ignoreddir/file:
339 339
340 340 $ hg status ignoreddir/file
341 341
342 342 hg status -i ignoreddir/file:
343 343
344 344 $ hg status -i ignoreddir/file
345 345 I ignoreddir/file
346 346 $ cd ..
347 347
348 348 Check 'status -q' and some combinations
349 349
350 350 $ hg init repo3
351 351 $ cd repo3
352 352 $ touch modified removed deleted ignored
353 353 $ echo "^ignored$" > .hgignore
354 354 $ hg commit -A -m 'initial checkin'
355 355 adding .hgignore
356 356 adding deleted
357 357 adding modified
358 358 adding removed
359 359 $ touch added unknown ignored
360 360 $ hg add added
361 361 $ echo "test" >> modified
362 362 $ hg remove removed
363 363 $ rm deleted
364 364 $ hg copy modified copied
365 365
366 366 Specify working directory revision explicitly, that should be the same as
367 367 "hg status"
368 368
369 369 $ hg status --change "wdir()"
370 370 M modified
371 371 A added
372 372 A copied
373 373 R removed
374 374 ! deleted
375 375 ? unknown
376 376
377 377 Run status with 2 different flags.
378 378 Check if result is the same or different.
379 379 If result is not as expected, raise error
380 380
381 381 $ assert() {
382 382 > hg status $1 > ../a
383 383 > hg status $2 > ../b
384 384 > if diff ../a ../b > /dev/null; then
385 385 > out=0
386 386 > else
387 387 > out=1
388 388 > fi
389 389 > if [ $3 -eq 0 ]; then
390 390 > df="same"
391 391 > else
392 392 > df="different"
393 393 > fi
394 394 > if [ $out -ne $3 ]; then
395 395 > echo "Error on $1 and $2, should be $df."
396 396 > fi
397 397 > }
398 398
399 399 Assert flag1 flag2 [0-same | 1-different]
400 400
401 401 $ assert "-q" "-mard" 0
402 402 $ assert "-A" "-marduicC" 0
403 403 $ assert "-qA" "-mardcC" 0
404 404 $ assert "-qAui" "-A" 0
405 405 $ assert "-qAu" "-marducC" 0
406 406 $ assert "-qAi" "-mardicC" 0
407 407 $ assert "-qu" "-u" 0
408 408 $ assert "-q" "-u" 1
409 409 $ assert "-m" "-a" 1
410 410 $ assert "-r" "-d" 1
411 411 $ cd ..
412 412
413 413 $ hg init repo4
414 414 $ cd repo4
415 415 $ touch modified removed deleted
416 416 $ hg ci -q -A -m 'initial checkin'
417 417 $ touch added unknown
418 418 $ hg add added
419 419 $ hg remove removed
420 420 $ rm deleted
421 421 $ echo x > modified
422 422 $ hg copy modified copied
423 423 $ hg ci -m 'test checkin' -d "1000001 0"
424 424 $ rm *
425 425 $ touch unrelated
426 426 $ hg ci -q -A -m 'unrelated checkin' -d "1000002 0"
427 427
428 428 hg status --change 1:
429 429
430 430 $ hg status --change 1
431 431 M modified
432 432 A added
433 433 A copied
434 434 R removed
435 435
436 436 hg status --change 1 unrelated:
437 437
438 438 $ hg status --change 1 unrelated
439 439
440 440 hg status -C --change 1 added modified copied removed deleted:
441 441
442 442 $ hg status -C --change 1 added modified copied removed deleted
443 443 M modified
444 444 A added
445 445 A copied
446 446 modified
447 447 R removed
448 448
449 449 hg status -A --change 1 and revset:
450 450
451 451 $ hg status -A --change '1|1'
452 452 M modified
453 453 A added
454 454 A copied
455 455 modified
456 456 R removed
457 457 C deleted
458 458
459 459 $ cd ..
460 460
461 461 hg status with --rev and reverted changes:
462 462
463 463 $ hg init reverted-changes-repo
464 464 $ cd reverted-changes-repo
465 465 $ echo a > file
466 466 $ hg add file
467 467 $ hg ci -m a
468 468 $ echo b > file
469 469 $ hg ci -m b
470 470
471 471 reverted file should appear clean
472 472
473 473 $ hg revert -r 0 .
474 474 reverting file
475 475 $ hg status -A --rev 0
476 476 C file
477 477
478 478 #if execbit
479 479 reverted file with changed flag should appear modified
480 480
481 481 $ chmod +x file
482 482 $ hg status -A --rev 0
483 483 M file
484 484
485 485 $ hg revert -r 0 .
486 486 reverting file
487 487
488 488 reverted and committed file with changed flag should appear modified
489 489
490 490 $ hg co -C .
491 491 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
492 492 $ chmod +x file
493 493 $ hg ci -m 'change flag'
494 494 $ hg status -A --rev 1 --rev 2
495 495 M file
496 496 $ hg diff -r 1 -r 2
497 497
498 498 #endif
499 499
500 500 $ cd ..
501 501
502 502 hg status of binary file starting with '\1\n', a separator for metadata:
503 503
504 504 $ hg init repo5
505 505 $ cd repo5
506 506 >>> open("010a", r"wb").write(b"\1\nfoo") and None
507 507 $ hg ci -q -A -m 'initial checkin'
508 508 $ hg status -A
509 509 C 010a
510 510
511 511 >>> open("010a", r"wb").write(b"\1\nbar") and None
512 512 $ hg status -A
513 513 M 010a
514 514 $ hg ci -q -m 'modify 010a'
515 515 $ hg status -A --rev 0:1
516 516 M 010a
517 517
518 518 $ touch empty
519 519 $ hg ci -q -A -m 'add another file'
520 520 $ hg status -A --rev 1:2 010a
521 521 C 010a
522 522
523 523 $ cd ..
524 524
525 525 test "hg status" with "directory pattern" which matches against files
526 526 only known on target revision.
527 527
528 528 $ hg init repo6
529 529 $ cd repo6
530 530
531 531 $ echo a > a.txt
532 532 $ hg add a.txt
533 533 $ hg commit -m '#0'
534 534 $ mkdir -p 1/2/3/4/5
535 535 $ echo b > 1/2/3/4/5/b.txt
536 536 $ hg add 1/2/3/4/5/b.txt
537 537 $ hg commit -m '#1'
538 538
539 539 $ hg update -C 0 > /dev/null
540 540 $ hg status -A
541 541 C a.txt
542 542
543 543 the directory matching against specified pattern should be removed,
544 544 because directory existence prevents 'dirstate.walk()' from showing
545 545 warning message about such pattern.
546 546
547 547 $ test ! -d 1
548 548 $ hg status -A --rev 1 1/2/3/4/5/b.txt
549 549 R 1/2/3/4/5/b.txt
550 550 $ hg status -A --rev 1 1/2/3/4/5
551 551 R 1/2/3/4/5/b.txt
552 552 $ hg status -A --rev 1 1/2/3
553 553 R 1/2/3/4/5/b.txt
554 554 $ hg status -A --rev 1 1
555 555 R 1/2/3/4/5/b.txt
556 556
557 557 $ hg status --config ui.formatdebug=True --rev 1 1
558 558 status = [
559 559 {
560 560 'path': '1/2/3/4/5/b.txt',
561 561 'status': 'R'
562 562 },
563 563 ]
564 564
565 565 #if windows
566 566 $ hg --config ui.slash=false status -A --rev 1 1
567 567 R 1\2\3\4\5\b.txt
568 568 #endif
569 569
570 570 $ cd ..
571 571
572 572 Status after move overwriting a file (issue4458)
573 573 =================================================
574 574
575 575
576 576 $ hg init issue4458
577 577 $ cd issue4458
578 578 $ echo a > a
579 579 $ echo b > b
580 580 $ hg commit -Am base
581 581 adding a
582 582 adding b
583 583
584 584
585 585 with --force
586 586
587 587 $ hg mv b --force a
588 588 $ hg st --copies
589 589 M a
590 590 b
591 591 R b
592 592 $ hg revert --all
593 593 reverting a
594 594 undeleting b
595 595 $ rm *.orig
596 596
597 597 without force
598 598
599 599 $ hg rm a
600 600 $ hg st --copies
601 601 R a
602 602 $ hg mv b a
603 603 $ hg st --copies
604 604 M a
605 605 b
606 606 R b
607 607
608 608 using ui.statuscopies setting
609 609 $ hg st --config ui.statuscopies=true
610 610 M a
611 611 b
612 612 R b
613 613 $ hg st --config ui.statuscopies=false
614 614 M a
615 615 R b
616 616 $ hg st --config ui.tweakdefaults=yes
617 617 M a
618 618 b
619 619 R b
620 620
621 621 using log status template (issue5155)
622 622 $ hg log -Tstatus -r 'wdir()' -C
623 623 changeset: 2147483647:ffffffffffff
624 624 parent: 0:8c55c58b4c0e
625 625 user: test
626 626 date: * (glob)
627 627 files:
628 628 M a
629 629 b
630 630 R b
631 631
632 632
633 633 Other "bug" highlight, the revision status does not report the copy information.
634 634 This is buggy behavior.
635 635
636 636 $ hg commit -m 'blah'
637 637 $ hg st --copies --change .
638 638 M a
639 639 R b
640 640
641 641 using log status template, the copy information is displayed correctly.
642 642 $ hg log -Tstatus -r. -C
643 643 changeset: 1:6685fde43d21
644 644 tag: tip
645 645 user: test
646 646 date: * (glob)
647 647 summary: blah
648 648 files:
649 649 M a
650 650 b
651 651 R b
652 652
653 653
654 654 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now