##// END OF EJS Templates
tests: make merge conflicts explicit in `hg annotate` tests...
Martin von Zweigbergk -
r42327:7116fc61 default
parent child Browse files
Show More
@@ -1,1080 +1,1210 b''
1 $ HGMERGE=true; export HGMERGE
1 $ cat >> "$HGRCPATH" << EOF
2 > [ui]
3 > merge = :merge3
4 > EOF
2 5
3 6 init
4 7
5 8 $ hg init repo
6 9 $ cd repo
7 10
8 11 commit
9 12
10 13 $ echo 'a' > a
11 14 $ hg ci -A -m test -u nobody -d '1 0'
12 15 adding a
13 16
14 17 annotate -c
15 18
16 19 $ hg annotate -c a
17 20 8435f90966e4: a
18 21
19 22 annotate -cl
20 23
21 24 $ hg annotate -cl a
22 25 8435f90966e4:1: a
23 26
24 27 annotate -d
25 28
26 29 $ hg annotate -d a
27 30 Thu Jan 01 00:00:01 1970 +0000: a
28 31
29 32 annotate -n
30 33
31 34 $ hg annotate -n a
32 35 0: a
33 36
34 37 annotate -nl
35 38
36 39 $ hg annotate -nl a
37 40 0:1: a
38 41
39 42 annotate -u
40 43
41 44 $ hg annotate -u a
42 45 nobody: a
43 46
44 47 annotate -cdnu
45 48
46 49 $ hg annotate -cdnu a
47 50 nobody 0 8435f90966e4 Thu Jan 01 00:00:01 1970 +0000: a
48 51
49 52 annotate -cdnul
50 53
51 54 $ hg annotate -cdnul a
52 55 nobody 0 8435f90966e4 Thu Jan 01 00:00:01 1970 +0000:1: a
53 56
54 57 annotate (JSON)
55 58
56 59 $ hg annotate -Tjson a
57 60 [
58 61 {
59 62 "lines": [{"line": "a\n", "rev": 0}],
60 63 "path": "a"
61 64 }
62 65 ]
63 66
64 67 $ hg annotate -Tjson -cdfnul a
65 68 [
66 69 {
67 70 "lines": [{"date": [1.0, 0], "line": "a\n", "lineno": 1, "node": "8435f90966e442695d2ded29fdade2bac5ad8065", "path": "a", "rev": 0, "user": "nobody"}],
68 71 "path": "a"
69 72 }
70 73 ]
71 74
72 75 log-like templating
73 76
74 77 $ hg annotate -T'{lines % "{rev} {node|shortest}: {line}"}' a
75 78 0 8435: a
76 79
77 80 '{lineno}' field should be populated as necessary
78 81
79 82 $ hg annotate -T'{lines % "{rev}:{lineno}: {line}"}' a
80 83 0:1: a
81 84 $ hg annotate -Ta a \
82 85 > --config templates.a='"{lines % "{rev}:{lineno}: {line}"}"'
83 86 0:1: a
84 87
85 88 $ cat <<EOF >>a
86 89 > a
87 90 > a
88 91 > EOF
89 92 $ hg ci -ma1 -d '1 0'
90 93 $ hg cp a b
91 94 $ hg ci -mb -d '1 0'
92 95 $ cat <<EOF >> b
93 96 > b4
94 97 > b5
95 98 > b6
96 99 > EOF
97 100 $ hg ci -mb2 -d '2 0'
98 101
99 102 default output of '{lines}' should be readable
100 103
101 104 $ hg annotate -T'{lines}' a
102 105 0: a
103 106 1: a
104 107 1: a
105 108 $ hg annotate -T'{join(lines, "\n")}' a
106 109 0: a
107 110
108 111 1: a
109 112
110 113 1: a
111 114
112 115 several filters can be applied to '{lines}'
113 116
114 117 $ hg annotate -T'{lines|json}\n' a
115 118 [{"line": "a\n", "rev": 0}, {"line": "a\n", "rev": 1}, {"line": "a\n", "rev": 1}]
116 119 $ hg annotate -T'{lines|stringify}' a
117 120 0: a
118 121 1: a
119 122 1: a
120 123 $ hg annotate -T'{lines|count}\n' a
121 124 3
122 125
123 126 annotate multiple files (JSON)
124 127
125 128 $ hg annotate -Tjson a b
126 129 [
127 130 {
128 131 "lines": [{"line": "a\n", "rev": 0}, {"line": "a\n", "rev": 1}, {"line": "a\n", "rev": 1}],
129 132 "path": "a"
130 133 },
131 134 {
132 135 "lines": [{"line": "a\n", "rev": 0}, {"line": "a\n", "rev": 1}, {"line": "a\n", "rev": 1}, {"line": "b4\n", "rev": 3}, {"line": "b5\n", "rev": 3}, {"line": "b6\n", "rev": 3}],
133 136 "path": "b"
134 137 }
135 138 ]
136 139
137 140 annotate multiple files (template)
138 141
139 142 $ hg annotate -T'== {path} ==\n{lines % "{rev}: {line}"}' a b
140 143 == a ==
141 144 0: a
142 145 1: a
143 146 1: a
144 147 == b ==
145 148 0: a
146 149 1: a
147 150 1: a
148 151 3: b4
149 152 3: b5
150 153 3: b6
151 154
152 155 annotate -n b
153 156
154 157 $ hg annotate -n b
155 158 0: a
156 159 1: a
157 160 1: a
158 161 3: b4
159 162 3: b5
160 163 3: b6
161 164
162 165 annotate --no-follow b
163 166
164 167 $ hg annotate --no-follow b
165 168 2: a
166 169 2: a
167 170 2: a
168 171 3: b4
169 172 3: b5
170 173 3: b6
171 174
172 175 annotate -nl b
173 176
174 177 $ hg annotate -nl b
175 178 0:1: a
176 179 1:2: a
177 180 1:3: a
178 181 3:4: b4
179 182 3:5: b5
180 183 3:6: b6
181 184
182 185 annotate -nf b
183 186
184 187 $ hg annotate -nf b
185 188 0 a: a
186 189 1 a: a
187 190 1 a: a
188 191 3 b: b4
189 192 3 b: b5
190 193 3 b: b6
191 194
192 195 annotate -nlf b
193 196
194 197 $ hg annotate -nlf b
195 198 0 a:1: a
196 199 1 a:2: a
197 200 1 a:3: a
198 201 3 b:4: b4
199 202 3 b:5: b5
200 203 3 b:6: b6
201 204
202 205 $ hg up -C 2
203 206 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
204 207 $ cat <<EOF >> b
205 208 > b4
206 209 > c
207 210 > b5
208 211 > EOF
209 212 $ hg ci -mb2.1 -d '2 0'
210 213 created new head
211 214 $ hg merge
212 215 merging b
213 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
214 (branch merge, don't forget to commit)
216 warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
217 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
218 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
219 [1]
220 $ cat b
221 a
222 a
223 a
224 <<<<<<< working copy: 5fbdc1152d97 - test: b2.1
225 b4
226 c
227 b5
228 ||||||| base
229 =======
230 b4
231 b5
232 b6
233 >>>>>>> merge rev: 37ec9f5c3d1f - test: b2
234 $ cat <<EOF > b
235 > a
236 > a
237 > a
238 > b4
239 > c
240 > b5
241 > EOF
242 $ hg resolve --mark -q
243 $ rm b.orig
215 244 $ hg ci -mmergeb -d '3 0'
216 245
217 246 annotate after merge
218 247
219 248 $ hg annotate -nf b
220 249 0 a: a
221 250 1 a: a
222 251 1 a: a
223 252 3 b: b4
224 253 4 b: c
225 254 3 b: b5
226 255
227 256 annotate after merge with -l
228 257
229 258 $ hg annotate -nlf b
230 259 0 a:1: a
231 260 1 a:2: a
232 261 1 a:3: a
233 262 3 b:4: b4
234 263 4 b:5: c
235 264 3 b:5: b5
236 265
237 266 $ hg up -C 1
238 267 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
239 268 $ hg cp a b
240 269 $ cat <<EOF > b
241 270 > a
242 271 > z
243 272 > a
244 273 > EOF
245 274 $ hg ci -mc -d '3 0'
246 275 created new head
276 BROKEN: 'a' was copied to 'b' on both sides. We should not get a merge conflict here
247 277 $ hg merge
248 278 merging b
249 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
250 (branch merge, don't forget to commit)
251 $ cat <<EOF >> b
279 warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
280 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
281 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
282 [1]
283 $ cat b
284 <<<<<<< working copy: b80e3e32f75a - test: c
285 a
286 z
287 a
288 ||||||| base
289 =======
290 a
291 a
292 a
293 b4
294 c
295 b5
296 >>>>>>> merge rev: 64afcdf8e29e - test: mergeb
297 $ cat <<EOF > b
298 > a
299 > z
300 > a
252 301 > b4
253 302 > c
254 303 > b5
255 304 > EOF
305 $ hg resolve --mark -q
306 $ rm b.orig
256 307 $ echo d >> b
257 308 $ hg ci -mmerge2 -d '4 0'
258 309
259 310 annotate after rename merge
260 311
261 312 $ hg annotate -nf b
262 313 0 a: a
263 314 6 b: z
264 315 1 a: a
265 316 3 b: b4
266 317 4 b: c
267 318 3 b: b5
268 319 7 b: d
269 320
270 321 annotate after rename merge with -l
271 322
272 323 $ hg annotate -nlf b
273 324 0 a:1: a
274 325 6 b:2: z
275 326 1 a:3: a
276 327 3 b:4: b4
277 328 4 b:5: c
278 329 3 b:5: b5
279 330 7 b:7: d
280 331
281 332 --skip nothing (should be the same as no --skip at all)
282 333
283 334 $ hg annotate -nlf b --skip '1::0'
284 335 0 a:1: a
285 336 6 b:2: z
286 337 1 a:3: a
287 338 3 b:4: b4
288 339 4 b:5: c
289 340 3 b:5: b5
290 341 7 b:7: d
291 342
292 343 --skip a modified line. Note a slight behavior difference in pure - this is
293 344 because the pure code comes up with slightly different deltas internally.
294 345
295 346 $ hg annotate -nlf b --skip 6
296 347 0 a:1: a
297 348 1 a:2* z (no-pure !)
298 349 0 a:1* z (pure !)
299 350 1 a:3: a
300 351 3 b:4: b4
301 352 4 b:5: c
302 353 3 b:5: b5
303 354 7 b:7: d
304 355
305 356 --skip added lines (and test multiple skip)
306 357
307 358 $ hg annotate -nlf b --skip 3
308 359 0 a:1: a
309 360 6 b:2: z
310 361 1 a:3: a
311 362 1 a:3* b4
312 363 4 b:5: c
313 364 1 a:3* b5
314 365 7 b:7: d
315 366
316 367 $ hg annotate -nlf b --skip 4
317 368 0 a:1: a
318 369 6 b:2: z
319 370 1 a:3: a
320 371 3 b:4: b4
321 372 1 a:3* c
322 373 3 b:5: b5
323 374 7 b:7: d
324 375
325 376 $ hg annotate -nlf b --skip 3 --skip 4
326 377 0 a:1: a
327 378 6 b:2: z
328 379 1 a:3: a
329 380 1 a:3* b4
330 381 1 a:3* c
331 382 1 a:3* b5
332 383 7 b:7: d
333 384
334 385 $ hg annotate -nlf b --skip 'merge()'
335 386 0 a:1: a
336 387 6 b:2: z
337 388 1 a:3: a
338 389 3 b:4: b4
339 390 4 b:5: c
340 391 3 b:5: b5
341 392 3 b:5* d
342 393
343 394 --skip everything -- use the revision the file was introduced in
344 395
345 396 $ hg annotate -nlf b --skip 'all()'
346 397 0 a:1: a
347 398 0 a:1* z
348 399 0 a:1* a
349 400 0 a:1* b4
350 401 0 a:1* c
351 402 0 a:1* b5
352 403 0 a:1* d
353 404
354 405 Issue2807: alignment of line numbers with -l
355 406
356 407 $ echo more >> b
357 408 $ hg ci -mmore -d '5 0'
358 409 $ echo more >> b
359 410 $ hg ci -mmore -d '6 0'
360 411 $ echo more >> b
361 412 $ hg ci -mmore -d '7 0'
362 413 $ hg annotate -nlf b
363 414 0 a: 1: a
364 415 6 b: 2: z
365 416 1 a: 3: a
366 417 3 b: 4: b4
367 418 4 b: 5: c
368 419 3 b: 5: b5
369 420 7 b: 7: d
370 421 8 b: 8: more
371 422 9 b: 9: more
372 423 10 b:10: more
373 424
374 425 linkrev vs rev
375 426
376 427 $ hg annotate -r tip -n a
377 428 0: a
378 429 1: a
379 430 1: a
380 431
381 432 linkrev vs rev with -l
382 433
383 434 $ hg annotate -r tip -nl a
384 435 0:1: a
385 436 1:2: a
386 437 1:3: a
387 438
388 439 Issue589: "undelete" sequence leads to crash
389 440
390 441 annotate was crashing when trying to --follow something
391 442
392 443 like A -> B -> A
393 444
394 445 generate ABA rename configuration
395 446
396 447 $ echo foo > foo
397 448 $ hg add foo
398 449 $ hg ci -m addfoo
399 450 $ hg rename foo bar
400 451 $ hg ci -m renamefoo
401 452 $ hg rename bar foo
402 453 $ hg ci -m renamebar
403 454
404 455 annotate after ABA with follow
405 456
406 457 $ hg annotate --follow foo
407 458 foo: foo
408 459
409 460 missing file
410 461
411 462 $ hg ann nosuchfile
412 463 abort: nosuchfile: no such file in rev e9e6b4fa872f
413 464 [255]
414 465
415 466 annotate file without '\n' on last line
416 467
417 468 $ printf "" > c
418 469 $ hg ci -A -m test -u nobody -d '1 0'
419 470 adding c
420 471 $ hg annotate c
421 472 $ printf "a\nb" > c
422 473 $ hg ci -m test
423 474 $ hg annotate c
424 475 [0-9]+: a (re)
425 476 [0-9]+: b (re)
426 477
427 478 Issue3841: check annotation of the file of which filelog includes
428 479 merging between the revision and its ancestor
429 480
430 481 to reproduce the situation with recent Mercurial, this script uses (1)
431 482 "hg debugsetparents" to merge without ancestor check by "hg merge",
432 483 and (2) the extension to allow filelog merging between the revision
433 484 and its ancestor by overriding "repo._filecommit".
434 485
435 486 $ cat > ../legacyrepo.py <<EOF
436 487 > from __future__ import absolute_import
437 488 > from mercurial import error, node
438 489 > def reposetup(ui, repo):
439 490 > class legacyrepo(repo.__class__):
440 491 > def _filecommit(self, fctx, manifest1, manifest2,
441 492 > linkrev, tr, changelist, includecopymeta):
442 493 > fname = fctx.path()
443 494 > text = fctx.data()
444 495 > flog = self.file(fname)
445 496 > fparent1 = manifest1.get(fname, node.nullid)
446 497 > fparent2 = manifest2.get(fname, node.nullid)
447 498 > meta = {}
448 499 > copy = fctx.copysource()
449 500 > if copy and copy != fname:
450 501 > raise error.Abort('copying is not supported')
451 502 > if fparent2 != node.nullid:
452 503 > changelist.append(fname)
453 504 > return flog.add(text, meta, tr, linkrev,
454 505 > fparent1, fparent2)
455 506 > raise error.Abort('only merging is supported')
456 507 > repo.__class__ = legacyrepo
457 508 > EOF
458 509
459 510 $ cat > baz <<EOF
460 511 > 1
461 512 > 2
462 513 > 3
463 514 > 4
464 515 > 5
465 516 > EOF
466 517 $ hg add baz
467 518 $ hg commit -m "baz:0"
468 519
469 520 $ cat > baz <<EOF
470 521 > 1 baz:1
471 522 > 2
472 523 > 3
473 524 > 4
474 525 > 5
475 526 > EOF
476 527 $ hg commit -m "baz:1"
477 528
478 529 $ cat > baz <<EOF
479 530 > 1 baz:1
480 531 > 2 baz:2
481 532 > 3
482 533 > 4
483 534 > 5
484 535 > EOF
485 536 $ hg debugsetparents 17 17
486 537 $ hg --config extensions.legacyrepo=../legacyrepo.py commit -m "baz:2"
487 538 $ hg debugindexdot baz
488 539 digraph G {
489 540 -1 -> 0
490 541 0 -> 1
491 542 1 -> 2
492 543 1 -> 2
493 544 }
494 545 $ hg annotate baz
495 546 17: 1 baz:1
496 547 18: 2 baz:2
497 548 16: 3
498 549 16: 4
499 550 16: 5
500 551
501 552 $ cat > baz <<EOF
502 553 > 1 baz:1
503 554 > 2 baz:2
504 555 > 3 baz:3
505 556 > 4
506 557 > 5
507 558 > EOF
508 559 $ hg commit -m "baz:3"
509 560
510 561 $ cat > baz <<EOF
511 562 > 1 baz:1
512 563 > 2 baz:2
513 564 > 3 baz:3
514 565 > 4 baz:4
515 566 > 5
516 567 > EOF
517 568 $ hg debugsetparents 19 18
518 569 $ hg --config extensions.legacyrepo=../legacyrepo.py commit -m "baz:4"
519 570 $ hg debugindexdot baz
520 571 digraph G {
521 572 -1 -> 0
522 573 0 -> 1
523 574 1 -> 2
524 575 1 -> 2
525 576 2 -> 3
526 577 3 -> 4
527 578 2 -> 4
528 579 }
529 580 $ hg annotate baz
530 581 17: 1 baz:1
531 582 18: 2 baz:2
532 583 19: 3 baz:3
533 584 20: 4 baz:4
534 585 16: 5
535 586
536 587 annotate clean file
537 588
538 589 $ hg annotate -ncr "wdir()" foo
539 590 11 472b18db256d : foo
540 591
541 592 annotate modified file
542 593
543 594 $ echo foofoo >> foo
544 595 $ hg annotate -r "wdir()" foo
545 596 11 : foo
546 597 20+: foofoo
547 598
548 599 $ hg annotate -cr "wdir()" foo
549 600 472b18db256d : foo
550 601 b6bedd5477e7+: foofoo
551 602
552 603 $ hg annotate -ncr "wdir()" foo
553 604 11 472b18db256d : foo
554 605 20 b6bedd5477e7+: foofoo
555 606
556 607 $ hg annotate --debug -ncr "wdir()" foo
557 608 11 472b18db256d1e8282064eab4bfdaf48cbfe83cd : foo
558 609 20 b6bedd5477e797f25e568a6402d4697f3f895a72+: foofoo
559 610
560 611 $ hg annotate -udr "wdir()" foo
561 612 test Thu Jan 01 00:00:00 1970 +0000: foo
562 613 test [A-Za-z0-9:+ ]+: foofoo (re)
563 614
564 615 $ hg annotate -ncr "wdir()" -Tjson foo
565 616 [
566 617 {
567 618 "lines": [{"line": "foo\n", "node": "472b18db256d1e8282064eab4bfdaf48cbfe83cd", "rev": 11}, {"line": "foofoo\n", "node": "ffffffffffffffffffffffffffffffffffffffff", "rev": 2147483647}],
568 619 "path": "foo"
569 620 }
570 621 ]
571 622
572 623 annotate added file
573 624
574 625 $ echo bar > bar
575 626 $ hg add bar
576 627 $ hg annotate -ncr "wdir()" bar
577 628 20 b6bedd5477e7+: bar
578 629
579 630 annotate renamed file
580 631
581 632 $ hg rename foo renamefoo2
582 633 $ hg annotate -ncr "wdir()" renamefoo2
583 634 11 472b18db256d : foo
584 635 20 b6bedd5477e7+: foofoo
585 636
586 637 annotate missing file
587 638
588 639 $ rm baz
589 640
590 641 $ hg annotate -ncr "wdir()" baz
591 642 abort: $TESTTMP\repo\baz: $ENOENT$ (windows !)
592 643 abort: $ENOENT$: '$TESTTMP/repo/baz' (no-windows !)
593 644 [255]
594 645
595 646 annotate removed file
596 647
597 648 $ hg rm baz
598 649
599 650 $ hg annotate -ncr "wdir()" baz
600 651 abort: $TESTTMP\repo\baz: $ENOENT$ (windows !)
601 652 abort: $ENOENT$: '$TESTTMP/repo/baz' (no-windows !)
602 653 [255]
603 654
604 655 $ hg revert --all --no-backup --quiet
605 656 $ hg id -n
606 657 20
607 658
608 659 Test followlines() revset; we usually check both followlines(pat, range) and
609 660 followlines(pat, range, descend=True) to make sure both give the same result
610 661 when they should.
611 662
612 663 $ echo a >> foo
613 664 $ hg ci -m 'foo: add a'
614 665 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 3:5)'
615 666 16: baz:0
616 667 19: baz:3
617 668 20: baz:4
618 669 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 3:5, startrev=20)'
619 670 16: baz:0
620 671 19: baz:3
621 672 20: baz:4
622 673 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 3:5, startrev=19)'
623 674 16: baz:0
624 675 19: baz:3
625 676 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 3:5, startrev=19, descend=True)'
626 677 19: baz:3
627 678 20: baz:4
628 679 $ printf "0\n0\n" | cat - baz > baz1
629 680 $ mv baz1 baz
630 681 $ hg ci -m 'added two lines with 0'
631 682 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 5:7)'
632 683 16: baz:0
633 684 19: baz:3
634 685 20: baz:4
635 686 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 3:5, descend=true, startrev=19)'
636 687 19: baz:3
637 688 20: baz:4
638 689 $ echo 6 >> baz
639 690 $ hg ci -m 'added line 8'
640 691 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 5:7)'
641 692 16: baz:0
642 693 19: baz:3
643 694 20: baz:4
644 695 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 3:5, startrev=19, descend=1)'
645 696 19: baz:3
646 697 20: baz:4
647 698 $ sed 's/3/3+/' baz > baz.new
648 699 $ mv baz.new baz
649 700 $ hg ci -m 'baz:3->3+'
650 701 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 5:7, descend=0)'
651 702 16: baz:0
652 703 19: baz:3
653 704 20: baz:4
654 705 24: baz:3->3+
655 706 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 3:5, startrev=17, descend=True)'
656 707 19: baz:3
657 708 20: baz:4
658 709 24: baz:3->3+
659 710 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 1:2, descend=false)'
660 711 22: added two lines with 0
661 712
662 713 file patterns are okay
663 714 $ hg log -T '{rev}: {desc}\n' -r 'followlines("path:baz", 1:2)'
664 715 22: added two lines with 0
665 716
666 717 renames are followed
667 718 $ hg mv baz qux
668 719 $ sed 's/4/4+/' qux > qux.new
669 720 $ mv qux.new qux
670 721 $ hg ci -m 'qux:4->4+'
671 722 $ hg log -T '{rev}: {desc}\n' -r 'followlines(qux, 5:7)'
672 723 16: baz:0
673 724 19: baz:3
674 725 20: baz:4
675 726 24: baz:3->3+
676 727 25: qux:4->4+
677 728
678 729 but are missed when following children
679 730 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 5:7, startrev=22, descend=True)'
680 731 24: baz:3->3+
681 732
682 733 merge
683 734 $ hg up 24 --quiet
684 735 $ echo 7 >> baz
685 736 $ hg ci -m 'one more line, out of line range'
686 737 created new head
687 738 $ sed 's/3+/3-/' baz > baz.new
688 739 $ mv baz.new baz
689 740 $ hg ci -m 'baz:3+->3-'
690 741 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 5:7)'
691 742 16: baz:0
692 743 19: baz:3
693 744 20: baz:4
694 745 24: baz:3->3+
695 746 27: baz:3+->3-
696 747 $ hg merge 25
697 748 merging baz and qux to qux
698 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
699 (branch merge, don't forget to commit)
749 warning: conflicts while merging qux! (edit, then use 'hg resolve --mark')
750 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
751 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
752 [1]
753 $ cat qux
754 0
755 0
756 1 baz:1
757 2 baz:2
758 <<<<<<< working copy: 863de62655ef - test: baz:3+->3-
759 3- baz:3
760 4 baz:4
761 ||||||| base
762 3+ baz:3
763 4 baz:4
764 =======
765 3+ baz:3
766 4+ baz:4
767 >>>>>>> merge rev: cb8df70ae185 - test: qux:4->4+
768 5
769 6
770 7
771 $ cat > qux <<EOF
772 > 0
773 > 0
774 > 1 baz:1
775 > 2 baz:2
776 > 3- baz:3
777 > 4 baz:4
778 > 5
779 > 6
780 > 7
781 > EOF
782 $ hg resolve --mark -q
783 $ rm qux.orig
700 784 $ hg ci -m merge
701 785 $ hg log -T '{rev}: {desc}\n' -r 'followlines(qux, 5:7)'
702 786 16: baz:0
703 787 19: baz:3
704 788 20: baz:4
705 789 24: baz:3->3+
706 790 25: qux:4->4+
707 791 27: baz:3+->3-
708 792 28: merge
709 793 $ hg up 25 --quiet
710 794 $ hg merge 27
711 795 merging qux and baz to qux
712 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
713 (branch merge, don't forget to commit)
796 warning: conflicts while merging qux! (edit, then use 'hg resolve --mark')
797 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
798 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
799 [1]
800 $ cat qux
801 0
802 0
803 1 baz:1
804 2 baz:2
805 <<<<<<< working copy: cb8df70ae185 - test: qux:4->4+
806 3+ baz:3
807 4+ baz:4
808 ||||||| base
809 3+ baz:3
810 4 baz:4
811 =======
812 3- baz:3
813 4 baz:4
814 >>>>>>> merge rev: 863de62655ef - test: baz:3+->3-
815 5
816 6
817 7
818 $ cat > qux <<EOF
819 > 0
820 > 0
821 > 1 baz:1
822 > 2 baz:2
823 > 3+ baz:3
824 > 4+ baz:4
825 > 5
826 > 6
827 > EOF
828 $ hg resolve --mark -q
829 $ rm qux.orig
714 830 $ hg ci -m 'merge from other side'
715 831 created new head
716 832 $ hg log -T '{rev}: {desc}\n' -r 'followlines(qux, 5:7)'
717 833 16: baz:0
718 834 19: baz:3
719 835 20: baz:4
720 836 24: baz:3->3+
721 837 25: qux:4->4+
722 838 27: baz:3+->3-
723 839 29: merge from other side
724 840 $ hg up 24 --quiet
725 841
726 842 we are missing the branch with rename when following children
727 843 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 5:7, startrev=26, descend=True)'
728 844 27: baz:3+->3-
729 845
730 846 we follow all branches in descending direction
731 847 $ hg up 23 --quiet
732 848 $ sed 's/3/+3/' baz > baz.new
733 849 $ mv baz.new baz
734 850 $ hg ci -m 'baz:3->+3'
735 851 created new head
736 852 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 2:5, startrev=16, descend=True)' --graph
737 853 @ 30: baz:3->+3
738 854 :
739 855 : o 27: baz:3+->3-
740 856 : :
741 857 : o 24: baz:3->3+
742 858 :/
743 859 o 20: baz:4
744 860 |\
745 861 | o 19: baz:3
746 862 |/
747 863 o 18: baz:2
748 864 :
749 865 o 16: baz:0
750 866 |
751 867 ~
752 868
753 869 Issue5595: on a merge changeset with different line ranges depending on
754 870 parent, be conservative and use the surrounding interval to avoid loosing
755 871 track of possible further descendants in specified range.
756 872
757 873 $ hg up 23 --quiet
758 874 $ hg cat baz -r 24
759 875 0
760 876 0
761 877 1 baz:1
762 878 2 baz:2
763 879 3+ baz:3
764 880 4 baz:4
765 881 5
766 882 6
767 883 $ cat > baz << EOF
768 884 > 0
769 885 > 0
770 886 > a
771 887 > b
772 888 > 3+ baz:3
773 889 > 4 baz:4
774 890 > y
775 891 > z
776 892 > EOF
777 893 $ hg ci -m 'baz: mostly rewrite with some content from 24'
778 894 created new head
779 895 $ hg merge --tool :merge-other 24
780 896 merging baz
781 897 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
782 898 (branch merge, don't forget to commit)
783 899 $ hg ci -m 'merge forgetting about baz rewrite'
784 900 $ cat > baz << EOF
785 901 > 0
786 902 > 0
787 903 > 1 baz:1
788 904 > 2+ baz:2
789 905 > 3+ baz:3
790 906 > 4 baz:4
791 907 > 5
792 908 > 6
793 909 > EOF
794 910 $ hg ci -m 'baz: narrow change (2->2+)'
795 911 $ hg log -T '{rev}: {desc}\n' -r 'followlines(baz, 3:4, startrev=20, descend=True)' --graph
796 912 @ 33: baz: narrow change (2->2+)
797 913 |
798 914 o 32: merge forgetting about baz rewrite
799 915 |\
800 916 | o 31: baz: mostly rewrite with some content from 24
801 917 | :
802 918 | : o 30: baz:3->+3
803 919 | :/
804 920 +---o 27: baz:3+->3-
805 921 | :
806 922 o : 24: baz:3->3+
807 923 :/
808 924 o 20: baz:4
809 925 |\
810 926 ~ ~
811 927
812 928 An integer as a line range, which is parsed as '1:1'
813 929
814 930 $ hg log -r 'followlines(baz, 1)'
815 931 changeset: 22:2174d0bf352a
816 932 user: test
817 933 date: Thu Jan 01 00:00:00 1970 +0000
818 934 summary: added two lines with 0
819 935
820 936
821 937 check error cases
822 938 $ hg up 24 --quiet
823 939 $ hg log -r 'followlines()'
824 940 hg: parse error: followlines takes at least 1 positional arguments
825 941 [255]
826 942 $ hg log -r 'followlines(baz)'
827 943 hg: parse error: followlines requires a line range
828 944 [255]
829 945 $ hg log -r 'followlines(baz, x)'
830 946 hg: parse error: followlines expects a line number or a range
831 947 [255]
832 948 $ hg log -r 'followlines(baz, 1:2, startrev=desc("b"))'
833 949 hg: parse error: followlines expects exactly one revision
834 950 [255]
835 951 $ hg log -r 'followlines("glob:*", 1:2)'
836 952 hg: parse error: followlines expects exactly one file
837 953 [255]
838 954 $ hg log -r 'followlines(baz, 1:)'
839 955 hg: parse error: line range bounds must be integers
840 956 [255]
841 957 $ hg log -r 'followlines(baz, :1)'
842 958 hg: parse error: line range bounds must be integers
843 959 [255]
844 960 $ hg log -r 'followlines(baz, x:4)'
845 961 hg: parse error: line range bounds must be integers
846 962 [255]
847 963 $ hg log -r 'followlines(baz, 5:4)'
848 964 hg: parse error: line range must be positive
849 965 [255]
850 966 $ hg log -r 'followlines(baz, 0:4)'
851 967 hg: parse error: fromline must be strictly positive
852 968 [255]
853 969 $ hg log -r 'followlines(baz, 2:40)'
854 970 abort: line range exceeds file size
855 971 [255]
856 972 $ hg log -r 'followlines(baz, 2:4, startrev=20, descend=[1])'
857 973 hg: parse error at 43: not a prefix: [
858 974 (followlines(baz, 2:4, startrev=20, descend=[1])
859 975 ^ here)
860 976 [255]
861 977 $ hg log -r 'followlines(baz, 2:4, startrev=20, descend=a)'
862 978 hg: parse error: descend argument must be a boolean
863 979 [255]
864 980
865 981 Test empty annotate output
866 982
867 983 $ printf '\0' > binary
868 984 $ touch empty
869 985 $ hg ci -qAm 'add binary and empty files'
870 986
871 987 $ hg annotate binary empty
872 988 binary: binary file
873 989
874 990 $ hg annotate -Tjson binary empty
875 991 [
876 992 {
877 993 "path": "binary"
878 994 },
879 995 {
880 996 "lines": [],
881 997 "path": "empty"
882 998 }
883 999 ]
884 1000
885 1001 Test annotate with whitespace options
886 1002
887 1003 $ cd ..
888 1004 $ hg init repo-ws
889 1005 $ cd repo-ws
890 1006 $ cat > a <<EOF
891 1007 > aa
892 1008 >
893 1009 > b b
894 1010 > EOF
895 1011 $ hg ci -Am "adda"
896 1012 adding a
897 1013 $ sed 's/EOL$//g' > a <<EOF
898 1014 > a a
899 1015 >
900 1016 > EOL
901 1017 > b b
902 1018 > EOF
903 1019 $ hg ci -m "changea"
904 1020
905 1021 Annotate with no option
906 1022
907 1023 $ hg annotate a
908 1024 1: a a
909 1025 0:
910 1026 1:
911 1027 1: b b
912 1028
913 1029 Annotate with --ignore-space-change
914 1030
915 1031 $ hg annotate --ignore-space-change a
916 1032 1: a a
917 1033 1:
918 1034 0:
919 1035 0: b b
920 1036
921 1037 Annotate with --ignore-all-space
922 1038
923 1039 $ hg annotate --ignore-all-space a
924 1040 0: a a
925 1041 0:
926 1042 1:
927 1043 0: b b
928 1044
929 1045 Annotate with --ignore-blank-lines (similar to no options case)
930 1046
931 1047 $ hg annotate --ignore-blank-lines a
932 1048 1: a a
933 1049 0:
934 1050 1:
935 1051 1: b b
936 1052
937 1053 $ cd ..
938 1054
939 1055 Annotate with orphaned CR (issue5798)
940 1056 -------------------------------------
941 1057
942 1058 $ hg init repo-cr
943 1059 $ cd repo-cr
944 1060
945 1061 $ cat <<'EOF' >> "$TESTTMP/substcr.py"
946 1062 > import sys
947 1063 > from mercurial.utils import procutil
948 1064 > procutil.setbinary(sys.stdin)
949 1065 > procutil.setbinary(sys.stdout)
950 1066 > stdin = getattr(sys.stdin, 'buffer', sys.stdin)
951 1067 > stdout = getattr(sys.stdout, 'buffer', sys.stdout)
952 1068 > stdout.write(stdin.read().replace(b'\r', b'[CR]'))
953 1069 > EOF
954 1070
955 1071 >>> with open('a', 'wb') as f:
956 1072 ... f.write(b'0a\r0b\r\n0c\r0d\r\n0e\n0f\n0g') and None
957 1073 $ hg ci -qAm0
958 1074 >>> with open('a', 'wb') as f:
959 1075 ... f.write(b'0a\r0b\r\n1c\r1d\r\n0e\n1f\n0g') and None
960 1076 $ hg ci -m1
961 1077
962 1078 $ hg annotate -r0 a | "$PYTHON" "$TESTTMP/substcr.py"
963 1079 0: 0a[CR]0b[CR]
964 1080 0: 0c[CR]0d[CR]
965 1081 0: 0e
966 1082 0: 0f
967 1083 0: 0g
968 1084 $ hg annotate -r1 a | "$PYTHON" "$TESTTMP/substcr.py"
969 1085 0: 0a[CR]0b[CR]
970 1086 1: 1c[CR]1d[CR]
971 1087 0: 0e
972 1088 1: 1f
973 1089 0: 0g
974 1090
975 1091 $ cd ..
976 1092
977 1093 Annotate with linkrev pointing to another branch
978 1094 ------------------------------------------------
979 1095
980 1096 create history with a filerev whose linkrev points to another branch
981 1097
982 1098 $ hg init branchedlinkrev
983 1099 $ cd branchedlinkrev
984 1100 $ echo A > a
985 1101 $ hg commit -Am 'contentA'
986 1102 adding a
987 1103 $ echo B >> a
988 1104 $ hg commit -m 'contentB'
989 1105 $ hg up --rev 'desc(contentA)'
990 1106 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
991 1107 $ echo unrelated > unrelated
992 1108 $ hg commit -Am 'unrelated'
993 1109 adding unrelated
994 1110 created new head
995 1111 $ hg graft -r 'desc(contentB)'
996 1112 grafting 1:fd27c222e3e6 "contentB"
997 1113 $ echo C >> a
998 1114 $ hg commit -m 'contentC'
999 1115 $ echo W >> a
1000 1116 $ hg log -G
1001 1117 @ changeset: 4:072f1e8df249
1002 1118 | tag: tip
1003 1119 | user: test
1004 1120 | date: Thu Jan 01 00:00:00 1970 +0000
1005 1121 | summary: contentC
1006 1122 |
1007 1123 o changeset: 3:ff38df03cc4b
1008 1124 | user: test
1009 1125 | date: Thu Jan 01 00:00:00 1970 +0000
1010 1126 | summary: contentB
1011 1127 |
1012 1128 o changeset: 2:62aaf3f6fc06
1013 1129 | parent: 0:f0932f74827e
1014 1130 | user: test
1015 1131 | date: Thu Jan 01 00:00:00 1970 +0000
1016 1132 | summary: unrelated
1017 1133 |
1018 1134 | o changeset: 1:fd27c222e3e6
1019 1135 |/ user: test
1020 1136 | date: Thu Jan 01 00:00:00 1970 +0000
1021 1137 | summary: contentB
1022 1138 |
1023 1139 o changeset: 0:f0932f74827e
1024 1140 user: test
1025 1141 date: Thu Jan 01 00:00:00 1970 +0000
1026 1142 summary: contentA
1027 1143
1028 1144
1029 1145 Annotate should list ancestor of starting revision only
1030 1146
1031 1147 $ hg annotate a
1032 1148 0: A
1033 1149 3: B
1034 1150 4: C
1035 1151
1036 1152 $ hg annotate a -r 'wdir()'
1037 1153 0 : A
1038 1154 3 : B
1039 1155 4 : C
1040 1156 4+: W
1041 1157
1042 1158 Even when the starting revision is the linkrev-shadowed one:
1043 1159
1044 1160 $ hg annotate a -r 3
1045 1161 0: A
1046 1162 3: B
1047 1163
1048 1164 $ cd ..
1049 1165
1050 1166 Issue5360: Deleted chunk in p1 of a merge changeset
1051 1167
1052 1168 $ hg init repo-5360
1053 1169 $ cd repo-5360
1054 1170 $ echo 1 > a
1055 1171 $ hg commit -A a -m 1
1056 1172 $ echo 2 >> a
1057 1173 $ hg commit -m 2
1058 1174 $ echo a > a
1059 1175 $ hg commit -m a
1060 1176 $ hg update '.^' -q
1061 1177 $ echo 3 >> a
1062 1178 $ hg commit -m 3 -q
1063 1179 $ hg merge 2 -q
1180 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
1181 [1]
1182 $ cat a
1183 <<<<<<< working copy: 0a068f0261cf - test: 3
1184 1
1185 2
1186 3
1187 ||||||| base
1188 1
1189 2
1190 =======
1191 a
1192 >>>>>>> merge rev: 9409851bc20a - test: a
1064 1193 $ cat > a << EOF
1065 1194 > b
1066 1195 > 1
1067 1196 > 2
1068 1197 > 3
1069 1198 > a
1070 1199 > EOF
1071 1200 $ hg resolve --mark -q
1201 $ rm a.orig
1072 1202 $ hg commit -m m
1073 1203 $ hg annotate a
1074 1204 4: b
1075 1205 0: 1
1076 1206 1: 2
1077 1207 3: 3
1078 1208 2: a
1079 1209
1080 1210 $ cd ..
@@ -1,764 +1,826 b''
1 1 (this file is backported from core hg tests/test-annotate.t)
2 2
3 3 $ cat >> $HGRCPATH << EOF
4 > [ui]
5 > merge = :merge3
4 6 > [diff]
5 7 > git=1
6 8 > [extensions]
7 9 > fastannotate=
8 10 > [fastannotate]
9 11 > modes=fctx
10 12 > forcefollow=False
11 13 > mainbranch=.
12 14 > EOF
13 15
14 $ HGMERGE=true; export HGMERGE
15
16 16 init
17 17
18 18 $ hg init repo
19 19 $ cd repo
20 20
21 21 commit
22 22
23 23 $ echo 'a' > a
24 24 $ hg ci -A -m test -u nobody -d '1 0'
25 25 adding a
26 26
27 27 annotate -c
28 28
29 29 $ hg annotate -c a
30 30 8435f90966e4: a
31 31
32 32 annotate -cl
33 33
34 34 $ hg annotate -cl a
35 35 8435f90966e4:1: a
36 36
37 37 annotate -d
38 38
39 39 $ hg annotate -d a
40 40 Thu Jan 01 00:00:01 1970 +0000: a
41 41
42 42 annotate -n
43 43
44 44 $ hg annotate -n a
45 45 0: a
46 46
47 47 annotate -nl
48 48
49 49 $ hg annotate -nl a
50 50 0:1: a
51 51
52 52 annotate -u
53 53
54 54 $ hg annotate -u a
55 55 nobody: a
56 56
57 57 annotate -cdnu
58 58
59 59 $ hg annotate -cdnu a
60 60 nobody 0 8435f90966e4 Thu Jan 01 00:00:01 1970 +0000: a
61 61
62 62 annotate -cdnul
63 63
64 64 $ hg annotate -cdnul a
65 65 nobody 0 8435f90966e4 Thu Jan 01 00:00:01 1970 +0000:1: a
66 66
67 67 annotate (JSON)
68 68
69 69 $ hg annotate -Tjson a
70 70 [
71 71 {
72 72 "lines": [{"line": "a\n", "rev": 0}],
73 73 "path": "a"
74 74 }
75 75 ]
76 76
77 77 $ hg annotate -Tjson -cdfnul a
78 78 [
79 79 {
80 80 "lines": [{"date": [1.0, 0], "line": "a\n", "lineno": 1, "node": "8435f90966e442695d2ded29fdade2bac5ad8065", "path": "a", "rev": 0, "user": "nobody"}],
81 81 "path": "a"
82 82 }
83 83 ]
84 84
85 85 $ cat <<EOF >>a
86 86 > a
87 87 > a
88 88 > EOF
89 89 $ hg ci -ma1 -d '1 0'
90 90 $ hg cp a b
91 91 $ hg ci -mb -d '1 0'
92 92 $ cat <<EOF >> b
93 93 > b4
94 94 > b5
95 95 > b6
96 96 > EOF
97 97 $ hg ci -mb2 -d '2 0'
98 98
99 99 annotate -n b
100 100
101 101 $ hg annotate -n b
102 102 0: a
103 103 1: a
104 104 1: a
105 105 3: b4
106 106 3: b5
107 107 3: b6
108 108
109 109 annotate --no-follow b
110 110
111 111 $ hg annotate --no-follow b
112 112 2: a
113 113 2: a
114 114 2: a
115 115 3: b4
116 116 3: b5
117 117 3: b6
118 118
119 119 annotate -nl b
120 120
121 121 $ hg annotate -nl b
122 122 0:1: a
123 123 1:2: a
124 124 1:3: a
125 125 3:4: b4
126 126 3:5: b5
127 127 3:6: b6
128 128
129 129 annotate -nf b
130 130
131 131 $ hg annotate -nf b
132 132 0 a: a
133 133 1 a: a
134 134 1 a: a
135 135 3 b: b4
136 136 3 b: b5
137 137 3 b: b6
138 138
139 139 annotate -nlf b
140 140
141 141 $ hg annotate -nlf b
142 142 0 a:1: a
143 143 1 a:2: a
144 144 1 a:3: a
145 145 3 b:4: b4
146 146 3 b:5: b5
147 147 3 b:6: b6
148 148
149 149 $ hg up -C 2
150 150 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
151 151 $ cat <<EOF >> b
152 152 > b4
153 153 > c
154 154 > b5
155 155 > EOF
156 156 $ hg ci -mb2.1 -d '2 0'
157 157 created new head
158 158 $ hg merge
159 159 merging b
160 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
161 (branch merge, don't forget to commit)
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 ||||||| base
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
162 188 $ hg ci -mmergeb -d '3 0'
163 189
164 190 annotate after merge
165 191 (note: the first one falls back to the vanilla annotate which does not use linelog)
166 192
167 193 $ hg annotate -nf b --debug
168 194 fastannotate: b: rebuilding broken cache
169 195 fastannotate: b: 5 new changesets in the main branch
170 196 0 a: a
171 197 1 a: a
172 198 1 a: a
173 199 3 b: b4
174 200 4 b: c
175 201 3 b: b5
176 202
177 203 (difference explained below)
178 204
179 205 $ hg annotate -nf b --debug
180 206 fastannotate: b: using fast path (resolved fctx: False)
181 207 0 a: a
182 208 1 a: a
183 209 1 a: a
184 210 4 b: b4
185 211 4 b: c
186 212 4 b: b5
187 213
188 214 annotate after merge with -l
189 215 (fastannotate differs from annotate)
190 216
191 217 $ hg log -Gp -T '{rev}:{node}' -r '2..5'
192 218 @ 5:64afcdf8e29e063c635be123d8d2fb160af00f7e
193 219 |\
194 220 | o 4:5fbdc1152d97597717021ad9e063061b200f146bdiff --git a/b b/b
195 221 | | --- a/b
196 222 | | +++ b/b
197 223 | | @@ -1,3 +1,6 @@
198 224 | | a
199 225 | | a
200 226 | | a
201 227 | | +b4
202 228 | | +c
203 229 | | +b5
204 230 | |
205 231 o | 3:37ec9f5c3d1f99572d7075971cb4876e2139b52fdiff --git a/b b/b
206 232 |/ --- a/b
207 233 | +++ b/b
208 234 | @@ -1,3 +1,6 @@
209 235 | a
210 236 | a
211 237 | a
212 238 | +b4
213 239 | +b5
214 240 | +b6
215 241 |
216 242 o 2:3086dbafde1ce745abfc8d2d367847280aabae9ddiff --git a/a b/b
217 243 | copy from a
218 244 ~ copy to b
219 245
220 246
221 247 (in this case, "b4", "b5" could be considered introduced by either rev 3, or rev 4.
222 248 and that causes the rev number difference)
223 249
224 250 $ hg annotate -nlf b --config fastannotate.modes=
225 251 0 a:1: a
226 252 1 a:2: a
227 253 1 a:3: a
228 254 3 b:4: b4
229 255 4 b:5: c
230 256 3 b:5: b5
231 257
232 258 $ hg annotate -nlf b
233 259 0 a:1: a
234 260 1 a:2: a
235 261 1 a:3: a
236 262 4 b:4: b4
237 263 4 b:5: c
238 264 4 b:6: b5
239 265
240 266 $ hg up -C 1
241 267 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
242 268 $ hg cp a b
243 269 $ cat <<EOF > b
244 270 > a
245 271 > z
246 272 > a
247 273 > EOF
248 274 $ hg ci -mc -d '3 0'
249 275 created new head
276 BROKEN: 'a' was copied to 'b' on both sides. We should not get a merge conflict here
250 277 $ hg merge
251 278 merging b
252 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
253 (branch merge, don't forget to commit)
254 $ cat <<EOF >> b
279 warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
280 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
281 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
282 [1]
283 $ cat b
284 <<<<<<< working copy: b80e3e32f75a - test: c
285 a
286 z
287 a
288 ||||||| base
289 =======
290 a
291 a
292 a
293 b4
294 c
295 b5
296 >>>>>>> merge rev: 64afcdf8e29e - test: mergeb
297 $ cat <<EOF > b
298 > a
299 > z
300 > a
255 301 > b4
256 302 > c
257 303 > b5
258 304 > EOF
305 $ hg resolve --mark -q
306 $ rm b.orig
259 307 $ echo d >> b
260 308 $ hg ci -mmerge2 -d '4 0'
261 309
262 310 annotate after rename merge
263 311
264 312 $ hg annotate -nf b
265 313 0 a: a
266 314 6 b: z
267 315 1 a: a
268 316 3 b: b4
269 317 4 b: c
270 318 3 b: b5
271 319 7 b: d
272 320
273 321 annotate after rename merge with -l
274 322 (fastannotate differs from annotate)
275 323
276 324 $ hg log -Gp -T '{rev}:{node}' -r '0+1+6+7'
277 325 @ 7:6284bb6c38fef984a929862a53bbc71ce9eafa81diff --git a/b b/b
278 326 |\ --- a/b
279 327 | : +++ b/b
280 328 | : @@ -1,3 +1,7 @@
281 329 | : a
282 330 | : z
283 331 | : a
284 332 | : +b4
285 333 | : +c
286 334 | : +b5
287 335 | : +d
288 336 | :
289 337 o : 6:b80e3e32f75a6a67cd4ac85496a11511e9112816diff --git a/a b/b
290 338 :/ copy from a
291 339 : copy to b
292 340 : --- a/a
293 341 : +++ b/b
294 342 : @@ -1,3 +1,3 @@
295 343 : -a (?)
296 344 : a
297 345 : +z
298 346 : a
299 347 : -a (?)
300 348 :
301 349 o 1:762f04898e6684ff713415f7b8a8d53d33f96c92diff --git a/a b/a
302 350 | --- a/a
303 351 | +++ b/a
304 352 | @@ -1,1 +1,3 @@
305 353 | a
306 354 | +a
307 355 | +a
308 356 |
309 357 o 0:8435f90966e442695d2ded29fdade2bac5ad8065diff --git a/a b/a
310 358 new file mode 100644
311 359 --- /dev/null
312 360 +++ b/a
313 361 @@ -0,0 +1,1 @@
314 362 +a
315 363
316 364
317 365 (note on question marks:
318 366 the upstream bdiff change (96f2f50d923f+3633403888ae+8c0c75aa3ff4+5c4e2636c1a9
319 367 +38ed54888617) alters the output so deletion is not always at the end of the
320 368 output. for example:
321 369 | a | b | old | new | # old: e1d6aa0e4c3a, new: 8836f13e3c5b
322 370 |-------------------|
323 371 | a | a | a | -a |
324 372 | a | z | +z | a |
325 373 | a | a | a | +z |
326 374 | | | -a | a |
327 375 |-------------------|
328 376 | a | a | a |
329 377 | a | a | a |
330 378 | a | | -a |
331 379 this leads to more question marks below)
332 380
333 381 (rev 1 adds two "a"s and rev 6 deletes one "a".
334 382 the "a" that rev 6 deletes could be either the first or the second "a" of those two "a"s added by rev 1.
335 383 and that causes the line number difference)
336 384
337 385 $ hg annotate -nlf b --config fastannotate.modes=
338 386 0 a:1: a
339 387 6 b:2: z
340 388 1 a:3: a
341 389 3 b:4: b4
342 390 4 b:5: c
343 391 3 b:5: b5
344 392 7 b:7: d
345 393
346 394 $ hg annotate -nlf b
347 395 0 a:1: a (?)
348 396 1 a:2: a (?)
349 397 6 b:2: z
350 398 1 a:2: a (?)
351 399 1 a:3: a (?)
352 400 3 b:4: b4
353 401 4 b:5: c
354 402 3 b:5: b5
355 403 7 b:7: d
356 404
357 405 Issue2807: alignment of line numbers with -l
358 406 (fastannotate differs from annotate, same reason as above)
359 407
360 408 $ echo more >> b
361 409 $ hg ci -mmore -d '5 0'
362 410 $ echo more >> b
363 411 $ hg ci -mmore -d '6 0'
364 412 $ echo more >> b
365 413 $ hg ci -mmore -d '7 0'
366 414 $ hg annotate -nlf b
367 415 0 a: 1: a (?)
368 416 1 a: 2: a (?)
369 417 6 b: 2: z
370 418 1 a: 2: a (?)
371 419 1 a: 3: a (?)
372 420 3 b: 4: b4
373 421 4 b: 5: c
374 422 3 b: 5: b5
375 423 7 b: 7: d
376 424 8 b: 8: more
377 425 9 b: 9: more
378 426 10 b:10: more
379 427
380 428 linkrev vs rev
381 429
382 430 $ hg annotate -r tip -n a
383 431 0: a
384 432 1: a
385 433 1: a
386 434
387 435 linkrev vs rev with -l
388 436
389 437 $ hg annotate -r tip -nl a
390 438 0:1: a
391 439 1:2: a
392 440 1:3: a
393 441
394 442 Issue589: "undelete" sequence leads to crash
395 443
396 444 annotate was crashing when trying to --follow something
397 445
398 446 like A -> B -> A
399 447
400 448 generate ABA rename configuration
401 449
402 450 $ echo foo > foo
403 451 $ hg add foo
404 452 $ hg ci -m addfoo
405 453 $ hg rename foo bar
406 454 $ hg ci -m renamefoo
407 455 $ hg rename bar foo
408 456 $ hg ci -m renamebar
409 457
410 458 annotate after ABA with follow
411 459
412 460 $ hg annotate --follow foo
413 461 foo: foo
414 462
415 463 missing file
416 464
417 465 $ hg ann nosuchfile
418 466 abort: nosuchfile: no such file in rev e9e6b4fa872f
419 467 [255]
420 468
421 469 annotate file without '\n' on last line
422 470
423 471 $ printf "" > c
424 472 $ hg ci -A -m test -u nobody -d '1 0'
425 473 adding c
426 474 $ hg annotate c
427 475 $ printf "a\nb" > c
428 476 $ hg ci -m test
429 477 $ hg annotate c
430 478 [0-9]+: a (re)
431 479 [0-9]+: b (re)
432 480
433 481 Issue3841: check annotation of the file of which filelog includes
434 482 merging between the revision and its ancestor
435 483
436 484 to reproduce the situation with recent Mercurial, this script uses (1)
437 485 "hg debugsetparents" to merge without ancestor check by "hg merge",
438 486 and (2) the extension to allow filelog merging between the revision
439 487 and its ancestor by overriding "repo._filecommit".
440 488
441 489 $ cat > ../legacyrepo.py <<EOF
442 490 > from mercurial import error, node
443 491 > def reposetup(ui, repo):
444 492 > class legacyrepo(repo.__class__):
445 493 > def _filecommit(self, fctx, manifest1, manifest2,
446 494 > linkrev, tr, changelist, includecopymeta):
447 495 > fname = fctx.path()
448 496 > text = fctx.data()
449 497 > flog = self.file(fname)
450 498 > fparent1 = manifest1.get(fname, node.nullid)
451 499 > fparent2 = manifest2.get(fname, node.nullid)
452 500 > meta = {}
453 501 > copy = fctx.renamed()
454 502 > if copy and copy[0] != fname:
455 503 > raise error.Abort('copying is not supported')
456 504 > if fparent2 != node.nullid:
457 505 > changelist.append(fname)
458 506 > return flog.add(text, meta, tr, linkrev,
459 507 > fparent1, fparent2)
460 508 > raise error.Abort('only merging is supported')
461 509 > repo.__class__ = legacyrepo
462 510 > EOF
463 511
464 512 $ cat > baz <<EOF
465 513 > 1
466 514 > 2
467 515 > 3
468 516 > 4
469 517 > 5
470 518 > EOF
471 519 $ hg add baz
472 520 $ hg commit -m "baz:0"
473 521
474 522 $ cat > baz <<EOF
475 523 > 1 baz:1
476 524 > 2
477 525 > 3
478 526 > 4
479 527 > 5
480 528 > EOF
481 529 $ hg commit -m "baz:1"
482 530
483 531 $ cat > baz <<EOF
484 532 > 1 baz:1
485 533 > 2 baz:2
486 534 > 3
487 535 > 4
488 536 > 5
489 537 > EOF
490 538 $ hg debugsetparents 17 17
491 539 $ hg --config extensions.legacyrepo=../legacyrepo.py commit -m "baz:2"
492 540 $ hg debugindexdot baz
493 541 digraph G {
494 542 -1 -> 0
495 543 0 -> 1
496 544 1 -> 2
497 545 1 -> 2
498 546 }
499 547 $ hg annotate baz
500 548 17: 1 baz:1
501 549 18: 2 baz:2
502 550 16: 3
503 551 16: 4
504 552 16: 5
505 553
506 554 $ cat > baz <<EOF
507 555 > 1 baz:1
508 556 > 2 baz:2
509 557 > 3 baz:3
510 558 > 4
511 559 > 5
512 560 > EOF
513 561 $ hg commit -m "baz:3"
514 562
515 563 $ cat > baz <<EOF
516 564 > 1 baz:1
517 565 > 2 baz:2
518 566 > 3 baz:3
519 567 > 4 baz:4
520 568 > 5
521 569 > EOF
522 570 $ hg debugsetparents 19 18
523 571 $ hg --config extensions.legacyrepo=../legacyrepo.py commit -m "baz:4"
524 572 $ hg debugindexdot baz
525 573 digraph G {
526 574 -1 -> 0
527 575 0 -> 1
528 576 1 -> 2
529 577 1 -> 2
530 578 2 -> 3
531 579 3 -> 4
532 580 2 -> 4
533 581 }
534 582 $ hg annotate baz
535 583 17: 1 baz:1
536 584 18: 2 baz:2
537 585 19: 3 baz:3
538 586 20: 4 baz:4
539 587 16: 5
540 588
541 589 annotate clean file
542 590
543 591 $ hg annotate -ncr "wdir()" foo
544 592 11 472b18db256d : foo
545 593
546 594 annotate modified file
547 595
548 596 $ echo foofoo >> foo
549 597 $ hg annotate -r "wdir()" foo
550 598 11 : foo
551 599 20+: foofoo
552 600
553 601 $ hg annotate -cr "wdir()" foo
554 602 472b18db256d : foo
555 603 b6bedd5477e7+: foofoo
556 604
557 605 $ hg annotate -ncr "wdir()" foo
558 606 11 472b18db256d : foo
559 607 20 b6bedd5477e7+: foofoo
560 608
561 609 $ hg annotate --debug -ncr "wdir()" foo
562 610 11 472b18db256d1e8282064eab4bfdaf48cbfe83cd : foo
563 611 20 b6bedd5477e797f25e568a6402d4697f3f895a72+: foofoo
564 612
565 613 $ hg annotate -udr "wdir()" foo
566 614 test Thu Jan 01 00:00:00 1970 +0000: foo
567 615 test [A-Za-z0-9:+ ]+: foofoo (re)
568 616
569 617 $ hg annotate -ncr "wdir()" -Tjson foo
570 618 [
571 619 {
572 620 "lines": [{"line": "foo\n", "node": "472b18db256d1e8282064eab4bfdaf48cbfe83cd", "rev": 11}, {"line": "foofoo\n", "node": "ffffffffffffffffffffffffffffffffffffffff", "rev": 2147483647}],
573 621 "path": "foo"
574 622 }
575 623 ]
576 624
577 625 annotate added file
578 626
579 627 $ echo bar > bar
580 628 $ hg add bar
581 629 $ hg annotate -ncr "wdir()" bar
582 630 20 b6bedd5477e7+: bar
583 631
584 632 annotate renamed file
585 633
586 634 $ hg rename foo renamefoo2
587 635 $ hg annotate -ncr "wdir()" renamefoo2
588 636 11 472b18db256d : foo
589 637 20 b6bedd5477e7+: foofoo
590 638
591 639 annotate missing file
592 640
593 641 $ rm baz
594 642 $ hg annotate -ncr "wdir()" baz
595 643 abort: $TESTTMP/repo/baz: $ENOENT$ (windows !)
596 644 abort: $ENOENT$: '$TESTTMP/repo/baz' (no-windows !)
597 645 [255]
598 646
599 647 annotate removed file
600 648
601 649 $ hg rm baz
602 650 $ hg annotate -ncr "wdir()" baz
603 651 abort: $TESTTMP/repo/baz: $ENOENT$ (windows !)
604 652 abort: $ENOENT$: '$TESTTMP/repo/baz' (no-windows !)
605 653 [255]
606 654
607 655 Test annotate with whitespace options
608 656
609 657 $ cd ..
610 658 $ hg init repo-ws
611 659 $ cd repo-ws
612 660 $ cat > a <<EOF
613 661 > aa
614 662 >
615 663 > b b
616 664 > EOF
617 665 $ hg ci -Am "adda"
618 666 adding a
619 667 $ sed 's/EOL$//g' > a <<EOF
620 668 > a a
621 669 >
622 670 > EOL
623 671 > b b
624 672 > EOF
625 673 $ hg ci -m "changea"
626 674
627 675 Annotate with no option
628 676
629 677 $ hg annotate a
630 678 1: a a
631 679 0:
632 680 1:
633 681 1: b b
634 682
635 683 Annotate with --ignore-space-change
636 684
637 685 $ hg annotate --ignore-space-change a
638 686 1: a a
639 687 1:
640 688 0:
641 689 0: b b
642 690
643 691 Annotate with --ignore-all-space
644 692
645 693 $ hg annotate --ignore-all-space a
646 694 0: a a
647 695 0:
648 696 1:
649 697 0: b b
650 698
651 699 Annotate with --ignore-blank-lines (similar to no options case)
652 700
653 701 $ hg annotate --ignore-blank-lines a
654 702 1: a a
655 703 0:
656 704 1:
657 705 1: b b
658 706
659 707 $ cd ..
660 708
661 709 Annotate with linkrev pointing to another branch
662 710 ------------------------------------------------
663 711
664 712 create history with a filerev whose linkrev points to another branch
665 713
666 714 $ hg init branchedlinkrev
667 715 $ cd branchedlinkrev
668 716 $ echo A > a
669 717 $ hg commit -Am 'contentA'
670 718 adding a
671 719 $ echo B >> a
672 720 $ hg commit -m 'contentB'
673 721 $ hg up --rev 'desc(contentA)'
674 722 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
675 723 $ echo unrelated > unrelated
676 724 $ hg commit -Am 'unrelated'
677 725 adding unrelated
678 726 created new head
679 727 $ hg graft -r 'desc(contentB)'
680 728 grafting 1:fd27c222e3e6 "contentB"
681 729 $ echo C >> a
682 730 $ hg commit -m 'contentC'
683 731 $ echo W >> a
684 732 $ hg log -G
685 733 @ changeset: 4:072f1e8df249
686 734 | tag: tip
687 735 | user: test
688 736 | date: Thu Jan 01 00:00:00 1970 +0000
689 737 | summary: contentC
690 738 |
691 739 o changeset: 3:ff38df03cc4b
692 740 | user: test
693 741 | date: Thu Jan 01 00:00:00 1970 +0000
694 742 | summary: contentB
695 743 |
696 744 o changeset: 2:62aaf3f6fc06
697 745 | parent: 0:f0932f74827e
698 746 | user: test
699 747 | date: Thu Jan 01 00:00:00 1970 +0000
700 748 | summary: unrelated
701 749 |
702 750 | o changeset: 1:fd27c222e3e6
703 751 |/ user: test
704 752 | date: Thu Jan 01 00:00:00 1970 +0000
705 753 | summary: contentB
706 754 |
707 755 o changeset: 0:f0932f74827e
708 756 user: test
709 757 date: Thu Jan 01 00:00:00 1970 +0000
710 758 summary: contentA
711 759
712 760
713 761 Annotate should list ancestor of starting revision only
714 762
715 763 $ hg annotate a
716 764 0: A
717 765 3: B
718 766 4: C
719 767
720 768 $ hg annotate a -r 'wdir()'
721 769 0 : A
722 770 3 : B
723 771 4 : C
724 772 4+: W
725 773
726 774 Even when the starting revision is the linkrev-shadowed one:
727 775
728 776 $ hg annotate a -r 3
729 777 0: A
730 778 3: B
731 779
732 780 $ cd ..
733 781
734 782 Issue5360: Deleted chunk in p1 of a merge changeset
735 783
736 784 $ hg init repo-5360
737 785 $ cd repo-5360
738 786 $ echo 1 > a
739 787 $ hg commit -A a -m 1
740 788 $ echo 2 >> a
741 789 $ hg commit -m 2
742 790 $ echo a > a
743 791 $ hg commit -m a
744 792 $ hg update '.^' -q
745 793 $ echo 3 >> a
746 794 $ hg commit -m 3 -q
747 795 $ hg merge 2 -q
796 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
797 [1]
798 $ cat a
799 <<<<<<< working copy: 0a068f0261cf - test: 3
800 1
801 2
802 3
803 ||||||| base
804 1
805 2
806 =======
807 a
808 >>>>>>> merge rev: 9409851bc20a - test: a
748 809 $ cat > a << EOF
749 810 > b
750 811 > 1
751 812 > 2
752 813 > 3
753 814 > a
754 815 > EOF
755 816 $ hg resolve --mark -q
817 $ rm a.orig
756 818 $ hg commit -m m
757 819 $ hg annotate a
758 820 4: b
759 821 0: 1
760 822 1: 2
761 823 3: 3
762 824 2: a
763 825
764 826 $ cd ..
@@ -1,182 +1,180 b''
1 1 $ cat >> $HGRCPATH << EOF
2 2 > [extensions]
3 3 > fastannotate=
4 4 > [fastannotate]
5 5 > perfhack=1
6 6 > EOF
7 7
8 $ HGMERGE=true; export HGMERGE
9
10 8 $ hg init repo
11 9 $ cd repo
12 10
13 11 a simple merge case
14 12
15 13 $ echo 1 > a
16 14 $ hg commit -qAm 'append 1'
17 15 $ echo 2 >> a
18 16 $ hg commit -m 'append 2'
19 17 $ echo 3 >> a
20 18 $ hg commit -m 'append 3'
21 19 $ hg up 1 -q
22 20 $ cat > a << EOF
23 21 > 0
24 22 > 1
25 23 > 2
26 24 > EOF
27 25 $ hg commit -qm 'insert 0'
28 26 $ hg merge 2 -q
29 27 $ echo 4 >> a
30 28 $ hg commit -m merge
31 29 $ hg log -G -T '{rev}: {desc}'
32 30 @ 4: merge
33 31 |\
34 32 | o 3: insert 0
35 33 | |
36 34 o | 2: append 3
37 35 |/
38 36 o 1: append 2
39 37 |
40 38 o 0: append 1
41 39
42 40 $ hg fastannotate a
43 41 3: 0
44 42 0: 1
45 43 1: 2
46 44 2: 3
47 45 4: 4
48 46 $ hg fastannotate -r 0 a
49 47 0: 1
50 48 $ hg fastannotate -r 1 a
51 49 0: 1
52 50 1: 2
53 51 $ hg fastannotate -udnclf a
54 52 test 3 d641cb51f61e Thu Jan 01 00:00:00 1970 +0000 a:1: 0
55 53 test 0 4994017376d3 Thu Jan 01 00:00:00 1970 +0000 a:1: 1
56 54 test 1 e940cb6d9a06 Thu Jan 01 00:00:00 1970 +0000 a:2: 2
57 55 test 2 26162a884ba6 Thu Jan 01 00:00:00 1970 +0000 a:3: 3
58 56 test 4 3ad7bcd2815f Thu Jan 01 00:00:00 1970 +0000 a:5: 4
59 57 $ hg fastannotate --linear a
60 58 3: 0
61 59 0: 1
62 60 1: 2
63 61 4: 3
64 62 4: 4
65 63
66 64 incrementally updating
67 65
68 66 $ hg fastannotate -r 0 a --debug
69 67 fastannotate: a: using fast path (resolved fctx: True)
70 68 0: 1
71 69 $ hg fastannotate -r 0 a --debug --rebuild
72 70 fastannotate: a: 1 new changesets in the main branch
73 71 0: 1
74 72 $ hg fastannotate -r 1 a --debug
75 73 fastannotate: a: 1 new changesets in the main branch
76 74 0: 1
77 75 1: 2
78 76 $ hg fastannotate -r 3 a --debug
79 77 fastannotate: a: 1 new changesets in the main branch
80 78 3: 0
81 79 0: 1
82 80 1: 2
83 81 $ hg fastannotate -r 4 a --debug
84 82 fastannotate: a: 1 new changesets in the main branch
85 83 3: 0
86 84 0: 1
87 85 1: 2
88 86 2: 3
89 87 4: 4
90 88 $ hg fastannotate -r 1 a --debug
91 89 fastannotate: a: using fast path (resolved fctx: True)
92 90 0: 1
93 91 1: 2
94 92
95 93 rebuild happens automatically if unable to update
96 94
97 95 $ hg fastannotate -r 2 a --debug
98 96 fastannotate: a: cache broken and deleted
99 97 fastannotate: a: 3 new changesets in the main branch
100 98 0: 1
101 99 1: 2
102 100 2: 3
103 101
104 102 config option "fastannotate.mainbranch"
105 103
106 104 $ hg fastannotate -r 1 --rebuild --config fastannotate.mainbranch=tip a --debug
107 105 fastannotate: a: 4 new changesets in the main branch
108 106 0: 1
109 107 1: 2
110 108 $ hg fastannotate -r 4 a --debug
111 109 fastannotate: a: using fast path (resolved fctx: True)
112 110 3: 0
113 111 0: 1
114 112 1: 2
115 113 2: 3
116 114 4: 4
117 115
118 116 rename
119 117
120 118 $ hg mv a b
121 119 $ cat > b << EOF
122 120 > 0
123 121 > 11
124 122 > 3
125 123 > 44
126 124 > EOF
127 125 $ hg commit -m b -q
128 126 $ hg fastannotate -ncf --long-hash b
129 127 3 d641cb51f61e331c44654104301f8154d7865c89 a: 0
130 128 5 d44dade239915bc82b91e4556b1257323f8e5824 b: 11
131 129 2 26162a884ba60e8c87bf4e0d6bb8efcc6f711a4e a: 3
132 130 5 d44dade239915bc82b91e4556b1257323f8e5824 b: 44
133 131 $ hg fastannotate -r 26162a884ba60e8c87bf4e0d6bb8efcc6f711a4e a
134 132 0: 1
135 133 1: 2
136 134 2: 3
137 135
138 136 fastannotate --deleted
139 137
140 138 $ hg fastannotate --deleted -nf b
141 139 3 a: 0
142 140 5 b: 11
143 141 0 a: -1
144 142 1 a: -2
145 143 2 a: 3
146 144 5 b: 44
147 145 4 a: -4
148 146 $ hg fastannotate --deleted -r 3 -nf a
149 147 3 a: 0
150 148 0 a: 1
151 149 1 a: 2
152 150
153 151 file and directories with ".l", ".m" suffixes
154 152
155 153 $ cd ..
156 154 $ hg init repo2
157 155 $ cd repo2
158 156
159 157 $ mkdir a.l b.m c.lock a.l.hg b.hg
160 158 $ for i in a b c d d.l d.m a.l/a b.m/a c.lock/a a.l.hg/a b.hg/a; do
161 159 > echo $i > $i
162 160 > done
163 161 $ hg add . -q
164 162 $ hg commit -m init
165 163 $ hg fastannotate a.l/a b.m/a c.lock/a a.l.hg/a b.hg/a d.l d.m a b c d
166 164 0: a
167 165 0: a.l.hg/a
168 166 0: a.l/a
169 167 0: b
170 168 0: b.hg/a
171 169 0: b.m/a
172 170 0: c
173 171 0: c.lock/a
174 172 0: d
175 173 0: d.l
176 174 0: d.m
177 175
178 176 empty file
179 177
180 178 $ touch empty
181 179 $ hg commit -A empty -m empty
182 180 $ hg fastannotate empty
@@ -1,211 +1,209 b''
1 1 $ cat >> $HGRCPATH << EOF
2 2 > [ui]
3 3 > ssh = "$PYTHON" "$TESTDIR/dummyssh"
4 4 > [extensions]
5 5 > fastannotate=
6 6 > [fastannotate]
7 7 > mainbranch=@
8 8 > EOF
9 9
10 $ HGMERGE=true; export HGMERGE
11
12 10 setup the server repo
13 11
14 12 $ hg init repo-server
15 13 $ cd repo-server
16 14 $ cat >> .hg/hgrc << EOF
17 15 > [fastannotate]
18 16 > server=1
19 17 > EOF
20 18 $ for i in 1 2 3 4; do
21 19 > echo $i >> a
22 20 > hg commit -A -m $i a
23 21 > done
24 22 $ [ -d .hg/fastannotate ]
25 23 [1]
26 24 $ hg bookmark @
27 25 $ cd ..
28 26
29 27 setup the local repo
30 28
31 29 $ hg clone 'ssh://user@dummy/repo-server' repo-local -q
32 30 $ cd repo-local
33 31 $ cat >> .hg/hgrc << EOF
34 32 > [fastannotate]
35 33 > client=1
36 34 > clientfetchthreshold=0
37 35 > EOF
38 36 $ [ -d .hg/fastannotate ]
39 37 [1]
40 38 $ hg fastannotate a --debug
41 39 running * (glob)
42 40 sending hello command
43 41 sending between command
44 42 remote: * (glob) (?)
45 43 remote: capabilities: * (glob)
46 44 remote: * (glob) (?)
47 45 sending protocaps command
48 46 fastannotate: requesting 1 files
49 47 sending getannotate command
50 48 fastannotate: writing 112 bytes to fastannotate/default/a.l
51 49 fastannotate: writing 94 bytes to fastannotate/default/a.m
52 50 fastannotate: a: using fast path (resolved fctx: True)
53 51 0: 1
54 52 1: 2
55 53 2: 3
56 54 3: 4
57 55
58 56 the cache could be reused and no download is necessary
59 57
60 58 $ hg fastannotate a --debug
61 59 fastannotate: a: using fast path (resolved fctx: True)
62 60 0: 1
63 61 1: 2
64 62 2: 3
65 63 3: 4
66 64
67 65 if the client agrees where the head of the master branch is, no re-download
68 66 happens even if the client has more commits
69 67
70 68 $ echo 5 >> a
71 69 $ hg commit -m 5
72 70 $ hg bookmark -r 3 @ -f
73 71 $ hg fastannotate a --debug
74 72 0: 1
75 73 1: 2
76 74 2: 3
77 75 3: 4
78 76 4: 5
79 77
80 78 if the client has a different "@" (head of the master branch) and "@" is ahead
81 79 of the server, the server can detect things are unchanged and does not return
82 80 full contents (not that there is no "writing ... to fastannotate"), but the
83 81 client can also build things up on its own (causing diverge)
84 82
85 83 $ hg bookmark -r 4 @ -f
86 84 $ hg fastannotate a --debug
87 85 running * (glob)
88 86 sending hello command
89 87 sending between command
90 88 remote: * (glob) (?)
91 89 remote: capabilities: * (glob)
92 90 remote: * (glob) (?)
93 91 sending protocaps command
94 92 fastannotate: requesting 1 files
95 93 sending getannotate command
96 94 fastannotate: a: 1 new changesets in the main branch
97 95 0: 1
98 96 1: 2
99 97 2: 3
100 98 3: 4
101 99 4: 5
102 100
103 101 if the client has a different "@" which is behind the server. no download is
104 102 necessary
105 103
106 104 $ hg fastannotate a --debug --config fastannotate.mainbranch=2
107 105 fastannotate: a: using fast path (resolved fctx: True)
108 106 0: 1
109 107 1: 2
110 108 2: 3
111 109 3: 4
112 110 4: 5
113 111
114 112 define fastannotate on-disk paths
115 113
116 114 $ p1=.hg/fastannotate/default
117 115 $ p2=../repo-server/.hg/fastannotate/default
118 116
119 117 revert bookmark change so the client is behind the server
120 118
121 119 $ hg bookmark -r 2 @ -f
122 120
123 121 in the "fctx" mode with the "annotate" command, the client also downloads the
124 122 cache. but not in the (default) "fastannotate" mode.
125 123
126 124 $ rm $p1/a.l $p1/a.m
127 125 $ hg annotate a --debug | grep 'fastannotate: writing'
128 126 [1]
129 127 $ hg annotate a --config fastannotate.modes=fctx --debug | grep 'fastannotate: writing' | sort
130 128 fastannotate: writing 112 bytes to fastannotate/default/a.l
131 129 fastannotate: writing 94 bytes to fastannotate/default/a.m
132 130
133 131 the fastannotate cache (built server-side, downloaded client-side) in two repos
134 132 have the same content (because the client downloads from the server)
135 133
136 134 $ diff $p1/a.l $p2/a.l
137 135 $ diff $p1/a.m $p2/a.m
138 136
139 137 in the "fctx" mode, the client could also build the cache locally
140 138
141 139 $ hg annotate a --config fastannotate.modes=fctx --debug --config fastannotate.mainbranch=4 | grep fastannotate
142 140 fastannotate: requesting 1 files
143 141 fastannotate: a: 1 new changesets in the main branch
144 142
145 143 the server would rebuild broken cache automatically
146 144
147 145 $ cp $p2/a.m $p2/a.m.bak
148 146 $ echo BROKEN1 > $p1/a.m
149 147 $ echo BROKEN2 > $p2/a.m
150 148 $ hg fastannotate a --debug | grep 'fastannotate: writing' | sort
151 149 fastannotate: writing 112 bytes to fastannotate/default/a.l
152 150 fastannotate: writing 94 bytes to fastannotate/default/a.m
153 151 $ diff $p1/a.m $p2/a.m
154 152 $ diff $p2/a.m $p2/a.m.bak
155 153
156 154 use the "debugbuildannotatecache" command to build annotate cache
157 155
158 156 $ rm -rf $p1 $p2
159 157 $ hg --cwd ../repo-server debugbuildannotatecache a --debug
160 158 fastannotate: a: 4 new changesets in the main branch
161 159 $ hg --cwd ../repo-local debugbuildannotatecache a --debug
162 160 running * (glob)
163 161 sending hello command
164 162 sending between command
165 163 remote: * (glob) (?)
166 164 remote: capabilities: * (glob)
167 165 remote: * (glob) (?)
168 166 sending protocaps command
169 167 fastannotate: requesting 1 files
170 168 sending getannotate command
171 169 fastannotate: writing * (glob)
172 170 fastannotate: writing * (glob)
173 171 $ diff $p1/a.l $p2/a.l
174 172 $ diff $p1/a.m $p2/a.m
175 173
176 174 with the clientfetchthreshold config option, the client can build up the cache
177 175 without downloading from the server
178 176
179 177 $ rm -rf $p1
180 178 $ hg fastannotate a --debug --config fastannotate.clientfetchthreshold=10
181 179 fastannotate: a: 3 new changesets in the main branch
182 180 0: 1
183 181 1: 2
184 182 2: 3
185 183 3: 4
186 184 4: 5
187 185
188 186 if the fastannotate directory is not writable, the fctx mode still works
189 187
190 188 $ rm -rf $p1
191 189 $ touch $p1
192 190 $ hg annotate a --debug --traceback --config fastannotate.modes=fctx
193 191 fastannotate: a: cache broken and deleted
194 192 fastannotate: prefetch failed: * (glob)
195 193 fastannotate: a: cache broken and deleted
196 194 fastannotate: falling back to the vanilla annotate: * (glob)
197 195 0: 1
198 196 1: 2
199 197 2: 3
200 198 3: 4
201 199 4: 5
202 200
203 201 with serverbuildondemand=False, the server will not build anything
204 202
205 203 $ cat >> ../repo-server/.hg/hgrc <<EOF
206 204 > [fastannotate]
207 205 > serverbuildondemand=False
208 206 > EOF
209 207 $ rm -rf $p1 $p2
210 208 $ hg fastannotate a --debug | grep 'fastannotate: writing'
211 209 [1]
@@ -1,263 +1,261 b''
1 1 $ cat >> $HGRCPATH << EOF
2 2 > [extensions]
3 3 > fastannotate=
4 4 > EOF
5 5
6 $ HGMERGE=true; export HGMERGE
7
8 6 $ hg init repo
9 7 $ cd repo
10 8
11 9 a simple merge case
12 10
13 11 $ echo 1 > a
14 12 $ hg commit -qAm 'append 1'
15 13 $ echo 2 >> a
16 14 $ hg commit -m 'append 2'
17 15 $ echo 3 >> a
18 16 $ hg commit -m 'append 3'
19 17 $ hg up 1 -q
20 18 $ cat > a << EOF
21 19 > 0
22 20 > 1
23 21 > 2
24 22 > EOF
25 23 $ hg commit -qm 'insert 0'
26 24 $ hg merge 2 -q
27 25 $ echo 4 >> a
28 26 $ hg commit -m merge
29 27 $ hg log -G -T '{rev}: {desc}'
30 28 @ 4: merge
31 29 |\
32 30 | o 3: insert 0
33 31 | |
34 32 o | 2: append 3
35 33 |/
36 34 o 1: append 2
37 35 |
38 36 o 0: append 1
39 37
40 38 $ hg fastannotate a
41 39 3: 0
42 40 0: 1
43 41 1: 2
44 42 2: 3
45 43 4: 4
46 44 $ hg fastannotate -r 0 a
47 45 0: 1
48 46 $ hg fastannotate -r 1 a
49 47 0: 1
50 48 1: 2
51 49 $ hg fastannotate -udnclf a
52 50 test 3 d641cb51f61e Thu Jan 01 00:00:00 1970 +0000 a:1: 0
53 51 test 0 4994017376d3 Thu Jan 01 00:00:00 1970 +0000 a:1: 1
54 52 test 1 e940cb6d9a06 Thu Jan 01 00:00:00 1970 +0000 a:2: 2
55 53 test 2 26162a884ba6 Thu Jan 01 00:00:00 1970 +0000 a:3: 3
56 54 test 4 3ad7bcd2815f Thu Jan 01 00:00:00 1970 +0000 a:5: 4
57 55 $ hg fastannotate --linear a
58 56 3: 0
59 57 0: 1
60 58 1: 2
61 59 4: 3
62 60 4: 4
63 61
64 62 incrementally updating
65 63
66 64 $ hg fastannotate -r 0 a --debug
67 65 fastannotate: a: using fast path (resolved fctx: True)
68 66 0: 1
69 67 $ hg fastannotate -r 0 a --debug --rebuild
70 68 fastannotate: a: 1 new changesets in the main branch
71 69 0: 1
72 70 $ hg fastannotate -r 1 a --debug
73 71 fastannotate: a: 1 new changesets in the main branch
74 72 0: 1
75 73 1: 2
76 74 $ hg fastannotate -r 3 a --debug
77 75 fastannotate: a: 1 new changesets in the main branch
78 76 3: 0
79 77 0: 1
80 78 1: 2
81 79 $ hg fastannotate -r 4 a --debug
82 80 fastannotate: a: 1 new changesets in the main branch
83 81 3: 0
84 82 0: 1
85 83 1: 2
86 84 2: 3
87 85 4: 4
88 86 $ hg fastannotate -r 1 a --debug
89 87 fastannotate: a: using fast path (resolved fctx: True)
90 88 0: 1
91 89 1: 2
92 90
93 91 rebuild happens automatically if unable to update
94 92
95 93 $ hg fastannotate -r 2 a --debug
96 94 fastannotate: a: cache broken and deleted
97 95 fastannotate: a: 3 new changesets in the main branch
98 96 0: 1
99 97 1: 2
100 98 2: 3
101 99
102 100 config option "fastannotate.mainbranch"
103 101
104 102 $ hg fastannotate -r 1 --rebuild --config fastannotate.mainbranch=tip a --debug
105 103 fastannotate: a: 4 new changesets in the main branch
106 104 0: 1
107 105 1: 2
108 106 $ hg fastannotate -r 4 a --debug
109 107 fastannotate: a: using fast path (resolved fctx: True)
110 108 3: 0
111 109 0: 1
112 110 1: 2
113 111 2: 3
114 112 4: 4
115 113
116 114 config option "fastannotate.modes"
117 115
118 116 $ hg annotate -r 1 --debug a
119 117 0: 1
120 118 1: 2
121 119 $ hg annotate --config fastannotate.modes=fctx -r 1 --debug a
122 120 fastannotate: a: using fast path (resolved fctx: False)
123 121 0: 1
124 122 1: 2
125 123 $ hg fastannotate --config fastannotate.modes=fctx -h -q
126 124 hg: unknown command 'fastannotate'
127 125 (did you mean *) (glob)
128 126 [255]
129 127
130 128 rename
131 129
132 130 $ hg mv a b
133 131 $ cat > b << EOF
134 132 > 0
135 133 > 11
136 134 > 3
137 135 > 44
138 136 > EOF
139 137 $ hg commit -m b -q
140 138 $ hg fastannotate -ncf --long-hash b
141 139 3 d641cb51f61e331c44654104301f8154d7865c89 a: 0
142 140 5 d44dade239915bc82b91e4556b1257323f8e5824 b: 11
143 141 2 26162a884ba60e8c87bf4e0d6bb8efcc6f711a4e a: 3
144 142 5 d44dade239915bc82b91e4556b1257323f8e5824 b: 44
145 143 $ hg fastannotate -r 26162a884ba60e8c87bf4e0d6bb8efcc6f711a4e a
146 144 0: 1
147 145 1: 2
148 146 2: 3
149 147
150 148 fastannotate --deleted
151 149
152 150 $ hg fastannotate --deleted -nf b
153 151 3 a: 0
154 152 5 b: 11
155 153 0 a: -1
156 154 1 a: -2
157 155 2 a: 3
158 156 5 b: 44
159 157 4 a: -4
160 158 $ hg fastannotate --deleted -r 3 -nf a
161 159 3 a: 0
162 160 0 a: 1
163 161 1 a: 2
164 162
165 163 file and directories with ".l", ".m" suffixes
166 164
167 165 $ cd ..
168 166 $ hg init repo2
169 167 $ cd repo2
170 168
171 169 $ mkdir a.l b.m c.lock a.l.hg b.hg
172 170 $ for i in a b c d d.l d.m a.l/a b.m/a c.lock/a a.l.hg/a b.hg/a; do
173 171 > echo $i > $i
174 172 > done
175 173 $ hg add . -q
176 174 $ hg commit -m init
177 175 $ hg fastannotate a.l/a b.m/a c.lock/a a.l.hg/a b.hg/a d.l d.m a b c d
178 176 0: a
179 177 0: a.l.hg/a
180 178 0: a.l/a
181 179 0: b
182 180 0: b.hg/a
183 181 0: b.m/a
184 182 0: c
185 183 0: c.lock/a
186 184 0: d
187 185 0: d.l
188 186 0: d.m
189 187
190 188 empty file
191 189
192 190 $ touch empty
193 191 $ hg commit -A empty -m empty
194 192 $ hg fastannotate empty
195 193
196 194 json format
197 195
198 196 $ hg fastannotate -Tjson -cludn b a empty
199 197 [
200 198 {
201 199 "date": [0.0, 0],
202 200 "line": "a\n",
203 201 "line_number": 1,
204 202 "node": "1fd620b16252aecb54c6aa530dff5ed6e6ec3d21",
205 203 "rev": 0,
206 204 "user": "test"
207 205 },
208 206 {
209 207 "date": [0.0, 0],
210 208 "line": "b\n",
211 209 "line_number": 1,
212 210 "node": "1fd620b16252aecb54c6aa530dff5ed6e6ec3d21",
213 211 "rev": 0,
214 212 "user": "test"
215 213 }
216 214 ]
217 215
218 216 $ hg fastannotate -Tjson -cludn empty
219 217 [
220 218 ]
221 219 $ hg fastannotate -Tjson --no-content -n a
222 220 [
223 221 {
224 222 "rev": 0
225 223 }
226 224 ]
227 225
228 226 working copy
229 227
230 228 $ echo a >> a
231 229 $ hg fastannotate -r 'wdir()' a
232 230 abort: cannot update linelog to wdir()
233 231 (set fastannotate.mainbranch)
234 232 [255]
235 233 $ cat >> $HGRCPATH << EOF
236 234 > [fastannotate]
237 235 > mainbranch = .
238 236 > EOF
239 237 $ hg fastannotate -r 'wdir()' a
240 238 0 : a
241 239 1+: a
242 240 $ hg fastannotate -cludn -r 'wdir()' a
243 241 test 0 1fd620b16252 Thu Jan 01 00:00:00 1970 +0000:1: a
244 242 test 1 720582f5bdb6+ *:2: a (glob)
245 243 $ hg fastannotate -cludn -r 'wdir()' -Tjson a
246 244 [
247 245 {
248 246 "date": [0.0, 0],
249 247 "line": "a\n",
250 248 "line_number": 1,
251 249 "node": "1fd620b16252aecb54c6aa530dff5ed6e6ec3d21",
252 250 "rev": 0,
253 251 "user": "test"
254 252 },
255 253 {
256 254 "date": [*, 0], (glob)
257 255 "line": "a\n",
258 256 "line_number": 2,
259 257 "node": null,
260 258 "rev": null,
261 259 "user": "test"
262 260 }
263 261 ]
General Comments 0
You need to be logged in to leave comments. Login now