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