Debian Codegraph @

tests/test-fastannotate-hg.t

raw
1 (this file is backported from core hg tests/test-annotate.t)
2
3 $ cat >> $HGRCPATH << EOF
4 > [ui]
5 > merge = :merge3
6 > [diff]
7 > git=1
8 > [extensions]
9 > fastannotate=
10 > [fastannotate]
11 > modes=fctx
12 > forcefollow=False
13 > mainbranch=.
14 > EOF
15
16 init
17
18 $ hg init repo
19 $ cd repo
20
21 commit
22
23 $ echo 'a' > a
24 $ hg ci -A -m test -u nobody -d '1 0'
25 adding a
26
27 annotate -c
28
29 $ hg annotate -c a
30 8435f90966e4: a
31
32 annotate -cl
33
34 $ hg annotate -cl a
35 8435f90966e4:1: a
36
37 annotate -d
38
39 $ hg annotate -d a
40 Thu Jan 01 00:00:01 1970 +0000: a
41
42 annotate -n
43
44 $ hg annotate -n a
45 0: a
46
47 annotate -nl
48
49 $ hg annotate -nl a
50 0:1: a
51
52 annotate -u
53
54 $ hg annotate -u a
55 nobody: a
56
57 annotate -cdnu
58
59 $ hg annotate -cdnu a
60 nobody 0 8435f90966e4 Thu Jan 01 00:00:01 1970 +0000: a
61
62 annotate -cdnul
63
64 $ hg annotate -cdnul a
65 nobody 0 8435f90966e4 Thu Jan 01 00:00:01 1970 +0000:1: a
66
67 annotate (JSON)
68
69 $ hg annotate -Tjson a
70 [
71 {
72 "lines": [{"line": "a\n", "rev": 0}],
73 "path": "a"
74 }
75 ]
76
77 $ hg annotate -Tjson -cdfnul a
78 [
79 {
80 "lines": [{"date": [1.0, 0], "line": "a\n", "lineno": 1, "node": "8435f90966e442695d2ded29fdade2bac5ad8065", "path": "a", "rev": 0, "user": "nobody"}],
81 "path": "a"
82 }
83 ]
84
85 $ cat <<EOF >>a
86 > a
87 > a
88 > EOF
89 $ hg ci -ma1 -d '1 0'
90 $ hg cp a b
91 $ hg ci -mb -d '1 0'
92 $ cat <<EOF >> b
93 > b4
94 > b5
95 > b6
96 > EOF
97 $ hg ci -mb2 -d '2 0'
98
99 annotate -n b
100
101 $ hg annotate -n b
102 0: a
103 1: a
104 1: a
105 3: b4
106 3: b5
107 3: b6
108
109 annotate --no-follow b
110
111 $ hg annotate --no-follow b
112 2: a
113 2: a
114 2: a
115 3: b4
116 3: b5
117 3: b6
118
119 annotate -nl b
120
121 $ hg annotate -nl b
122 0:1: a
123 1:2: a
124 1:3: a
125 3:4: b4
126 3:5: b5
127 3:6: b6
128
129 annotate -nf b
130
131 $ hg annotate -nf b
132 0 a: a
133 1 a: a
134 1 a: a
135 3 b: b4
136 3 b: b5
137 3 b: b6
138
139 annotate -nlf b
140
141 $ hg annotate -nlf b
142 0 a:1: a
143 1 a:2: a
144 1 a:3: a
145 3 b:4: b4
146 3 b:5: b5
147 3 b:6: b6
148
149 $ hg up -C 2
150 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
151 $ cat <<EOF >> b
152 > b4
153 > c
154 > b5
155 > EOF
156 $ hg ci -mb2.1 -d '2 0'
157 created new head
158 $ hg merge
159 merging b
160 warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
161 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
162 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
163 [1]
164 $ cat b
165 a
166 a
167 a
168 <<<<<<< working copy: 5fbdc1152d97 - test: b2.1
169 b4
170 c
171 b5
172 ||||||| common ancestor: 3086dbafde1c - test: b
173 =======
174 b4
175 b5
176 b6
177 >>>>>>> merge rev: 37ec9f5c3d1f - test: b2
178 $ cat <<EOF > b
179 > a
180 > a
181 > a
182 > b4
183 > c
184 > b5
185 > EOF
186 $ hg resolve --mark -q
187 $ rm b.orig
188 $ hg ci -mmergeb -d '3 0'
189
190 annotate after merge
191 (note: the first one falls back to the vanilla annotate which does not use linelog)
192
193 $ hg annotate -nf b --debug
194 fastannotate: b: rebuilding broken cache
195 fastannotate: b: 5 new changesets in the main branch
196 0 a: a
197 1 a: a
198 1 a: a
199 3 b: b4
200 4 b: c
201 3 b: b5
202
203 (difference explained below)
204
205 $ hg annotate -nf b --debug
206 fastannotate: b: using fast path (resolved fctx: False)
207 0 a: a
208 1 a: a
209 1 a: a
210 4 b: b4
211 4 b: c
212 4 b: b5
213
214 annotate after merge with -l
215 (fastannotate differs from annotate)
216
217 $ hg log -Gp -T '{rev}:{node}' -r '2..5'
218 @ 5:64afcdf8e29e063c635be123d8d2fb160af00f7e
219 |\
220 | o 4:5fbdc1152d97597717021ad9e063061b200f146bdiff --git a/b b/b
221 | | --- a/b
222 | | +++ b/b
223 | | @@ -1,3 +1,6 @@
224 | | a
225 | | a
226 | | a
227 | | +b4
228 | | +c
229 | | +b5
230 | |
231 o | 3:37ec9f5c3d1f99572d7075971cb4876e2139b52fdiff --git a/b b/b
232 |/ --- a/b
233 | +++ b/b
234 | @@ -1,3 +1,6 @@
235 | a
236 | a
237 | a
238 | +b4
239 | +b5
240 | +b6
241 |
242 o 2:3086dbafde1ce745abfc8d2d367847280aabae9ddiff --git a/a b/b
243 | copy from a
244 ~ copy to b
245
246
247 (in this case, "b4", "b5" could be considered introduced by either rev 3, or rev 4.
248 and that causes the rev number difference)
249
250 $ hg annotate -nlf b --config fastannotate.modes=
251 0 a:1: a
252 1 a:2: a
253 1 a:3: a
254 3 b:4: b4
255 4 b:5: c
256 3 b:5: b5
257
258 $ hg annotate -nlf b
259 0 a:1: a
260 1 a:2: a
261 1 a:3: a
262 4 b:4: b4
263 4 b:5: c
264 4 b:6: b5
265
266 $ hg up -C 1
267 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
268 $ hg cp a b
269 $ cat <<EOF > b
270 > a
271 > z
272 > a
273 > EOF
274 $ hg ci -mc -d '3 0'
275 created new head
276 Work around the pure version not resolving the conflict like native code
277 #if pure
278 $ hg merge
279 merging b
280 warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
281 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
282 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
283 [1]
284 $ cat <<EOF > b
285 > a
286 > z
287 > a
288 > b4
289 > c
290 > b5
291 > EOF
292 $ hg resolve -m b
293 (no more unresolved files)
294 $ rm b.orig
295 #else
296 $ hg merge
297 merging b
298 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
299 (branch merge, don't forget to commit)
300 #endif
301 $ echo d >> b
302 $ hg ci -mmerge2 -d '4 0'
303
304 annotate after rename merge
305
306 $ hg annotate -nf b
307 0 a: a
308 6 b: z
309 1 a: a
310 3 b: b4
311 4 b: c
312 3 b: b5
313 7 b: d
314
315 annotate after rename merge with -l
316 (fastannotate differs from annotate)
317
318 $ hg log -Gp -T '{rev}:{node}' -r '0+1+6+7'
319 @ 7:6284bb6c38fef984a929862a53bbc71ce9eafa81diff --git a/b b/b
320 |\ --- a/b
321 | : +++ b/b
322 | : @@ -1,3 +1,7 @@
323 | : a
324 | : z
325 | : a
326 | : +b4
327 | : +c
328 | : +b5
329 | : +d
330 | :
331 o : 6:b80e3e32f75a6a67cd4ac85496a11511e9112816diff --git a/a b/b
332 :/ copy from a
333 : copy to b
334 : --- a/a
335 : +++ b/b
336 : @@ -1,3 +1,3 @@
337 : -a (?)
338 : a
339 : +z
340 : a
341 : -a (?)
342 :
343 o 1:762f04898e6684ff713415f7b8a8d53d33f96c92diff --git a/a b/a
344 | --- a/a
345 | +++ b/a
346 | @@ -1,1 +1,3 @@
347 | a
348 | +a
349 | +a
350 |
351 o 0:8435f90966e442695d2ded29fdade2bac5ad8065diff --git a/a b/a
352 new file mode 100644
353 --- /dev/null
354 +++ b/a
355 @@ -0,0 +1,1 @@
356 +a
357
358
359 (note on question marks:
360 the upstream bdiff change (96f2f50d923f+3633403888ae+8c0c75aa3ff4+5c4e2636c1a9
361 +38ed54888617) alters the output so deletion is not always at the end of the
362 output. for example:
363 | a | b | old | new | # old: e1d6aa0e4c3a, new: 8836f13e3c5b
364 |-------------------|
365 | a | a | a | -a |
366 | a | z | +z | a |
367 | a | a | a | +z |
368 | | | -a | a |
369 |-------------------|
370 | a | a | a |
371 | a | a | a |
372 | a | | -a |
373 this leads to more question marks below)
374
375 (rev 1 adds two "a"s and rev 6 deletes one "a".
376 the "a" that rev 6 deletes could be either the first or the second "a" of those two "a"s added by rev 1.
377 and that causes the line number difference)
378
379 $ hg annotate -nlf b --config fastannotate.modes=
380 0 a:1: a
381 6 b:2: z
382 1 a:3: a
383 3 b:4: b4
384 4 b:5: c
385 3 b:5: b5
386 7 b:7: d
387
388 $ hg annotate -nlf b
389 0 a:1: a (?)
390 1 a:2: a (?)
391 6 b:2: z
392 1 a:2: a (?)
393 1 a:3: a (?)
394 3 b:4: b4
395 4 b:5: c
396 3 b:5: b5
397 7 b:7: d
398
399 Issue2807: alignment of line numbers with -l
400 (fastannotate differs from annotate, same reason as above)
401
402 $ echo more >> b
403 $ hg ci -mmore -d '5 0'
404 $ echo more >> b
405 $ hg ci -mmore -d '6 0'
406 $ echo more >> b
407 $ hg ci -mmore -d '7 0'
408 $ hg annotate -nlf b
409 0 a: 1: a (?)
410 1 a: 2: a (?)
411 6 b: 2: z
412 1 a: 2: a (?)
413 1 a: 3: a (?)
414 3 b: 4: b4
415 4 b: 5: c
416 3 b: 5: b5
417 7 b: 7: d
418 8 b: 8: more
419 9 b: 9: more
420 10 b:10: more
421
422 linkrev vs rev
423
424 $ hg annotate -r tip -n a
425 0: a
426 1: a
427 1: a
428
429 linkrev vs rev with -l
430
431 $ hg annotate -r tip -nl a
432 0:1: a
433 1:2: a
434 1:3: a
435
436 Issue589: "undelete" sequence leads to crash
437
438 annotate was crashing when trying to --follow something
439
440 like A -> B -> A
441
442 generate ABA rename configuration
443
444 $ echo foo > foo
445 $ hg add foo
446 $ hg ci -m addfoo
447 $ hg rename foo bar
448 $ hg ci -m renamefoo
449 $ hg rename bar foo
450 $ hg ci -m renamebar
451
452 annotate after ABA with follow
453
454 $ hg annotate --follow foo
455 foo: foo
456
457 missing file
458
459 $ hg annotate nosuchfile
460 abort: nosuchfile: no such file in rev e9e6b4fa872f
461 [255]
462
463 annotate file without '\n' on last line
464
465 $ printf "" > c
466 $ hg ci -A -m test -u nobody -d '1 0'
467 adding c
468 $ hg annotate c
469 $ printf "a\nb" > c
470 $ hg ci -m test
471 $ hg annotate c
472 [0-9]+: a (re)
473 [0-9]+: b (re)
474
475 Issue3841: check annotation of the file of which filelog includes
476 merging between the revision and its ancestor
477
478 to reproduce the situation with recent Mercurial, this script uses (1)
479 "hg debugsetparents" to merge without ancestor check by "hg merge",
480 and (2) the extension to allow filelog merging between the revision
481 and its ancestor by overriding "repo._filecommit".
482
483 $ cat > ../legacyrepo.py <<EOF
484 > from mercurial import commit, error, extensions
485 > def _filecommit(orig, repo, fctx, manifest1, manifest2,
486 > linkrev, tr, includecopymeta, ms):
487 > fname = fctx.path()
488 > text = fctx.data()
489 > flog = repo.file(fname, writable=True)
490 > fparent1 = manifest1.get(fname, repo.nullid)
491 > fparent2 = manifest2.get(fname, repo.nullid)
492 > meta = {}
493 > copy = fctx.copysource()
494 > if copy and copy != fname:
495 > raise error.Abort('copying is not supported')
496 > if fparent2 != repo.nullid:
497 > return flog.add(text, meta, tr, linkrev,
498 > fparent1, fparent2), 'modified'
499 > raise error.Abort('only merging is supported')
500 > def uisetup(ui):
501 > extensions.wrapfunction(commit, '_filecommit', _filecommit)
502 > EOF
503
504 $ cat > baz <<EOF
505 > 1
506 > 2
507 > 3
508 > 4
509 > 5
510 > EOF
511 $ hg add baz
512 $ hg commit -m "baz:0"
513
514 $ cat > baz <<EOF
515 > 1 baz:1
516 > 2
517 > 3
518 > 4
519 > 5
520 > EOF
521 $ hg commit -m "baz:1"
522
523 $ cat > baz <<EOF
524 > 1 baz:1
525 > 2 baz:2
526 > 3
527 > 4
528 > 5
529 > EOF
530 $ hg debugsetparents 17 17
531 $ hg --config extensions.legacyrepo=../legacyrepo.py commit -m "baz:2"
532 $ hg debugindexdot baz
533 digraph G {
534 -1 -> 0
535 0 -> 1
536 1 -> 2
537 1 -> 2
538 }
539 $ hg annotate baz
540 17: 1 baz:1
541 18: 2 baz:2
542 16: 3
543 16: 4
544 16: 5
545
546 $ cat > baz <<EOF
547 > 1 baz:1
548 > 2 baz:2
549 > 3 baz:3
550 > 4
551 > 5
552 > EOF
553 $ hg commit -m "baz:3"
554
555 $ cat > baz <<EOF
556 > 1 baz:1
557 > 2 baz:2
558 > 3 baz:3
559 > 4 baz:4
560 > 5
561 > EOF
562 $ hg debugsetparents 19 18
563 $ hg --config extensions.legacyrepo=../legacyrepo.py commit -m "baz:4"
564 $ hg debugindexdot baz
565 digraph G {
566 -1 -> 0
567 0 -> 1
568 1 -> 2
569 1 -> 2
570 2 -> 3
571 3 -> 4
572 2 -> 4
573 }
574 $ hg annotate baz
575 17: 1 baz:1
576 18: 2 baz:2
577 19: 3 baz:3
578 20: 4 baz:4
579 16: 5
580
581 annotate clean file
582
583 $ hg annotate -ncr "wdir()" foo
584 11 472b18db256d : foo
585
586 annotate modified file
587
588 $ echo foofoo >> foo
589 $ hg annotate -r "wdir()" foo
590 11 : foo
591 20+: foofoo
592
593 $ hg annotate -cr "wdir()" foo
594 472b18db256d : foo
595 b6bedd5477e7+: foofoo
596
597 $ hg annotate -ncr "wdir()" foo
598 11 472b18db256d : foo
599 20 b6bedd5477e7+: foofoo
600
601 $ hg annotate --debug -ncr "wdir()" foo
602 11 472b18db256d1e8282064eab4bfdaf48cbfe83cd : foo
603 20 b6bedd5477e797f25e568a6402d4697f3f895a72+: foofoo
604
605 $ hg annotate -udr "wdir()" foo
606 test Thu Jan 01 00:00:00 1970 +0000: foo
607 test [A-Za-z0-9:+ ]+: foofoo (re)
608
609 $ hg annotate -ncr "wdir()" -Tjson foo
610 [
611 {
612 "lines": [{"line": "foo\n", "node": "472b18db256d1e8282064eab4bfdaf48cbfe83cd", "rev": 11}, {"line": "foofoo\n", "node": "ffffffffffffffffffffffffffffffffffffffff", "rev": 2147483647}],
613 "path": "foo"
614 }
615 ]
616
617 annotate added file
618
619 $ echo bar > bar
620 $ hg add bar
621 $ hg annotate -ncr "wdir()" bar
622 20 b6bedd5477e7+: bar
623
624 annotate renamed file
625
626 $ hg rename foo renamefoo2
627 $ hg annotate -ncr "wdir()" renamefoo2
628 11 472b18db256d : foo
629 20 b6bedd5477e7+: foofoo
630
631 annotate missing file
632
633 $ rm baz
634 $ hg annotate -ncr "wdir()" baz
635 abort: $TESTTMP/repo/baz: $ENOENT$ (windows !)
636 abort: $ENOENT$: '$TESTTMP/repo/baz' (no-windows !)
637 [255]
638
639 annotate removed file
640
641 $ hg rm baz
642 $ hg annotate -ncr "wdir()" baz
643 abort: $TESTTMP/repo/baz: $ENOENT$ (windows !)
644 abort: $ENOENT$: '$TESTTMP/repo/baz' (no-windows !)
645 [255]
646
647 Test annotate with whitespace options
648
649 $ cd ..
650 $ hg init repo-ws
651 $ cd repo-ws
652 $ cat > a <<EOF
653 > aa
654 >
655 > b b
656 > EOF
657 $ hg ci -Am "adda"
658 adding a
659 $ sed 's/EOL$//g' > a <<EOF
660 > a a
661 >
662 > EOL
663 > b b
664 > EOF
665 $ hg ci -m "changea"
666
667 Annotate with no option
668
669 $ hg annotate a
670 1: a a
671 0:
672 1:
673 1: b b
674
675 Annotate with --ignore-space-change
676
677 $ hg annotate --ignore-space-change a
678 1: a a
679 1:
680 0:
681 0: b b
682
683 Annotate with --ignore-all-space
684
685 $ hg annotate --ignore-all-space a
686 0: a a
687 0:
688 1:
689 0: b b
690
691 Annotate with --ignore-blank-lines (similar to no options case)
692
693 $ hg annotate --ignore-blank-lines a
694 1: a a
695 0:
696 1:
697 1: b b
698
699 $ cd ..
700
701 Annotate with linkrev pointing to another branch
702 ------------------------------------------------
703
704 create history with a filerev whose linkrev points to another branch
705
706 $ hg init branchedlinkrev
707 $ cd branchedlinkrev
708 $ echo A > a
709 $ hg commit -Am 'contentA'
710 adding a
711 $ echo B >> a
712 $ hg commit -m 'contentB'
713 $ hg up --rev 'desc(contentA)'
714 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
715 $ echo unrelated > unrelated
716 $ hg commit -Am 'unrelated'
717 adding unrelated
718 created new head
719 $ hg graft -r 'desc(contentB)'
720 grafting 1:fd27c222e3e6 "contentB"
721 $ echo C >> a
722 $ hg commit -m 'contentC'
723 $ echo W >> a
724 $ hg log -G
725 @ changeset: 4:072f1e8df249
726 | tag: tip
727 | user: test
728 | date: Thu Jan 01 00:00:00 1970 +0000
729 | summary: contentC
730 |
731 o changeset: 3:ff38df03cc4b
732 | user: test
733 | date: Thu Jan 01 00:00:00 1970 +0000
734 | summary: contentB
735 |
736 o changeset: 2:62aaf3f6fc06
737 | parent: 0:f0932f74827e
738 | user: test
739 | date: Thu Jan 01 00:00:00 1970 +0000
740 | summary: unrelated
741 |
742 | o changeset: 1:fd27c222e3e6
743 |/ user: test
744 | date: Thu Jan 01 00:00:00 1970 +0000
745 | summary: contentB
746 |
747 o changeset: 0:f0932f74827e
748 user: test
749 date: Thu Jan 01 00:00:00 1970 +0000
750 summary: contentA
751
752
753 Annotate should list ancestor of starting revision only
754
755 $ hg annotate a
756 0: A
757 3: B
758 4: C
759
760 $ hg annotate a -r 'wdir()'
761 0 : A
762 3 : B
763 4 : C
764 4+: W
765
766 Even when the starting revision is the linkrev-shadowed one:
767
768 $ hg annotate a -r 3
769 0: A
770 3: B
771
772 $ cd ..
773
774 Issue5360: Deleted chunk in p1 of a merge changeset
775
776 $ hg init repo-5360
777 $ cd repo-5360
778 $ echo 1 > a
779 $ hg commit -A a -m 1
780 $ echo 2 >> a
781 $ hg commit -m 2
782 $ echo a > a
783 $ hg commit -m a
784 $ hg update '.^' -q
785 $ echo 3 >> a
786 $ hg commit -m 3 -q
787 $ hg merge 2 -q
788 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
789 [1]
790 $ cat a
791 <<<<<<< working copy: 0a068f0261cf - test: 3
792 1
793 2
794 3
795 ||||||| common ancestor: 1ed24be7e7a0 - test: 2
796 1
797 2
798 =======
799 a
800 >>>>>>> merge rev: 9409851bc20a - test: a
801 $ cat > a << EOF
802 > b
803 > 1
804 > 2
805 > 3
806 > a
807 > EOF
808 $ hg resolve --mark -q
809 $ rm a.orig
810 $ hg commit -m m
811 $ hg annotate a
812 4: b
813 0: 1
814 1: 2
815 3: 3
816 2: a
817
818 $ cd ..