##// END OF EJS Templates
tests: stop creating temporary files in TESTDIR
Arseniy Alekseyev -
r50503:2af928d6 stable
parent child Browse files
Show More
@@ -1,1002 +1,1002 b''
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 -A:
250 250
251 251 $ hg status -A
252 252 A added
253 253 A copied
254 254 modified
255 255 R removed
256 256 ! deleted
257 257 ? unknown
258 258 I ignored
259 259 C .hgignore
260 260 C modified
261 261
262 262 $ hg status -A -T '{status} {path} {node|shortest}\n'
263 263 A added ffff
264 264 A copied ffff
265 265 R removed ffff
266 266 ! deleted ffff
267 267 ? unknown ffff
268 268 I ignored ffff
269 269 C .hgignore ffff
270 270 C modified ffff
271 271
272 272 $ hg status -A -Tjson
273 273 [
274 274 {
275 275 "itemtype": "file",
276 276 "path": "added",
277 277 "status": "A"
278 278 },
279 279 {
280 280 "itemtype": "file",
281 281 "path": "copied",
282 282 "source": "modified",
283 283 "status": "A"
284 284 },
285 285 {
286 286 "itemtype": "file",
287 287 "path": "removed",
288 288 "status": "R"
289 289 },
290 290 {
291 291 "itemtype": "file",
292 292 "path": "deleted",
293 293 "status": "!"
294 294 },
295 295 {
296 296 "itemtype": "file",
297 297 "path": "unknown",
298 298 "status": "?"
299 299 },
300 300 {
301 301 "itemtype": "file",
302 302 "path": "ignored",
303 303 "status": "I"
304 304 },
305 305 {
306 306 "itemtype": "file",
307 307 "path": ".hgignore",
308 308 "status": "C"
309 309 },
310 310 {
311 311 "itemtype": "file",
312 312 "path": "modified",
313 313 "status": "C"
314 314 }
315 315 ]
316 316
317 317 $ hg status -A -Tpickle > pickle
318 318 >>> import pickle
319 319 >>> from mercurial import util
320 320 >>> data = sorted((x[b'status'].decode(), x[b'path'].decode()) for x in pickle.load(open("pickle", r"rb")))
321 321 >>> for s, p in data: print("%s %s" % (s, p))
322 322 ! deleted
323 323 ? pickle
324 324 ? unknown
325 325 A added
326 326 A copied
327 327 C .hgignore
328 328 C modified
329 329 I ignored
330 330 R removed
331 331 $ rm pickle
332 332
333 333 $ echo "^ignoreddir$" > .hgignore
334 334 $ mkdir ignoreddir
335 335 $ touch ignoreddir/file
336 336
337 337 Test templater support:
338 338
339 339 $ hg status -AT "[{status}]\t{if(source, '{source} -> ')}{path}\n"
340 340 [M] .hgignore
341 341 [A] added
342 342 [A] modified -> copied
343 343 [R] removed
344 344 [!] deleted
345 345 [?] ignored
346 346 [?] unknown
347 347 [I] ignoreddir/file
348 348 [C] modified
349 349 $ hg status -AT default
350 350 M .hgignore
351 351 A added
352 352 A copied
353 353 modified
354 354 R removed
355 355 ! deleted
356 356 ? ignored
357 357 ? unknown
358 358 I ignoreddir/file
359 359 C modified
360 360 $ hg status -T compact
361 361 abort: "status" not in template map
362 362 [255]
363 363
364 364 hg status ignoreddir/file:
365 365
366 366 $ hg status ignoreddir/file
367 367
368 368 hg status -i ignoreddir/file:
369 369
370 370 $ hg status -i ignoreddir/file
371 371 I ignoreddir/file
372 372 $ cd ..
373 373
374 374 Check 'status -q' and some combinations
375 375
376 376 $ hg init repo3
377 377 $ cd repo3
378 378 $ touch modified removed deleted ignored
379 379 $ echo "^ignored$" > .hgignore
380 380 $ hg commit -A -m 'initial checkin'
381 381 adding .hgignore
382 382 adding deleted
383 383 adding modified
384 384 adding removed
385 385 $ touch added unknown ignored
386 386 $ hg add added
387 387 $ echo "test" >> modified
388 388 $ hg remove removed
389 389 $ rm deleted
390 390 $ hg copy modified copied
391 391
392 392 Specify working directory revision explicitly, that should be the same as
393 393 "hg status"
394 394
395 395 $ hg status --change "wdir()"
396 396 M modified
397 397 A added
398 398 A copied
399 399 R removed
400 400 ! deleted
401 401 ? unknown
402 402
403 403 Run status with 2 different flags.
404 404 Check if result is the same or different.
405 405 If result is not as expected, raise error
406 406
407 407 $ assert() {
408 408 > hg status $1 > ../a
409 409 > hg status $2 > ../b
410 410 > if diff ../a ../b > /dev/null; then
411 411 > out=0
412 412 > else
413 413 > out=1
414 414 > fi
415 415 > if [ $3 -eq 0 ]; then
416 416 > df="same"
417 417 > else
418 418 > df="different"
419 419 > fi
420 420 > if [ $out -ne $3 ]; then
421 421 > echo "Error on $1 and $2, should be $df."
422 422 > fi
423 423 > }
424 424
425 425 Assert flag1 flag2 [0-same | 1-different]
426 426
427 427 $ assert "-q" "-mard" 0
428 428 $ assert "-A" "-marduicC" 0
429 429 $ assert "-qA" "-mardcC" 0
430 430 $ assert "-qAui" "-A" 0
431 431 $ assert "-qAu" "-marducC" 0
432 432 $ assert "-qAi" "-mardicC" 0
433 433 $ assert "-qu" "-u" 0
434 434 $ assert "-q" "-u" 1
435 435 $ assert "-m" "-a" 1
436 436 $ assert "-r" "-d" 1
437 437 $ cd ..
438 438
439 439 $ hg init repo4
440 440 $ cd repo4
441 441 $ touch modified removed deleted
442 442 $ hg ci -q -A -m 'initial checkin'
443 443 $ touch added unknown
444 444 $ hg add added
445 445 $ hg remove removed
446 446 $ rm deleted
447 447 $ echo x > modified
448 448 $ hg copy modified copied
449 449 $ hg ci -m 'test checkin' -d "1000001 0"
450 450 $ rm *
451 451 $ touch unrelated
452 452 $ hg ci -q -A -m 'unrelated checkin' -d "1000002 0"
453 453
454 454 hg status --change 1:
455 455
456 456 $ hg status --change 1
457 457 M modified
458 458 A added
459 459 A copied
460 460 R removed
461 461
462 462 hg status --change 1 unrelated:
463 463
464 464 $ hg status --change 1 unrelated
465 465
466 466 hg status -C --change 1 added modified copied removed deleted:
467 467
468 468 $ hg status -C --change 1 added modified copied removed deleted
469 469 M modified
470 470 A added
471 471 A copied
472 472 modified
473 473 R removed
474 474
475 475 hg status -A --change 1 and revset:
476 476
477 477 $ hg status -A --change '1|1'
478 478 M modified
479 479 A added
480 480 A copied
481 481 modified
482 482 R removed
483 483 C deleted
484 484
485 485 $ cd ..
486 486
487 487 hg status with --rev and reverted changes:
488 488
489 489 $ hg init reverted-changes-repo
490 490 $ cd reverted-changes-repo
491 491 $ echo a > file
492 492 $ hg add file
493 493 $ hg ci -m a
494 494 $ echo b > file
495 495 $ hg ci -m b
496 496
497 497 reverted file should appear clean
498 498
499 499 $ hg revert -r 0 .
500 500 reverting file
501 501 $ hg status -A --rev 0
502 502 C file
503 503
504 504 #if execbit
505 505 reverted file with changed flag should appear modified
506 506
507 507 $ chmod +x file
508 508 $ hg status -A --rev 0
509 509 M file
510 510
511 511 $ hg revert -r 0 .
512 512 reverting file
513 513
514 514 reverted and committed file with changed flag should appear modified
515 515
516 516 $ hg co -C .
517 517 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
518 518 $ chmod +x file
519 519 $ hg ci -m 'change flag'
520 520 $ hg status -A --rev 1 --rev 2
521 521 M file
522 522 $ hg diff -r 1 -r 2
523 523
524 524 #endif
525 525
526 526 $ cd ..
527 527
528 528 hg status of binary file starting with '\1\n', a separator for metadata:
529 529
530 530 $ hg init repo5
531 531 $ cd repo5
532 532 >>> open("010a", r"wb").write(b"\1\nfoo") and None
533 533 $ hg ci -q -A -m 'initial checkin'
534 534 $ hg status -A
535 535 C 010a
536 536
537 537 >>> open("010a", r"wb").write(b"\1\nbar") and None
538 538 $ hg status -A
539 539 M 010a
540 540 $ hg ci -q -m 'modify 010a'
541 541 $ hg status -A --rev 0:1
542 542 M 010a
543 543
544 544 $ touch empty
545 545 $ hg ci -q -A -m 'add another file'
546 546 $ hg status -A --rev 1:2 010a
547 547 C 010a
548 548
549 549 $ cd ..
550 550
551 551 test "hg status" with "directory pattern" which matches against files
552 552 only known on target revision.
553 553
554 554 $ hg init repo6
555 555 $ cd repo6
556 556
557 557 $ echo a > a.txt
558 558 $ hg add a.txt
559 559 $ hg commit -m '#0'
560 560 $ mkdir -p 1/2/3/4/5
561 561 $ echo b > 1/2/3/4/5/b.txt
562 562 $ hg add 1/2/3/4/5/b.txt
563 563 $ hg commit -m '#1'
564 564
565 565 $ hg update -C 0 > /dev/null
566 566 $ hg status -A
567 567 C a.txt
568 568
569 569 the directory matching against specified pattern should be removed,
570 570 because directory existence prevents 'dirstate.walk()' from showing
571 571 warning message about such pattern.
572 572
573 573 $ test ! -d 1
574 574 $ hg status -A --rev 1 1/2/3/4/5/b.txt
575 575 R 1/2/3/4/5/b.txt
576 576 $ hg status -A --rev 1 1/2/3/4/5
577 577 R 1/2/3/4/5/b.txt
578 578 $ hg status -A --rev 1 1/2/3
579 579 R 1/2/3/4/5/b.txt
580 580 $ hg status -A --rev 1 1
581 581 R 1/2/3/4/5/b.txt
582 582
583 583 $ hg status --config ui.formatdebug=True --rev 1 1
584 584 status = [
585 585 {
586 586 'itemtype': 'file',
587 587 'path': '1/2/3/4/5/b.txt',
588 588 'status': 'R'
589 589 },
590 590 ]
591 591
592 592 #if windows
593 593 $ hg --config ui.slash=false status -A --rev 1 1
594 594 R 1\2\3\4\5\b.txt
595 595 #endif
596 596
597 597 $ cd ..
598 598
599 599 Status after move overwriting a file (issue4458)
600 600 =================================================
601 601
602 602
603 603 $ hg init issue4458
604 604 $ cd issue4458
605 605 $ echo a > a
606 606 $ echo b > b
607 607 $ hg commit -Am base
608 608 adding a
609 609 adding b
610 610
611 611
612 612 with --force
613 613
614 614 $ hg mv b --force a
615 615 $ hg st --copies
616 616 M a
617 617 b
618 618 R b
619 619 $ hg revert --all
620 620 reverting a
621 621 undeleting b
622 622 $ rm *.orig
623 623
624 624 without force
625 625
626 626 $ hg rm a
627 627 $ hg st --copies
628 628 R a
629 629 $ hg mv b a
630 630 $ hg st --copies
631 631 M a
632 632 b
633 633 R b
634 634
635 635 using ui.statuscopies setting
636 636 $ hg st --config ui.statuscopies=true
637 637 M a
638 638 b
639 639 R b
640 640 $ hg st --config ui.statuscopies=true --no-copies
641 641 M a
642 642 R b
643 643 $ hg st --config ui.statuscopies=false
644 644 M a
645 645 R b
646 646 $ hg st --config ui.statuscopies=false --copies
647 647 M a
648 648 b
649 649 R b
650 650 $ hg st --config ui.tweakdefaults=yes
651 651 M a
652 652 b
653 653 R b
654 654
655 655 using log status template (issue5155)
656 656 $ hg log -Tstatus -r 'wdir()' -C
657 657 changeset: 2147483647:ffffffffffff
658 658 parent: 0:8c55c58b4c0e
659 659 user: test
660 660 date: * (glob)
661 661 files:
662 662 M a
663 663 b
664 664 R b
665 665
666 666 $ hg log -GTstatus -r 'wdir()' -C
667 667 o changeset: 2147483647:ffffffffffff
668 668 | parent: 0:8c55c58b4c0e
669 669 ~ user: test
670 670 date: * (glob)
671 671 files:
672 672 M a
673 673 b
674 674 R b
675 675
676 676
677 677 Other "bug" highlight, the revision status does not report the copy information.
678 678 This is buggy behavior.
679 679
680 680 $ hg commit -m 'blah'
681 681 $ hg st --copies --change .
682 682 M a
683 683 R b
684 684
685 685 using log status template, the copy information is displayed correctly.
686 686 $ hg log -Tstatus -r. -C
687 687 changeset: 1:6685fde43d21
688 688 tag: tip
689 689 user: test
690 690 date: * (glob)
691 691 summary: blah
692 692 files:
693 693 M a
694 694 b
695 695 R b
696 696
697 697
698 698 $ cd ..
699 699
700 700 Make sure .hg doesn't show up even as a symlink
701 701
702 702 $ hg init repo0
703 703 $ mkdir symlink-repo0
704 704 $ cd symlink-repo0
705 705 $ ln -s ../repo0/.hg
706 706 $ hg status
707 707
708 708 If the size hasn’t changed but mtime has, status needs to read the contents
709 709 of the file to check whether it has changed
710 710
711 711 $ echo 1 > a
712 712 $ echo 1 > b
713 713 $ touch -t 200102030000 a b
714 714 $ hg commit -Aqm '#0'
715 715 $ echo 2 > a
716 716 $ touch -t 200102040000 a b
717 717 $ hg status
718 718 M a
719 719
720 720 Asking specifically for the status of a deleted/removed file
721 721
722 722 $ rm a
723 723 $ rm b
724 724 $ hg status a
725 725 ! a
726 726 $ hg rm a
727 727 $ hg rm b
728 728 $ hg status a
729 729 R a
730 730 $ hg commit -qm '#1'
731 731 $ hg status a
732 732 a: $ENOENT$
733 733
734 734 Check using include flag with pattern when status does not need to traverse
735 735 the working directory (issue6483)
736 736
737 737 $ cd ..
738 738 $ hg init issue6483
739 739 $ cd issue6483
740 740 $ touch a.py b.rs
741 741 $ hg add a.py b.rs
742 742 $ hg st -aI "*.py"
743 743 A a.py
744 744
745 745 Also check exclude pattern
746 746
747 747 $ hg st -aX "*.rs"
748 748 A a.py
749 749
750 750 issue6335
751 751 When a directory containing a tracked file gets symlinked, as of 5.8
752 752 `hg st` only gives the correct answer about clean (or deleted) files
753 753 if also listing unknowns.
754 754 The tree-based dirstate and status algorithm fix this:
755 755
756 756 #if symlink no-dirstate-v1 rust
757 757
758 758 $ cd ..
759 759 $ hg init issue6335
760 760 $ cd issue6335
761 761 $ mkdir foo
762 762 $ touch foo/a
763 763 $ hg ci -Ama
764 764 adding foo/a
765 765 $ mv foo bar
766 766 $ ln -s bar foo
767 767 $ hg status
768 768 ! foo/a
769 769 ? bar/a
770 770 ? foo
771 771
772 772 $ hg status -c # incorrect output without the Rust implementation
773 773 $ hg status -cu
774 774 ? bar/a
775 775 ? foo
776 776 $ hg status -d # incorrect output without the Rust implementation
777 777 ! foo/a
778 778 $ hg status -du
779 779 ! foo/a
780 780 ? bar/a
781 781 ? foo
782 782
783 783 #endif
784 784
785 785
786 786 Create a repo with files in each possible status
787 787
788 788 $ cd ..
789 789 $ hg init repo7
790 790 $ cd repo7
791 791 $ mkdir subdir
792 792 $ touch clean modified deleted removed
793 793 $ touch subdir/clean subdir/modified subdir/deleted subdir/removed
794 794 $ echo ignored > .hgignore
795 795 $ hg ci -Aqm '#0'
796 796 $ echo 1 > modified
797 797 $ echo 1 > subdir/modified
798 798 $ rm deleted
799 799 $ rm subdir/deleted
800 800 $ hg rm removed
801 801 $ hg rm subdir/removed
802 802 $ touch unknown ignored
803 803 $ touch subdir/unknown subdir/ignored
804 804
805 805 Check the output
806 806
807 807 $ hg status
808 808 M modified
809 809 M subdir/modified
810 810 R removed
811 811 R subdir/removed
812 812 ! deleted
813 813 ! subdir/deleted
814 814 ? subdir/unknown
815 815 ? unknown
816 816
817 817 $ hg status -mard
818 818 M modified
819 819 M subdir/modified
820 820 R removed
821 821 R subdir/removed
822 822 ! deleted
823 823 ! subdir/deleted
824 824
825 825 $ hg status -A
826 826 M modified
827 827 M subdir/modified
828 828 R removed
829 829 R subdir/removed
830 830 ! deleted
831 831 ! subdir/deleted
832 832 ? subdir/unknown
833 833 ? unknown
834 834 I ignored
835 835 I subdir/ignored
836 836 C .hgignore
837 837 C clean
838 838 C subdir/clean
839 839
840 840 Note: `hg status some-name` creates a patternmatcher which is not supported
841 841 yet by the Rust implementation of status, but includematcher is supported.
842 842 --include is used below for that reason
843 843
844 844 #if unix-permissions
845 845
846 846 Not having permission to read a directory that contains tracked files makes
847 847 status emit a warning then behave as if the directory was empty or removed
848 848 entirely:
849 849
850 850 $ chmod 0 subdir
851 851 $ hg status --include subdir
852 852 subdir: Permission denied
853 853 R subdir/removed
854 854 ! subdir/clean
855 855 ! subdir/deleted
856 856 ! subdir/modified
857 857 $ chmod 755 subdir
858 858
859 859 #endif
860 860
861 861 Remove a directory that contains tracked files
862 862
863 863 $ rm -r subdir
864 864 $ hg status --include subdir
865 865 R subdir/removed
866 866 ! subdir/clean
867 867 ! subdir/deleted
868 868 ! subdir/modified
869 869
870 870 … and replace it by a file
871 871
872 872 $ touch subdir
873 873 $ hg status --include subdir
874 874 R subdir/removed
875 875 ! subdir/clean
876 876 ! subdir/deleted
877 877 ! subdir/modified
878 878 ? subdir
879 879
880 880 Replaced a deleted or removed file with a directory
881 881
882 882 $ mkdir deleted removed
883 883 $ touch deleted/1 removed/1
884 884 $ hg status --include deleted --include removed
885 885 R removed
886 886 ! deleted
887 887 ? deleted/1
888 888 ? removed/1
889 889 $ hg add removed/1
890 890 $ hg status --include deleted --include removed
891 891 A removed/1
892 892 R removed
893 893 ! deleted
894 894 ? deleted/1
895 895
896 896 Deeply nested files in an ignored directory are still listed on request
897 897
898 898 $ echo ignored-dir >> .hgignore
899 899 $ mkdir ignored-dir
900 900 $ mkdir ignored-dir/subdir
901 901 $ touch ignored-dir/subdir/1
902 902 $ hg status --ignored
903 903 I ignored
904 904 I ignored-dir/subdir/1
905 905
906 906 Check using include flag while listing ignored composes correctly (issue6514)
907 907
908 908 $ cd ..
909 909 $ hg init issue6514
910 910 $ cd issue6514
911 911 $ mkdir ignored-folder
912 912 $ touch A.hs B.hs C.hs ignored-folder/other.txt ignored-folder/ctest.hs
913 913 $ cat >.hgignore <<EOF
914 914 > A.hs
915 915 > B.hs
916 916 > ignored-folder/
917 917 > EOF
918 918 $ hg st -i -I 're:.*\.hs$'
919 919 I A.hs
920 920 I B.hs
921 921 I ignored-folder/ctest.hs
922 922
923 923 #if rust dirstate-v2
924 924
925 925 Check read_dir caching
926 926
927 927 $ cd ..
928 928 $ hg init repo8
929 929 $ cd repo8
930 930 $ mkdir subdir
931 931 $ touch subdir/a subdir/b
932 932 $ hg ci -Aqm '#0'
933 933
934 934 The cached mtime is initially unset
935 935
936 936 $ hg debugdirstate --all --no-dates | grep '^ '
937 937 0 -1 unset subdir
938 938
939 939 It is still not set when there are unknown files
940 940
941 941 $ touch subdir/unknown
942 942 $ hg status
943 943 ? subdir/unknown
944 944 $ hg debugdirstate --all --no-dates | grep '^ '
945 945 0 -1 unset subdir
946 946
947 947 Now the directory is eligible for caching, so its mtime is saved in the dirstate
948 948
949 949 $ rm subdir/unknown
950 950 $ sleep 0.1 # ensure the kernel’s internal clock for mtimes has ticked
951 951 $ hg status
952 952 $ hg debugdirstate --all --no-dates | grep '^ '
953 953 0 -1 set subdir
954 954
955 955 This time the command should be ever so slightly faster since it does not need `read_dir("subdir")`
956 956
957 957 $ hg status
958 958
959 959 Creating a new file changes the directory’s mtime, invalidating the cache
960 960
961 961 $ touch subdir/unknown
962 962 $ hg status
963 963 ? subdir/unknown
964 964
965 965 $ rm subdir/unknown
966 966 $ hg status
967 967
968 968 Removing a node from the dirstate resets the cache for its parent directory
969 969
970 970 $ hg forget subdir/a
971 971 $ hg debugdirstate --all --no-dates | grep '^ '
972 972 0 -1 set subdir
973 973 $ hg ci -qm '#1'
974 974 $ hg debugdirstate --all --no-dates | grep '^ '
975 975 0 -1 unset subdir
976 976 $ hg status
977 977 ? subdir/a
978 978
979 979 Changing the hgignore rules makes us recompute the status (and rewrite the dirstate).
980 980
981 981 $ rm subdir/a
982 982 $ mkdir another-subdir
983 983 $ touch another-subdir/something-else
984 984
985 $ cat > "$TESTDIR"/extra-hgignore <<EOF
985 $ cat > "$TESTTMP"/extra-hgignore <<EOF
986 986 > something-else
987 987 > EOF
988 988
989 $ hg status --config ui.ignore.global="$TESTDIR"/extra-hgignore
989 $ hg status --config ui.ignore.global="$TESTTMP"/extra-hgignore
990 990 $ hg debugdirstate --all --no-dates | grep '^ '
991 991 0 -1 set subdir
992 992
993 993 $ hg status
994 994 ? another-subdir/something-else
995 995
996 996 One invocation of status is enough to populate the cache even if it's invalidated
997 997 in the same run.
998 998
999 999 $ hg debugdirstate --all --no-dates | grep '^ '
1000 1000 0 -1 set subdir
1001 1001
1002 1002 #endif
General Comments 0
You need to be logged in to leave comments. Login now