##// END OF EJS Templates
py3: fix file i/o in test-status.t...
Gregory Szorc -
r36056:c1e01b1d default
parent child Browse files
Show More
@@ -1,613 +1,613 b''
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 (glob)
127 127 ? in_a
128 128 ? ../b/1/in_b_1 (glob)
129 129 ? ../b/2/in_b_2 (glob)
130 130 ? ../b/in_b (glob)
131 131 ? ../in_root (glob)
132 132
133 133 relative paths can be requested
134 134
135 135 $ cat >> $HGRCPATH <<EOF
136 136 > [commands]
137 137 > status.relative = True
138 138 > EOF
139 139 $ hg status --cwd a
140 140 ? 1/in_a_1
141 141 ? in_a
142 142 ? ../b/1/in_b_1
143 143 ? ../b/2/in_b_2
144 144 ? ../b/in_b
145 145 ? ../in_root
146 146 $ HGPLAIN=1 hg status --cwd a
147 147 ? a/1/in_a_1 (glob)
148 148 ? a/in_a (glob)
149 149 ? b/1/in_b_1 (glob)
150 150 ? b/2/in_b_2 (glob)
151 151 ? b/in_b (glob)
152 152 ? in_root
153 153
154 154 if relative paths are explicitly off, tweakdefaults doesn't change it
155 155 $ cat >> $HGRCPATH <<EOF
156 156 > [commands]
157 157 > status.relative = False
158 158 > EOF
159 159 $ hg status --cwd a --config ui.tweakdefaults=yes
160 160 ? a/1/in_a_1
161 161 ? a/in_a
162 162 ? b/1/in_b_1
163 163 ? b/2/in_b_2
164 164 ? b/in_b
165 165 ? in_root
166 166
167 167 $ cd ..
168 168
169 169 $ hg init repo2
170 170 $ cd repo2
171 171 $ touch modified removed deleted ignored
172 172 $ echo "^ignored$" > .hgignore
173 173 $ hg ci -A -m 'initial checkin'
174 174 adding .hgignore
175 175 adding deleted
176 176 adding modified
177 177 adding removed
178 178 $ touch modified added unknown ignored
179 179 $ hg add added
180 180 $ hg remove removed
181 181 $ rm deleted
182 182
183 183 hg status:
184 184
185 185 $ hg status
186 186 A added
187 187 R removed
188 188 ! deleted
189 189 ? unknown
190 190
191 191 hg status modified added removed deleted unknown never-existed ignored:
192 192
193 193 $ hg status modified added removed deleted unknown never-existed ignored
194 194 never-existed: * (glob)
195 195 A added
196 196 R removed
197 197 ! deleted
198 198 ? unknown
199 199
200 200 $ hg copy modified copied
201 201
202 202 hg status -C:
203 203
204 204 $ hg status -C
205 205 A added
206 206 A copied
207 207 modified
208 208 R removed
209 209 ! deleted
210 210 ? unknown
211 211
212 212 hg status -A:
213 213
214 214 $ hg status -A
215 215 A added
216 216 A copied
217 217 modified
218 218 R removed
219 219 ! deleted
220 220 ? unknown
221 221 I ignored
222 222 C .hgignore
223 223 C modified
224 224
225 225 $ hg status -A -Tjson
226 226 [
227 227 {
228 228 "path": "added",
229 229 "status": "A"
230 230 },
231 231 {
232 232 "copy": "modified",
233 233 "path": "copied",
234 234 "status": "A"
235 235 },
236 236 {
237 237 "path": "removed",
238 238 "status": "R"
239 239 },
240 240 {
241 241 "path": "deleted",
242 242 "status": "!"
243 243 },
244 244 {
245 245 "path": "unknown",
246 246 "status": "?"
247 247 },
248 248 {
249 249 "path": "ignored",
250 250 "status": "I"
251 251 },
252 252 {
253 253 "path": ".hgignore",
254 254 "status": "C"
255 255 },
256 256 {
257 257 "path": "modified",
258 258 "status": "C"
259 259 }
260 260 ]
261 261
262 262 $ hg status -A -Tpickle > pickle
263 263 >>> from __future__ import print_function
264 264 >>> import pickle
265 265 >>> print(sorted((x['status'], x['path']) for x in pickle.load(open("pickle"))))
266 266 [('!', 'deleted'), ('?', 'pickle'), ('?', 'unknown'), ('A', 'added'), ('A', 'copied'), ('C', '.hgignore'), ('C', 'modified'), ('I', 'ignored'), ('R', 'removed')]
267 267 $ rm pickle
268 268
269 269 $ echo "^ignoreddir$" > .hgignore
270 270 $ mkdir ignoreddir
271 271 $ touch ignoreddir/file
272 272
273 273 Test templater support:
274 274
275 275 $ hg status -AT "[{status}]\t{if(copy, '{copy} -> ')}{path}\n"
276 276 [M] .hgignore
277 277 [A] added
278 278 [A] modified -> copied
279 279 [R] removed
280 280 [!] deleted
281 281 [?] ignored
282 282 [?] unknown
283 283 [I] ignoreddir/file
284 284 [C] modified
285 285 $ hg status -AT default
286 286 M .hgignore
287 287 A added
288 288 A copied
289 289 modified
290 290 R removed
291 291 ! deleted
292 292 ? ignored
293 293 ? unknown
294 294 I ignoreddir/file
295 295 C modified
296 296 $ hg status -T compact
297 297 abort: "status" not in template map
298 298 [255]
299 299
300 300 hg status ignoreddir/file:
301 301
302 302 $ hg status ignoreddir/file
303 303
304 304 hg status -i ignoreddir/file:
305 305
306 306 $ hg status -i ignoreddir/file
307 307 I ignoreddir/file
308 308 $ cd ..
309 309
310 310 Check 'status -q' and some combinations
311 311
312 312 $ hg init repo3
313 313 $ cd repo3
314 314 $ touch modified removed deleted ignored
315 315 $ echo "^ignored$" > .hgignore
316 316 $ hg commit -A -m 'initial checkin'
317 317 adding .hgignore
318 318 adding deleted
319 319 adding modified
320 320 adding removed
321 321 $ touch added unknown ignored
322 322 $ hg add added
323 323 $ echo "test" >> modified
324 324 $ hg remove removed
325 325 $ rm deleted
326 326 $ hg copy modified copied
327 327
328 328 Specify working directory revision explicitly, that should be the same as
329 329 "hg status"
330 330
331 331 $ hg status --change "wdir()"
332 332 M modified
333 333 A added
334 334 A copied
335 335 R removed
336 336 ! deleted
337 337 ? unknown
338 338
339 339 Run status with 2 different flags.
340 340 Check if result is the same or different.
341 341 If result is not as expected, raise error
342 342
343 343 $ assert() {
344 344 > hg status $1 > ../a
345 345 > hg status $2 > ../b
346 346 > if diff ../a ../b > /dev/null; then
347 347 > out=0
348 348 > else
349 349 > out=1
350 350 > fi
351 351 > if [ $3 -eq 0 ]; then
352 352 > df="same"
353 353 > else
354 354 > df="different"
355 355 > fi
356 356 > if [ $out -ne $3 ]; then
357 357 > echo "Error on $1 and $2, should be $df."
358 358 > fi
359 359 > }
360 360
361 361 Assert flag1 flag2 [0-same | 1-different]
362 362
363 363 $ assert "-q" "-mard" 0
364 364 $ assert "-A" "-marduicC" 0
365 365 $ assert "-qA" "-mardcC" 0
366 366 $ assert "-qAui" "-A" 0
367 367 $ assert "-qAu" "-marducC" 0
368 368 $ assert "-qAi" "-mardicC" 0
369 369 $ assert "-qu" "-u" 0
370 370 $ assert "-q" "-u" 1
371 371 $ assert "-m" "-a" 1
372 372 $ assert "-r" "-d" 1
373 373 $ cd ..
374 374
375 375 $ hg init repo4
376 376 $ cd repo4
377 377 $ touch modified removed deleted
378 378 $ hg ci -q -A -m 'initial checkin'
379 379 $ touch added unknown
380 380 $ hg add added
381 381 $ hg remove removed
382 382 $ rm deleted
383 383 $ echo x > modified
384 384 $ hg copy modified copied
385 385 $ hg ci -m 'test checkin' -d "1000001 0"
386 386 $ rm *
387 387 $ touch unrelated
388 388 $ hg ci -q -A -m 'unrelated checkin' -d "1000002 0"
389 389
390 390 hg status --change 1:
391 391
392 392 $ hg status --change 1
393 393 M modified
394 394 A added
395 395 A copied
396 396 R removed
397 397
398 398 hg status --change 1 unrelated:
399 399
400 400 $ hg status --change 1 unrelated
401 401
402 402 hg status -C --change 1 added modified copied removed deleted:
403 403
404 404 $ hg status -C --change 1 added modified copied removed deleted
405 405 M modified
406 406 A added
407 407 A copied
408 408 modified
409 409 R removed
410 410
411 411 hg status -A --change 1 and revset:
412 412
413 413 $ hg status -A --change '1|1'
414 414 M modified
415 415 A added
416 416 A copied
417 417 modified
418 418 R removed
419 419 C deleted
420 420
421 421 $ cd ..
422 422
423 423 hg status with --rev and reverted changes:
424 424
425 425 $ hg init reverted-changes-repo
426 426 $ cd reverted-changes-repo
427 427 $ echo a > file
428 428 $ hg add file
429 429 $ hg ci -m a
430 430 $ echo b > file
431 431 $ hg ci -m b
432 432
433 433 reverted file should appear clean
434 434
435 435 $ hg revert -r 0 .
436 436 reverting file
437 437 $ hg status -A --rev 0
438 438 C file
439 439
440 440 #if execbit
441 441 reverted file with changed flag should appear modified
442 442
443 443 $ chmod +x file
444 444 $ hg status -A --rev 0
445 445 M file
446 446
447 447 $ hg revert -r 0 .
448 448 reverting file
449 449
450 450 reverted and committed file with changed flag should appear modified
451 451
452 452 $ hg co -C .
453 453 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
454 454 $ chmod +x file
455 455 $ hg ci -m 'change flag'
456 456 $ hg status -A --rev 1 --rev 2
457 457 M file
458 458 $ hg diff -r 1 -r 2
459 459
460 460 #endif
461 461
462 462 $ cd ..
463 463
464 464 hg status of binary file starting with '\1\n', a separator for metadata:
465 465
466 466 $ hg init repo5
467 467 $ cd repo5
468 >>> open("010a", "wb").write("\1\nfoo")
468 >>> open("010a", r"wb").write(b"\1\nfoo")
469 469 $ hg ci -q -A -m 'initial checkin'
470 470 $ hg status -A
471 471 C 010a
472 472
473 >>> open("010a", "wb").write("\1\nbar")
473 >>> open("010a", r"wb").write(b"\1\nbar")
474 474 $ hg status -A
475 475 M 010a
476 476 $ hg ci -q -m 'modify 010a'
477 477 $ hg status -A --rev 0:1
478 478 M 010a
479 479
480 480 $ touch empty
481 481 $ hg ci -q -A -m 'add another file'
482 482 $ hg status -A --rev 1:2 010a
483 483 C 010a
484 484
485 485 $ cd ..
486 486
487 487 test "hg status" with "directory pattern" which matches against files
488 488 only known on target revision.
489 489
490 490 $ hg init repo6
491 491 $ cd repo6
492 492
493 493 $ echo a > a.txt
494 494 $ hg add a.txt
495 495 $ hg commit -m '#0'
496 496 $ mkdir -p 1/2/3/4/5
497 497 $ echo b > 1/2/3/4/5/b.txt
498 498 $ hg add 1/2/3/4/5/b.txt
499 499 $ hg commit -m '#1'
500 500
501 501 $ hg update -C 0 > /dev/null
502 502 $ hg status -A
503 503 C a.txt
504 504
505 505 the directory matching against specified pattern should be removed,
506 506 because directory existence prevents 'dirstate.walk()' from showing
507 507 warning message about such pattern.
508 508
509 509 $ test ! -d 1
510 510 $ hg status -A --rev 1 1/2/3/4/5/b.txt
511 511 R 1/2/3/4/5/b.txt
512 512 $ hg status -A --rev 1 1/2/3/4/5
513 513 R 1/2/3/4/5/b.txt
514 514 $ hg status -A --rev 1 1/2/3
515 515 R 1/2/3/4/5/b.txt
516 516 $ hg status -A --rev 1 1
517 517 R 1/2/3/4/5/b.txt
518 518
519 519 $ hg status --config ui.formatdebug=True --rev 1 1
520 520 status = [
521 521 {*'path': '1/2/3/4/5/b.txt'*}, (glob)
522 522 ]
523 523
524 524 #if windows
525 525 $ hg --config ui.slash=false status -A --rev 1 1
526 526 R 1\2\3\4\5\b.txt
527 527 #endif
528 528
529 529 $ cd ..
530 530
531 531 Status after move overwriting a file (issue4458)
532 532 =================================================
533 533
534 534
535 535 $ hg init issue4458
536 536 $ cd issue4458
537 537 $ echo a > a
538 538 $ echo b > b
539 539 $ hg commit -Am base
540 540 adding a
541 541 adding b
542 542
543 543
544 544 with --force
545 545
546 546 $ hg mv b --force a
547 547 $ hg st --copies
548 548 M a
549 549 b
550 550 R b
551 551 $ hg revert --all
552 552 reverting a
553 553 undeleting b
554 554 $ rm *.orig
555 555
556 556 without force
557 557
558 558 $ hg rm a
559 559 $ hg st --copies
560 560 R a
561 561 $ hg mv b a
562 562 $ hg st --copies
563 563 M a
564 564 b
565 565 R b
566 566
567 567 using ui.statuscopies setting
568 568 $ hg st --config ui.statuscopies=true
569 569 M a
570 570 b
571 571 R b
572 572 $ hg st --config ui.statuscopies=false
573 573 M a
574 574 R b
575 575 $ hg st --config ui.tweakdefaults=yes
576 576 M a
577 577 b
578 578 R b
579 579
580 580 using log status template (issue5155)
581 581 $ hg log -Tstatus -r 'wdir()' -C
582 582 changeset: 2147483647:ffffffffffff
583 583 parent: 0:8c55c58b4c0e
584 584 user: test
585 585 date: * (glob)
586 586 files:
587 587 M a
588 588 b
589 589 R b
590 590
591 591
592 592 Other "bug" highlight, the revision status does not report the copy information.
593 593 This is buggy behavior.
594 594
595 595 $ hg commit -m 'blah'
596 596 $ hg st --copies --change .
597 597 M a
598 598 R b
599 599
600 600 using log status template, the copy information is displayed correctly.
601 601 $ hg log -Tstatus -r. -C
602 602 changeset: 1:6685fde43d21
603 603 tag: tip
604 604 user: test
605 605 date: * (glob)
606 606 summary: blah
607 607 files:
608 608 M a
609 609 b
610 610 R b
611 611
612 612
613 613 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now