##// END OF EJS Templates
rhg: add test for bug with matchers in rhg status --rev --rev...
Mitchell Kember -
r53291:4e58b549 default
parent child Browse files
Show More
@@ -1,1051 +1,1072
1 1 #testcases dirstate-v1 dirstate-v2
2 2
3 3 #if dirstate-v2
4 4 $ cat >> $HGRCPATH << EOF
5 5 > [format]
6 6 > use-dirstate-v2=1
7 7 > [storage]
8 8 > dirstate-v2.slow-path=allow
9 9 > EOF
10 10 #endif
11 11
12 12 $ hg init repo1
13 13 $ cd repo1
14 14 $ mkdir a b a/1 b/1 b/2
15 15 $ touch in_root a/in_a b/in_b a/1/in_a_1 b/1/in_b_1 b/2/in_b_2
16 16
17 17 hg status in repo root:
18 18
19 19 $ hg status
20 20 ? a/1/in_a_1
21 21 ? a/in_a
22 22 ? b/1/in_b_1
23 23 ? b/2/in_b_2
24 24 ? b/in_b
25 25 ? in_root
26 26
27 27 hg status . in repo root:
28 28
29 29 $ hg status .
30 30 ? a/1/in_a_1
31 31 ? a/in_a
32 32 ? b/1/in_b_1
33 33 ? b/2/in_b_2
34 34 ? b/in_b
35 35 ? in_root
36 36
37 37 $ hg status --cwd a
38 38 ? a/1/in_a_1
39 39 ? a/in_a
40 40 ? b/1/in_b_1
41 41 ? b/2/in_b_2
42 42 ? b/in_b
43 43 ? in_root
44 44 $ hg status --cwd a .
45 45 ? 1/in_a_1
46 46 ? in_a
47 47 $ hg status --cwd a ..
48 48 ? 1/in_a_1
49 49 ? in_a
50 50 ? ../b/1/in_b_1
51 51 ? ../b/2/in_b_2
52 52 ? ../b/in_b
53 53 ? ../in_root
54 54
55 55 $ hg status --cwd b
56 56 ? a/1/in_a_1
57 57 ? a/in_a
58 58 ? b/1/in_b_1
59 59 ? b/2/in_b_2
60 60 ? b/in_b
61 61 ? in_root
62 62 $ hg status --cwd b .
63 63 ? 1/in_b_1
64 64 ? 2/in_b_2
65 65 ? in_b
66 66 $ hg status --cwd b ..
67 67 ? ../a/1/in_a_1
68 68 ? ../a/in_a
69 69 ? 1/in_b_1
70 70 ? 2/in_b_2
71 71 ? in_b
72 72 ? ../in_root
73 73
74 74 $ hg status --cwd a/1
75 75 ? a/1/in_a_1
76 76 ? a/in_a
77 77 ? b/1/in_b_1
78 78 ? b/2/in_b_2
79 79 ? b/in_b
80 80 ? in_root
81 81 $ hg status --cwd a/1 .
82 82 ? in_a_1
83 83 $ hg status --cwd a/1 ..
84 84 ? in_a_1
85 85 ? ../in_a
86 86
87 87 $ hg status --cwd b/1
88 88 ? a/1/in_a_1
89 89 ? a/in_a
90 90 ? b/1/in_b_1
91 91 ? b/2/in_b_2
92 92 ? b/in_b
93 93 ? in_root
94 94 $ hg status --cwd b/1 .
95 95 ? in_b_1
96 96 $ hg status --cwd b/1 ..
97 97 ? in_b_1
98 98 ? ../2/in_b_2
99 99 ? ../in_b
100 100
101 101 $ hg status --cwd b/2
102 102 ? a/1/in_a_1
103 103 ? a/in_a
104 104 ? b/1/in_b_1
105 105 ? b/2/in_b_2
106 106 ? b/in_b
107 107 ? in_root
108 108 $ hg status --cwd b/2 .
109 109 ? in_b_2
110 110 $ hg status --cwd b/2 ..
111 111 ? ../1/in_b_1
112 112 ? in_b_2
113 113 ? ../in_b
114 114
115 115 combining patterns with root and patterns without a root works
116 116
117 117 $ hg st a/in_a re:.*b$
118 118 ? a/in_a
119 119 ? b/in_b
120 120
121 121 tweaking defaults works
122 122 $ hg status --cwd a --config ui.tweakdefaults=yes
123 123 ? 1/in_a_1
124 124 ? in_a
125 125 ? ../b/1/in_b_1
126 126 ? ../b/2/in_b_2
127 127 ? ../b/in_b
128 128 ? ../in_root
129 129 $ HGPLAIN=1 hg status --cwd a --config ui.tweakdefaults=yes
130 130 ? a/1/in_a_1 (glob)
131 131 ? a/in_a (glob)
132 132 ? b/1/in_b_1 (glob)
133 133 ? b/2/in_b_2 (glob)
134 134 ? b/in_b (glob)
135 135 ? in_root
136 136 $ HGPLAINEXCEPT=tweakdefaults hg status --cwd a --config ui.tweakdefaults=yes
137 137 ? 1/in_a_1
138 138 ? in_a
139 139 ? ../b/1/in_b_1
140 140 ? ../b/2/in_b_2
141 141 ? ../b/in_b
142 142 ? ../in_root (glob)
143 143
144 144 relative paths can be requested
145 145
146 146 $ hg status --cwd a --config ui.relative-paths=yes
147 147 ? 1/in_a_1
148 148 ? in_a
149 149 ? ../b/1/in_b_1
150 150 ? ../b/2/in_b_2
151 151 ? ../b/in_b
152 152 ? ../in_root
153 153
154 154 $ hg status --cwd a . --config ui.relative-paths=legacy
155 155 ? 1/in_a_1
156 156 ? in_a
157 157 $ hg status --cwd a . --config ui.relative-paths=no
158 158 ? a/1/in_a_1
159 159 ? a/in_a
160 160
161 161 commands.status.relative overrides ui.relative-paths
162 162
163 163 $ cat >> $HGRCPATH <<EOF
164 164 > [ui]
165 165 > relative-paths = False
166 166 > [commands]
167 167 > status.relative = True
168 168 > EOF
169 169 $ hg status --cwd a
170 170 ? 1/in_a_1
171 171 ? in_a
172 172 ? ../b/1/in_b_1
173 173 ? ../b/2/in_b_2
174 174 ? ../b/in_b
175 175 ? ../in_root
176 176 $ HGPLAIN=1 hg status --cwd a
177 177 ? a/1/in_a_1 (glob)
178 178 ? a/in_a (glob)
179 179 ? b/1/in_b_1 (glob)
180 180 ? b/2/in_b_2 (glob)
181 181 ? b/in_b (glob)
182 182 ? in_root
183 183
184 184 if relative paths are explicitly off, tweakdefaults doesn't change it
185 185 $ cat >> $HGRCPATH <<EOF
186 186 > [commands]
187 187 > status.relative = False
188 188 > EOF
189 189 $ hg status --cwd a --config ui.tweakdefaults=yes
190 190 ? a/1/in_a_1
191 191 ? a/in_a
192 192 ? b/1/in_b_1
193 193 ? b/2/in_b_2
194 194 ? b/in_b
195 195 ? in_root
196 196
197 197 $ cd ..
198 198
199 199 $ hg init repo2
200 200 $ cd repo2
201 201 $ touch modified removed deleted ignored
202 202 $ echo "^ignored$" > .hgignore
203 203 $ hg ci -A -m 'initial checkin'
204 204 adding .hgignore
205 205 adding deleted
206 206 adding modified
207 207 adding removed
208 208 $ touch modified added unknown ignored
209 209 $ hg add added
210 210 $ hg remove removed
211 211 $ rm deleted
212 212
213 213 hg status:
214 214
215 215 $ hg status
216 216 A added
217 217 R removed
218 218 ! deleted
219 219 ? unknown
220 220
221 221 hg status -n:
222 222 $ env RHG_ON_UNSUPPORTED=abort hg status -n
223 223 added
224 224 removed
225 225 deleted
226 226 unknown
227 227
228 228 hg status modified added removed deleted unknown never-existed ignored:
229 229
230 230 $ hg status modified added removed deleted unknown never-existed ignored
231 231 never-existed: * (glob)
232 232 A added
233 233 R removed
234 234 ! deleted
235 235 ? unknown
236 236
237 237 $ hg copy modified copied
238 238
239 239 hg status -C:
240 240
241 241 $ hg status -C
242 242 A added
243 243 A copied
244 244 modified
245 245 R removed
246 246 ! deleted
247 247 ? unknown
248 248
249 249 hg status -0:
250 250
251 251 $ hg status -0 --config rhg.on-unsupported=abort
252 252 A added\x00A copied\x00R removed\x00! deleted\x00? unknown\x00 (no-eol) (esc)
253 253
254 254 hg status -A:
255 255
256 256 $ hg status -A
257 257 A added
258 258 A copied
259 259 modified
260 260 R removed
261 261 ! deleted
262 262 ? unknown
263 263 I ignored
264 264 C .hgignore
265 265 C modified
266 266
267 267 $ hg status -A -T '{status} {path} {node|shortest}\n'
268 268 A added ffff
269 269 A copied ffff
270 270 R removed ffff
271 271 ! deleted ffff
272 272 ? unknown ffff
273 273 I ignored ffff
274 274 C .hgignore ffff
275 275 C modified ffff
276 276
277 277 $ hg status -A -Tjson
278 278 [
279 279 {
280 280 "itemtype": "file",
281 281 "path": "added",
282 282 "status": "A"
283 283 },
284 284 {
285 285 "itemtype": "file",
286 286 "path": "copied",
287 287 "source": "modified",
288 288 "status": "A"
289 289 },
290 290 {
291 291 "itemtype": "file",
292 292 "path": "removed",
293 293 "status": "R"
294 294 },
295 295 {
296 296 "itemtype": "file",
297 297 "path": "deleted",
298 298 "status": "!"
299 299 },
300 300 {
301 301 "itemtype": "file",
302 302 "path": "unknown",
303 303 "status": "?"
304 304 },
305 305 {
306 306 "itemtype": "file",
307 307 "path": "ignored",
308 308 "status": "I"
309 309 },
310 310 {
311 311 "itemtype": "file",
312 312 "path": ".hgignore",
313 313 "status": "C"
314 314 },
315 315 {
316 316 "itemtype": "file",
317 317 "path": "modified",
318 318 "status": "C"
319 319 }
320 320 ]
321 321
322 322 $ hg status -A -Tpickle > pickle
323 323 >>> import pickle
324 324 >>> from mercurial import util
325 325 >>> data = sorted((x[b'status'].decode(), x[b'path'].decode()) for x in pickle.load(open("pickle", r"rb")))
326 326 >>> for s, p in data: print("%s %s" % (s, p))
327 327 ! deleted
328 328 ? pickle
329 329 ? unknown
330 330 A added
331 331 A copied
332 332 C .hgignore
333 333 C modified
334 334 I ignored
335 335 R removed
336 336 $ rm pickle
337 337
338 338 $ echo "^ignoreddir$" > .hgignore
339 339 $ mkdir ignoreddir
340 340 $ touch ignoreddir/file
341 341
342 342 Test templater support:
343 343
344 344 $ hg status -AT "[{status}]\t{if(source, '{source} -> ')}{path}\n"
345 345 [M] .hgignore
346 346 [A] added
347 347 [A] modified -> copied
348 348 [R] removed
349 349 [!] deleted
350 350 [?] ignored
351 351 [?] unknown
352 352 [I] ignoreddir/file
353 353 [C] modified
354 354 $ hg status -AT default
355 355 M .hgignore
356 356 A added
357 357 A copied
358 358 modified
359 359 R removed
360 360 ! deleted
361 361 ? ignored
362 362 ? unknown
363 363 I ignoreddir/file
364 364 C modified
365 365 $ hg status -T compact
366 366 abort: "status" not in template map
367 367 [255]
368 368
369 369 hg status ignoreddir/file:
370 370
371 371 $ hg status ignoreddir/file
372 372
373 373 hg status -i ignoreddir/file:
374 374
375 375 $ hg status -i ignoreddir/file
376 376 I ignoreddir/file
377 377 $ cd ..
378 378
379 379 Check 'status -q' and some combinations
380 380
381 381 $ hg init repo3
382 382 $ cd repo3
383 383 $ touch modified removed deleted ignored
384 384 $ echo "^ignored$" > .hgignore
385 385 $ hg commit -A -m 'initial checkin'
386 386 adding .hgignore
387 387 adding deleted
388 388 adding modified
389 389 adding removed
390 390 $ touch added unknown ignored
391 391 $ hg add added
392 392 $ echo "test" >> modified
393 393 $ hg remove removed
394 394 $ rm deleted
395 395 $ hg copy modified copied
396 396
397 397 Specify working directory revision explicitly, that should be the same as
398 398 "hg status"
399 399
400 400 $ hg status --change "wdir()"
401 401 M modified
402 402 A added
403 403 A copied
404 404 R removed
405 405 ! deleted
406 406 ? unknown
407 407
408 408 Run status with 2 different flags.
409 409 Check if result is the same or different.
410 410 If result is not as expected, raise error
411 411
412 412 $ assert() {
413 413 > hg status $1 > ../a
414 414 > hg status $2 > ../b
415 415 > if diff ../a ../b > /dev/null; then
416 416 > out=0
417 417 > else
418 418 > out=1
419 419 > fi
420 420 > if [ $3 -eq 0 ]; then
421 421 > df="same"
422 422 > else
423 423 > df="different"
424 424 > fi
425 425 > if [ $out -ne $3 ]; then
426 426 > echo "Error on $1 and $2, should be $df."
427 427 > fi
428 428 > }
429 429
430 430 Assert flag1 flag2 [0-same | 1-different]
431 431
432 432 $ assert "-q" "-mard" 0
433 433 $ assert "-A" "-marduicC" 0
434 434 $ assert "-qA" "-mardcC" 0
435 435 $ assert "-qAui" "-A" 0
436 436 $ assert "-qAu" "-marducC" 0
437 437 $ assert "-qAi" "-mardicC" 0
438 438 $ assert "-qu" "-u" 0
439 439 $ assert "-q" "-u" 1
440 440 $ assert "-m" "-a" 1
441 441 $ assert "-r" "-d" 1
442 442 $ cd ..
443 443
444 444 $ hg init repo4
445 445 $ cd repo4
446 446 $ touch modified removed deleted
447 447 $ hg ci -q -A -m 'initial checkin'
448 448 $ touch added unknown
449 449 $ hg add added
450 450 $ hg remove removed
451 451 $ rm deleted
452 452 $ echo x > modified
453 453 $ hg copy modified copied
454 454 $ hg ci -m 'test checkin' -d "1000001 0"
455 455 $ rm *
456 456 $ touch unrelated
457 457 $ hg ci -q -A -m 'unrelated checkin' -d "1000002 0"
458 458
459 459 hg status --change 1:
460 460
461 461 $ hg status --change 1
462 462 M modified
463 463 A added
464 464 A copied
465 465 R removed
466 466
467 467 hg status --change 1 unrelated:
468 468
469 469 $ hg status --change 1 unrelated
470 470
471 471 hg status -C --change 1 added modified copied removed deleted:
472 472
473 473 $ hg status -C --change 1 added modified copied removed deleted
474 474 M modified
475 475 A added
476 476 A copied
477 477 modified
478 478 R removed
479 479
480 480 hg status -A --change 1 and revset:
481 481
482 482 $ hg status -A --change '1|1'
483 483 M modified
484 484 A added
485 485 A copied
486 486 modified
487 487 R removed
488 488 C deleted
489 489
490 Like previous tests but using --rev --rev instead of --change:
491
492 $ hg status --rev 0 --rev 1
493 M modified
494 A added
495 A copied
496 R removed
497
498 $ hg status --rev 0 --rev 1 unrelated
499 M modified (known-bad-output rhg !)
500 A added (known-bad-output rhg !)
501 A copied (known-bad-output rhg !)
502 R removed (known-bad-output rhg !)
503
504 $ hg status -C --rev 0 --rev 1 added modified copied removed deleted
505 M modified
506 A added
507 A copied
508 modified
509 R removed
510
490 511 $ cd ..
491 512
492 513 hg status with --rev and reverted changes:
493 514
494 515 $ hg init reverted-changes-repo
495 516 $ cd reverted-changes-repo
496 517 $ echo a > file
497 518 $ hg add file
498 519 $ hg ci -m a
499 520 $ echo b > file
500 521 $ hg ci -m b
501 522
502 523 reverted file should appear clean
503 524
504 525 $ hg revert -r 0 .
505 526 reverting file
506 527 $ hg status -A --rev 0
507 528 C file
508 529
509 530 #if execbit
510 531 reverted file with changed flag should appear modified
511 532
512 533 $ chmod +x file
513 534 $ hg status -A --rev 0
514 535 M file
515 536
516 537 $ hg revert -r 0 .
517 538 reverting file
518 539
519 540 reverted and committed file with changed flag should appear modified
520 541
521 542 $ hg co -C .
522 543 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
523 544 $ chmod +x file
524 545 $ hg ci -m 'change flag'
525 546 $ hg status -A --rev 1 --rev 2
526 547 M file
527 548 $ hg diff -r 1 -r 2
528 549
529 550 #endif
530 551
531 552 $ cd ..
532 553
533 554 hg status of binary file starting with '\1\n', a separator for metadata:
534 555
535 556 $ hg init repo5
536 557 $ cd repo5
537 558 >>> open("010a", r"wb").write(b"\1\nfoo") and None
538 559 $ hg ci -q -A -m 'initial checkin'
539 560 $ hg status -A
540 561 C 010a
541 562
542 563 >>> open("010a", r"wb").write(b"\1\nbar") and None
543 564 $ hg status -A
544 565 M 010a
545 566 $ hg ci -q -m 'modify 010a'
546 567 $ hg status -A --rev 0:1
547 568 M 010a
548 569
549 570 $ touch empty
550 571 $ hg ci -q -A -m 'add another file'
551 572 $ hg status -A --rev 1:2 010a
552 573 C 010a
553 574
554 575 $ cd ..
555 576
556 577 test "hg status" with "directory pattern" which matches against files
557 578 only known on target revision.
558 579
559 580 $ hg init repo6
560 581 $ cd repo6
561 582
562 583 $ echo a > a.txt
563 584 $ hg add a.txt
564 585 $ hg commit -m '#0'
565 586 $ mkdir -p 1/2/3/4/5
566 587 $ echo b > 1/2/3/4/5/b.txt
567 588 $ hg add 1/2/3/4/5/b.txt
568 589 $ hg commit -m '#1'
569 590
570 591 $ hg update -C 0 > /dev/null
571 592 $ hg status -A
572 593 C a.txt
573 594
574 595 the directory matching against specified pattern should be removed,
575 596 because directory existence prevents 'dirstate.walk()' from showing
576 597 warning message about such pattern.
577 598
578 599 $ test ! -d 1
579 600 $ hg status -A --rev 1 1/2/3/4/5/b.txt
580 601 R 1/2/3/4/5/b.txt
581 602 $ hg status -A --rev 1 1/2/3/4/5
582 603 R 1/2/3/4/5/b.txt
583 604 $ hg status -A --rev 1 1/2/3
584 605 R 1/2/3/4/5/b.txt
585 606 $ hg status -A --rev 1 1
586 607 R 1/2/3/4/5/b.txt
587 608
588 609 $ hg status --config ui.formatdebug=True --rev 1 1
589 610 status = [
590 611 {
591 612 'itemtype': 'file',
592 613 'path': '1/2/3/4/5/b.txt',
593 614 'status': 'R'
594 615 },
595 616 ]
596 617
597 618 #if windows
598 619 $ hg --config ui.slash=false status -A --rev 1 1
599 620 R 1\2\3\4\5\b.txt
600 621 #endif
601 622
602 623 $ cd ..
603 624
604 625 Status after move overwriting a file (issue4458)
605 626 =================================================
606 627
607 628
608 629 $ hg init issue4458
609 630 $ cd issue4458
610 631 $ echo a > a
611 632 $ echo b > b
612 633 $ hg commit -Am base
613 634 adding a
614 635 adding b
615 636
616 637
617 638 with --force
618 639
619 640 $ hg mv b --force a
620 641 $ hg st --copies
621 642 M a
622 643 b
623 644 R b
624 645 $ hg revert --all
625 646 reverting a
626 647 undeleting b
627 648 $ rm *.orig
628 649
629 650 without force
630 651
631 652 $ hg rm a
632 653 $ hg st --copies
633 654 R a
634 655 $ hg mv b a
635 656 $ hg st --copies
636 657 M a
637 658 b
638 659 R b
639 660
640 661 using ui.statuscopies setting
641 662 $ hg st --config ui.statuscopies=true
642 663 M a
643 664 b
644 665 R b
645 666 $ hg st --config ui.statuscopies=true --no-copies
646 667 M a
647 668 R b
648 669 $ hg st --config ui.statuscopies=false
649 670 M a
650 671 R b
651 672 $ hg st --config ui.statuscopies=false --copies
652 673 M a
653 674 b
654 675 R b
655 676 $ hg st --config ui.tweakdefaults=yes
656 677 M a
657 678 b
658 679 R b
659 680
660 681 using log status template (issue5155)
661 682 $ hg log -Tstatus -r 'wdir()' -C
662 683 changeset: 2147483647:ffffffffffff
663 684 parent: 0:8c55c58b4c0e
664 685 user: test
665 686 date: * (glob)
666 687 files:
667 688 M a
668 689 b
669 690 R b
670 691
671 692 $ hg log -GTstatus -r 'wdir()' -C
672 693 o changeset: 2147483647:ffffffffffff
673 694 | parent: 0:8c55c58b4c0e
674 695 ~ user: test
675 696 date: * (glob)
676 697 files:
677 698 M a
678 699 b
679 700 R b
680 701
681 702
682 703 Other "bug" highlight, the revision status does not report the copy information.
683 704 This is buggy behavior.
684 705
685 706 $ hg commit -m 'blah'
686 707 $ hg st --copies --change .
687 708 M a
688 709 R b
689 710
690 711 using log status template, the copy information is displayed correctly.
691 712 $ hg log -Tstatus -r. -C
692 713 changeset: 1:6685fde43d21
693 714 tag: tip
694 715 user: test
695 716 date: * (glob)
696 717 summary: blah
697 718 files:
698 719 M a
699 720 b
700 721 R b
701 722
702 723
703 724 $ cd ..
704 725
705 726 Make sure .hg doesn't show up even as a symlink
706 727
707 728 $ hg init repo0
708 729 $ mkdir symlink-repo0
709 730 $ cd symlink-repo0
710 731 $ ln -s ../repo0/.hg
711 732 $ hg status
712 733
713 734 If the size hasn’t changed but mtime has, status needs to read the contents
714 735 of the file to check whether it has changed
715 736
716 737 $ echo 1 > a
717 738 $ echo 1 > b
718 739 $ touch -t 200102030000 a b
719 740 $ hg commit -Aqm '#0'
720 741 $ echo 2 > a
721 742 $ touch -t 200102040000 a b
722 743 $ hg status
723 744 M a
724 745
725 746 Asking specifically for the status of a deleted/removed file
726 747
727 748 $ rm a
728 749 $ rm b
729 750 $ hg status a
730 751 ! a
731 752 $ hg rm a
732 753 $ hg rm b
733 754 $ hg status a
734 755 R a
735 756 $ hg commit -qm '#1'
736 757 $ hg status a
737 758 a: $ENOENT$
738 759
739 760 Check using include flag with pattern when status does not need to traverse
740 761 the working directory (issue6483)
741 762
742 763 $ cd ..
743 764 $ hg init issue6483
744 765 $ cd issue6483
745 766 $ touch a.py b.rs
746 767 $ hg add a.py b.rs
747 768 $ hg st -aI "*.py"
748 769 A a.py
749 770
750 771 Also check exclude pattern
751 772
752 773 $ hg st -aX "*.rs"
753 774 A a.py
754 775
755 776 issue6335
756 777 When a directory containing a tracked file gets symlinked, as of 5.8
757 778 `hg st` only gives the correct answer about clean (or deleted) files
758 779 if also listing unknowns.
759 780 The tree-based dirstate and status algorithm fix this:
760 781
761 782 #if symlink no-dirstate-v1 rust
762 783
763 784 $ cd ..
764 785 $ hg init issue6335
765 786 $ cd issue6335
766 787 $ mkdir foo
767 788 $ touch foo/a
768 789 $ hg ci -Ama
769 790 adding foo/a
770 791 $ mv foo bar
771 792 $ ln -s bar foo
772 793 $ hg status
773 794 ! foo/a
774 795 ? bar/a
775 796 ? foo
776 797
777 798 $ hg status -c # incorrect output without the Rust implementation
778 799 $ hg status -cu
779 800 ? bar/a
780 801 ? foo
781 802 $ hg status -d # incorrect output without the Rust implementation
782 803 ! foo/a
783 804 $ hg status -du
784 805 ! foo/a
785 806 ? bar/a
786 807 ? foo
787 808
788 809 #endif
789 810
790 811
791 812 Create a repo with files in each possible status
792 813
793 814 $ cd ..
794 815 $ hg init repo7
795 816 $ cd repo7
796 817 $ mkdir subdir
797 818 $ touch clean modified deleted removed
798 819 $ touch subdir/clean subdir/modified subdir/deleted subdir/removed
799 820 $ echo ignored > .hgignore
800 821 $ hg ci -Aqm '#0'
801 822 $ echo 1 > modified
802 823 $ echo 1 > subdir/modified
803 824 $ rm deleted
804 825 $ rm subdir/deleted
805 826 $ hg rm removed
806 827 $ hg rm subdir/removed
807 828 $ touch unknown ignored
808 829 $ touch subdir/unknown subdir/ignored
809 830
810 831 Check the output
811 832
812 833 $ hg status
813 834 M modified
814 835 M subdir/modified
815 836 R removed
816 837 R subdir/removed
817 838 ! deleted
818 839 ! subdir/deleted
819 840 ? subdir/unknown
820 841 ? unknown
821 842
822 843 $ hg status -mard
823 844 M modified
824 845 M subdir/modified
825 846 R removed
826 847 R subdir/removed
827 848 ! deleted
828 849 ! subdir/deleted
829 850
830 851 $ hg status -A
831 852 M modified
832 853 M subdir/modified
833 854 R removed
834 855 R subdir/removed
835 856 ! deleted
836 857 ! subdir/deleted
837 858 ? subdir/unknown
838 859 ? unknown
839 860 I ignored
840 861 I subdir/ignored
841 862 C .hgignore
842 863 C clean
843 864 C subdir/clean
844 865
845 866 Test various matchers interatction with dirstate code:
846 867
847 868 $ hg status path:subdir
848 869 M subdir/modified
849 870 R subdir/removed
850 871 ! subdir/deleted
851 872 ? subdir/unknown
852 873
853 874 $ hg status 'glob:subdir/*'
854 875 M subdir/modified
855 876 R subdir/removed
856 877 ! subdir/deleted
857 878 ? subdir/unknown
858 879
859 880 $ hg status rootfilesin:subdir
860 881 M subdir/modified
861 882 R subdir/removed
862 883 ! subdir/deleted
863 884 ? subdir/unknown
864 885
865 886 Note: `hg status some-name` creates a patternmatcher which is not supported
866 887 yet by the Rust implementation of status, but includematcher is supported.
867 888 --include is used below for that reason
868 889
869 890 #if unix-permissions
870 891
871 892 Not having permission to read a directory that contains tracked files makes
872 893 status emit a warning then behave as if the directory was empty or removed
873 894 entirely:
874 895
875 896 $ chmod 0 subdir
876 897 $ hg status --include subdir
877 898 subdir: $EACCES$
878 899 R subdir/removed
879 900 ! subdir/clean
880 901 ! subdir/deleted
881 902 ! subdir/modified
882 903 $ chmod 755 subdir
883 904
884 905 #endif
885 906
886 907 Remove a directory that contains tracked files
887 908
888 909 $ rm -r subdir
889 910 $ hg status --include subdir
890 911 R subdir/removed
891 912 ! subdir/clean
892 913 ! subdir/deleted
893 914 ! subdir/modified
894 915
895 916 … and replace it by a file
896 917
897 918 $ touch subdir
898 919 $ hg status --include subdir
899 920 R subdir/removed
900 921 ! subdir/clean
901 922 ! subdir/deleted
902 923 ! subdir/modified
903 924 ? subdir
904 925
905 926 Replaced a deleted or removed file with a directory
906 927
907 928 $ mkdir deleted removed
908 929 $ touch deleted/1 removed/1
909 930 $ hg status --include deleted --include removed
910 931 R removed
911 932 ! deleted
912 933 ? deleted/1
913 934 ? removed/1
914 935 $ hg add removed/1
915 936 $ hg status --include deleted --include removed
916 937 A removed/1
917 938 R removed
918 939 ! deleted
919 940 ? deleted/1
920 941
921 942 Deeply nested files in an ignored directory are still listed on request
922 943
923 944 $ echo ignored-dir >> .hgignore
924 945 $ mkdir ignored-dir
925 946 $ mkdir ignored-dir/subdir
926 947 $ touch ignored-dir/subdir/1
927 948 $ hg status --ignored
928 949 I ignored
929 950 I ignored-dir/subdir/1
930 951
931 952 Check using include flag while listing ignored composes correctly (issue6514)
932 953
933 954 $ cd ..
934 955 $ hg init issue6514
935 956 $ cd issue6514
936 957 $ mkdir ignored-folder
937 958 $ touch A.hs B.hs C.hs ignored-folder/other.txt ignored-folder/ctest.hs
938 959 $ cat >.hgignore <<EOF
939 960 > A.hs
940 961 > B.hs
941 962 > ignored-folder/
942 963 > EOF
943 964 $ hg st -i -I 're:.*\.hs$'
944 965 I A.hs
945 966 I B.hs
946 967 I ignored-folder/ctest.hs
947 968
948 969 #if rust dirstate-v2
949 970
950 971 Check read_dir caching
951 972
952 973 $ cd ..
953 974 $ hg init repo8
954 975 $ cd repo8
955 976 $ mkdir subdir
956 977 $ touch subdir/a subdir/b
957 978 $ hg ci -Aqm '#0'
958 979
959 980 The cached mtime is initially unset
960 981
961 982 $ hg debugdirstate --all --no-dates | grep '^ '
962 983 0 -1 unset subdir
963 984
964 985 It is still not set when there are unknown files
965 986
966 987 $ touch subdir/unknown
967 988 $ hg status
968 989 ? subdir/unknown
969 990 $ hg debugdirstate --all --no-dates | grep '^ '
970 991 0 -1 unset subdir
971 992
972 993 Now the directory is eligible for caching, so its mtime is saved in the dirstate
973 994
974 995 $ rm subdir/unknown
975 996 $ sleep 0.1 # ensure the kernel’s internal clock for mtimes has ticked
976 997 $ hg status
977 998 $ hg debugdirstate --all --no-dates | grep '^ '
978 999 0 -1 set subdir
979 1000
980 1001 This time the command should be ever so slightly faster since it does not need `read_dir("subdir")`
981 1002
982 1003 $ hg status
983 1004
984 1005 Creating a new file changes the directory’s mtime, invalidating the cache
985 1006
986 1007 $ touch subdir/unknown
987 1008 $ hg status
988 1009 ? subdir/unknown
989 1010
990 1011 $ rm subdir/unknown
991 1012 $ hg status
992 1013
993 1014 Removing a node from the dirstate resets the cache for its parent directory
994 1015
995 1016 $ hg forget subdir/a
996 1017 $ hg debugdirstate --all --no-dates | grep '^ '
997 1018 0 -1 set subdir
998 1019 $ hg ci -qm '#1'
999 1020 $ hg debugdirstate --all --no-dates | grep '^ '
1000 1021 0 -1 unset subdir
1001 1022 $ hg status
1002 1023 ? subdir/a
1003 1024
1004 1025 Changing the hgignore rules makes us recompute the status (and rewrite the dirstate).
1005 1026
1006 1027 $ rm subdir/a
1007 1028 $ mkdir another-subdir
1008 1029 $ touch another-subdir/something-else
1009 1030
1010 1031 $ cat > "$TESTTMP"/extra-hgignore <<EOF
1011 1032 > something-else
1012 1033 > EOF
1013 1034
1014 1035 $ hg status --config ui.ignore.global="$TESTTMP"/extra-hgignore
1015 1036 $ hg debugdirstate --all --no-dates | grep '^ '
1016 1037 0 -1 set subdir
1017 1038
1018 1039 $ hg status
1019 1040 ? another-subdir/something-else
1020 1041
1021 1042 One invocation of status is enough to populate the cache even if it's invalidated
1022 1043 in the same run.
1023 1044
1024 1045 $ hg debugdirstate --all --no-dates | grep '^ '
1025 1046 0 -1 set subdir
1026 1047
1027 1048 #endif
1028 1049
1029 1050
1030 1051 Test copy source formatting.
1031 1052 $ cd ..
1032 1053 $ hg init copy-source-repo
1033 1054 $ cd copy-source-repo
1034 1055 $ mkdir -p foo/bar
1035 1056 $ cd foo/bar
1036 1057 $ touch file
1037 1058 $ hg addremove
1038 1059 adding foo/bar/file
1039 1060 $ hg commit -m 'add file'
1040 1061 $ hg mv file copy
1041 1062
1042 1063 Copy source respects relative path setting.
1043 1064 $ hg st --config ui.statuscopies=true --config commands.status.relative=true
1044 1065 A copy
1045 1066 file
1046 1067 R file
1047 1068
1048 1069 Copy source is not shown when --no-status is passed.
1049 1070 $ hg st --config ui.statuscopies=true --no-status
1050 1071 foo/bar/copy
1051 1072 foo/bar/file
General Comments 0
You need to be logged in to leave comments. Login now