Show More
@@ -377,15 +377,18 def annotate(ui, repo, *pats, **opts): | |||
|
377 | 377 | |
|
378 | 378 | for abs in ctx.walk(m): |
|
379 | 379 | fctx = ctx[abs] |
|
380 | rootfm.startitem() | |
|
381 | rootfm.data(abspath=abs, path=m.rel(abs)) | |
|
380 | 382 | if not opts.get('text') and fctx.isbinary(): |
|
381 | 383 | rootfm.plain(_("%s: binary file\n") |
|
382 | 384 | % ((pats and m.rel(abs)) or abs)) |
|
383 | 385 | continue |
|
384 | 386 | |
|
385 | fm = rootfm | |
|
387 | fm = rootfm.nested('lines') | |
|
386 | 388 | lines = fctx.annotate(follow=follow, linenumber=linenumber, |
|
387 | 389 | skiprevs=skiprevs, diffopts=diffopts) |
|
388 | 390 | if not lines: |
|
391 | fm.end() | |
|
389 | 392 | continue |
|
390 | 393 | formats = [] |
|
391 | 394 | pieces = [] |
@@ -407,6 +410,7 def annotate(ui, repo, *pats, **opts): | |||
|
407 | 410 | |
|
408 | 411 | if not lines[-1][1].endswith('\n'): |
|
409 | 412 | fm.plain('\n') |
|
413 | fm.end() | |
|
410 | 414 | |
|
411 | 415 | rootfm.end() |
|
412 | 416 |
@@ -56,21 +56,18 annotate (JSON) | |||
|
56 | 56 | $ hg annotate -Tjson a |
|
57 | 57 | [ |
|
58 | 58 | { |
|
59 |
" |
|
|
60 | "rev": 0 | |
|
59 | "abspath": "a", | |
|
60 | "lines": [{"line": "a\n", "rev": 0}], | |
|
61 | "path": "a" | |
|
61 | 62 | } |
|
62 | 63 | ] |
|
63 | 64 | |
|
64 | 65 | $ hg annotate -Tjson -cdfnul a |
|
65 | 66 | [ |
|
66 | 67 | { |
|
67 | "date": [1.0, 0], | |
|
68 | "file": "a", | |
|
69 |
" |
|
|
70 | "line_number": 1, | |
|
71 | "node": "8435f90966e442695d2ded29fdade2bac5ad8065", | |
|
72 | "rev": 0, | |
|
73 | "user": "nobody" | |
|
68 | "abspath": "a", | |
|
69 | "lines": [{"date": [1.0, 0], "file": "a", "line": "a\n", "line_number": 1, "node": "8435f90966e442695d2ded29fdade2bac5ad8065", "rev": 0, "user": "nobody"}], | |
|
70 | "path": "a" | |
|
74 | 71 | } |
|
75 | 72 | ] |
|
76 | 73 | |
@@ -88,6 +85,37 annotate (JSON) | |||
|
88 | 85 | > EOF |
|
89 | 86 | $ hg ci -mb2 -d '2 0' |
|
90 | 87 | |
|
88 | annotate multiple files (JSON) | |
|
89 | ||
|
90 | $ hg annotate -Tjson a b | |
|
91 | [ | |
|
92 | { | |
|
93 | "abspath": "a", | |
|
94 | "lines": [{"line": "a\n", "rev": 0}, {"line": "a\n", "rev": 1}, {"line": "a\n", "rev": 1}], | |
|
95 | "path": "a" | |
|
96 | }, | |
|
97 | { | |
|
98 | "abspath": "b", | |
|
99 | "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}], | |
|
100 | "path": "b" | |
|
101 | } | |
|
102 | ] | |
|
103 | ||
|
104 | annotate multiple files (template) | |
|
105 | ||
|
106 | $ hg annotate -T'== {abspath} ==\n{lines % "{rev}: {line}"}' a b | |
|
107 | == a == | |
|
108 | 0: a | |
|
109 | 1: a | |
|
110 | 1: a | |
|
111 | == b == | |
|
112 | 0: a | |
|
113 | 1: a | |
|
114 | 1: a | |
|
115 | 3: b4 | |
|
116 | 3: b5 | |
|
117 | 3: b6 | |
|
118 | ||
|
91 | 119 | annotate -n b |
|
92 | 120 | |
|
93 | 121 | $ hg annotate -n b |
@@ -500,14 +528,9 annotate modified file | |||
|
500 | 528 | $ hg annotate -ncr "wdir()" -Tjson foo |
|
501 | 529 | [ |
|
502 | 530 | { |
|
503 |
" |
|
|
504 | "node": "472b18db256d1e8282064eab4bfdaf48cbfe83cd", | |
|
505 | "rev": 11 | |
|
506 | }, | |
|
507 | { | |
|
508 | "line": "foofoo\n", | |
|
509 | "node": null, | |
|
510 | "rev": null | |
|
531 | "abspath": "foo", | |
|
532 | "lines": [{"line": "foo\n", "node": "472b18db256d1e8282064eab4bfdaf48cbfe83cd", "rev": 11}, {"line": "foofoo\n", "node": null, "rev": null}], | |
|
533 | "path": "foo" | |
|
511 | 534 | } |
|
512 | 535 | ] |
|
513 | 536 | |
@@ -742,6 +765,28 check error cases | |||
|
742 | 765 | hg: parse error: descend argument must be a boolean |
|
743 | 766 | [255] |
|
744 | 767 | |
|
768 | Test empty annotate output | |
|
769 | ||
|
770 | $ printf '\0' > binary | |
|
771 | $ touch empty | |
|
772 | $ hg ci -qAm 'add binary and empty files' | |
|
773 | ||
|
774 | $ hg annotate binary empty | |
|
775 | binary: binary file | |
|
776 | ||
|
777 | $ hg annotate -Tjson binary empty | |
|
778 | [ | |
|
779 | { | |
|
780 | "abspath": "binary", | |
|
781 | "path": "binary" | |
|
782 | }, | |
|
783 | { | |
|
784 | "abspath": "empty", | |
|
785 | "lines": [], | |
|
786 | "path": "empty" | |
|
787 | } | |
|
788 | ] | |
|
789 | ||
|
745 | 790 | Test annotate with whitespace options |
|
746 | 791 | |
|
747 | 792 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now