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