Show More
@@ -70,19 +70,31 b' def annotate(ui, repo, *pats, **opts):' | |||||
70 | detects as binary. With -a, annotate will generate an annotation |
|
70 | detects as binary. With -a, annotate will generate an annotation | |
71 | anyway, probably with undesirable results. |
|
71 | anyway, probably with undesirable results. | |
72 | """ |
|
72 | """ | |
73 | getdate = util.cachefunc(lambda x: util.datestr(x.date())) |
|
73 | getdate = util.cachefunc(lambda x: util.datestr(x[0].date())) | |
74 |
|
74 | |||
75 | if not pats: |
|
75 | if not pats: | |
76 | raise util.Abort(_('at least one file name or pattern required')) |
|
76 | raise util.Abort(_('at least one file name or pattern required')) | |
77 |
|
77 | |||
78 |
opmap = [ |
|
78 | opmap = [('user', lambda x: ui.shortuser(x[0].user())), | |
79 |
|
|
79 | ('number', lambda x: str(x[0].rev())), | |
80 |
|
|
80 | ('changeset', lambda x: short(x[0].node())), | |
81 |
|
|
81 | ('date', getdate), | |
|
82 | ('follow', lambda x: x[0].path()), | |||
|
83 | ] | |||
|
84 | ||||
82 | if (not opts['user'] and not opts['changeset'] and not opts['date'] |
|
85 | if (not opts['user'] and not opts['changeset'] and not opts['date'] | |
83 | and not opts['follow']): |
|
86 | and not opts['follow']): | |
84 | opts['number'] = 1 |
|
87 | opts['number'] = 1 | |
85 |
|
88 | |||
|
89 | linenumber = opts.get('line_number') is not None | |||
|
90 | if (linenumber and (not opts['changeset']) and (not opts['number'])): | |||
|
91 | raise util.Abort(_('at least one of -n/-c is required for -l')) | |||
|
92 | ||||
|
93 | funcmap = [func for op, func in opmap if opts.get(op)] | |||
|
94 | if linenumber: | |||
|
95 | lastfunc = funcmap[-1] | |||
|
96 | funcmap[-1] = lambda x: "%s:%s" % (lastfunc(x), x[1]) | |||
|
97 | ||||
86 | ctx = repo.changectx(opts['rev']) |
|
98 | ctx = repo.changectx(opts['rev']) | |
87 |
|
99 | |||
88 | for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, |
|
100 | for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, | |
@@ -92,15 +104,15 b' def annotate(ui, repo, *pats, **opts):' | |||||
92 | ui.write(_("%s: binary file\n") % ((pats and rel) or abs)) |
|
104 | ui.write(_("%s: binary file\n") % ((pats and rel) or abs)) | |
93 | continue |
|
105 | continue | |
94 |
|
106 | |||
95 |
lines = fctx.annotate(follow=opts.get('follow') |
|
107 | lines = fctx.annotate(follow=opts.get('follow'), | |
|
108 | linenumber=linenumber) | |||
96 | pieces = [] |
|
109 | pieces = [] | |
97 |
|
110 | |||
98 |
for |
|
111 | for f in funcmap: | |
99 | if opts[o]: |
|
112 | l = [f(n) for n, dummy in lines] | |
100 | l = [f(n) for n, dummy in lines] |
|
113 | if l: | |
101 |
|
|
114 | m = max(map(len, l)) | |
102 | m = max(map(len, l)) |
|
115 | pieces.append(["%*s" % (m, x) for x in l]) | |
103 | pieces.append(["%*s" % (m, x) for x in l]) |
|
|||
104 |
|
116 | |||
105 | if pieces: |
|
117 | if pieces: | |
106 | for p, l in zip(zip(*pieces), lines): |
|
118 | for p, l in zip(zip(*pieces), lines): | |
@@ -2757,8 +2769,10 b' table = {' | |||||
2757 | ('d', 'date', None, _('list the date')), |
|
2769 | ('d', 'date', None, _('list the date')), | |
2758 | ('n', 'number', None, _('list the revision number (default)')), |
|
2770 | ('n', 'number', None, _('list the revision number (default)')), | |
2759 | ('c', 'changeset', None, _('list the changeset')), |
|
2771 | ('c', 'changeset', None, _('list the changeset')), | |
|
2772 | ('l', 'line-number', None, | |||
|
2773 | _('show line number at the first appearance')) | |||
2760 | ] + walkopts, |
|
2774 | ] + walkopts, | |
2761 | _('hg annotate [-r REV] [-f] [-a] [-u] [-d] [-n] [-c] FILE...')), |
|
2775 | _('hg annotate [-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...')), | |
2762 | "archive": |
|
2776 | "archive": | |
2763 | (archive, |
|
2777 | (archive, | |
2764 | [('', 'no-decode', None, _('do not pass files through decoders')), |
|
2778 | [('', 'no-decode', None, _('do not pass files through decoders')), |
@@ -12,18 +12,27 b" hg ci -A -m test -u nobody -d '1 0'" | |||||
12 | echo % annotate -c |
|
12 | echo % annotate -c | |
13 | hg annotate -c a |
|
13 | hg annotate -c a | |
14 |
|
14 | |||
|
15 | echo % annotate -cl | |||
|
16 | hg annotate -cl a | |||
|
17 | ||||
15 | echo % annotate -d |
|
18 | echo % annotate -d | |
16 | hg annotate -d a |
|
19 | hg annotate -d a | |
17 |
|
20 | |||
18 | echo % annotate -n |
|
21 | echo % annotate -n | |
19 | hg annotate -n a |
|
22 | hg annotate -n a | |
20 |
|
23 | |||
|
24 | echo % annotate -nl | |||
|
25 | hg annotate -nl a | |||
|
26 | ||||
21 | echo % annotate -u |
|
27 | echo % annotate -u | |
22 | hg annotate -u a |
|
28 | hg annotate -u a | |
23 |
|
29 | |||
24 | echo % annotate -cdnu |
|
30 | echo % annotate -cdnu | |
25 | hg annotate -cdnu a |
|
31 | hg annotate -cdnu a | |
26 |
|
32 | |||
|
33 | echo % annotate -cdnul | |||
|
34 | hg annotate -cdnul a | |||
|
35 | ||||
27 | cat <<EOF >>a |
|
36 | cat <<EOF >>a | |
28 | a |
|
37 | a | |
29 | a |
|
38 | a | |
@@ -32,28 +41,34 b" hg ci -ma1 -d '1 0'" | |||||
32 | hg cp a b |
|
41 | hg cp a b | |
33 | hg ci -mb -d '1 0' |
|
42 | hg ci -mb -d '1 0' | |
34 | cat <<EOF >> b |
|
43 | cat <<EOF >> b | |
35 | b |
|
44 | b4 | |
36 | b |
|
45 | b5 | |
37 | b |
|
46 | b6 | |
38 | EOF |
|
47 | EOF | |
39 | hg ci -mb2 -d '2 0' |
|
48 | hg ci -mb2 -d '2 0' | |
40 |
|
49 | |||
41 | echo % annotate b |
|
50 | echo % annotate -n b | |
42 | hg annotate b |
|
51 | hg annotate -n b | |
|
52 | echo % annotate -nl b | |||
|
53 | hg annotate -nl b | |||
43 | echo % annotate -nf b |
|
54 | echo % annotate -nf b | |
44 | hg annotate -nf b |
|
55 | hg annotate -nf b | |
|
56 | echo % annotate -nlf b | |||
|
57 | hg annotate -nlf b | |||
45 |
|
58 | |||
46 | hg up -C 2 |
|
59 | hg up -C 2 | |
47 | cat <<EOF >> b |
|
60 | cat <<EOF >> b | |
48 | b |
|
61 | b4 | |
49 | c |
|
62 | c | |
50 | b |
|
63 | b5 | |
51 | EOF |
|
64 | EOF | |
52 | hg ci -mb2.1 -d '2 0' |
|
65 | hg ci -mb2.1 -d '2 0' | |
53 | hg merge |
|
66 | hg merge | |
54 | hg ci -mmergeb -d '3 0' |
|
67 | hg ci -mmergeb -d '3 0' | |
55 | echo % annotate after merge |
|
68 | echo % annotate after merge | |
56 | hg annotate -nf b |
|
69 | hg annotate -nf b | |
|
70 | echo % annotate after merge with -l | |||
|
71 | hg annotate -nlf b | |||
57 |
|
72 | |||
58 | hg up -C 1 |
|
73 | hg up -C 1 | |
59 | hg cp a b |
|
74 | hg cp a b | |
@@ -65,17 +80,21 b' EOF' | |||||
65 | hg ci -mc -d '3 0' |
|
80 | hg ci -mc -d '3 0' | |
66 | hg merge |
|
81 | hg merge | |
67 | cat <<EOF >> b |
|
82 | cat <<EOF >> b | |
68 | b |
|
83 | b4 | |
69 | c |
|
84 | c | |
70 | b |
|
85 | b5 | |
71 | EOF |
|
86 | EOF | |
72 | echo d >> b |
|
87 | echo d >> b | |
73 | hg ci -mmerge2 -d '4 0' |
|
88 | hg ci -mmerge2 -d '4 0' | |
74 | echo % annotate after rename merge |
|
89 | echo % annotate after rename merge | |
75 | hg annotate -nf b |
|
90 | hg annotate -nf b | |
|
91 | echo % annotate after rename merge with -l | |||
|
92 | hg annotate -nlf b | |||
76 |
|
93 | |||
77 | echo % linkrev vs rev |
|
94 | echo % linkrev vs rev | |
78 | hg annotate -r tip a |
|
95 | hg annotate -r tip -n a | |
|
96 | echo % linkrev vs rev with -l | |||
|
97 | hg annotate -r tip -nl a | |||
79 |
|
98 | |||
80 | # test issue 589 |
|
99 | # test issue 589 | |
81 | # annotate was crashing when trying to --follow something |
|
100 | # annotate was crashing when trying to --follow something |
@@ -3,28 +3,48 b'' | |||||
3 | adding a |
|
3 | adding a | |
4 | % annotate -c |
|
4 | % annotate -c | |
5 | 8435f90966e4: a |
|
5 | 8435f90966e4: a | |
|
6 | % annotate -cl | |||
|
7 | 8435f90966e4:1: a | |||
6 | % annotate -d |
|
8 | % annotate -d | |
7 | Thu Jan 01 00:00:01 1970 +0000: a |
|
9 | Thu Jan 01 00:00:01 1970 +0000: a | |
8 | % annotate -n |
|
10 | % annotate -n | |
9 | 0: a |
|
11 | 0: a | |
|
12 | % annotate -nl | |||
|
13 | 0:1: a | |||
10 | % annotate -u |
|
14 | % annotate -u | |
11 | nobody: a |
|
15 | nobody: a | |
12 | % annotate -cdnu |
|
16 | % annotate -cdnu | |
13 | nobody 0 8435f90966e4 Thu Jan 01 00:00:01 1970 +0000: a |
|
17 | nobody 0 8435f90966e4 Thu Jan 01 00:00:01 1970 +0000: a | |
14 |
% annotate |
|
18 | % annotate -cdnul | |
|
19 | nobody 0 8435f90966e4 Thu Jan 01 00:00:01 1970 +0000:1: a | |||
|
20 | % annotate -n b | |||
15 | 2: a |
|
21 | 2: a | |
16 | 2: a |
|
22 | 2: a | |
17 | 2: a |
|
23 | 2: a | |
18 | 3: b |
|
24 | 3: b4 | |
19 | 3: b |
|
25 | 3: b5 | |
20 | 3: b |
|
26 | 3: b6 | |
|
27 | % annotate -nl b | |||
|
28 | 2:1: a | |||
|
29 | 2:2: a | |||
|
30 | 2:3: a | |||
|
31 | 3:4: b4 | |||
|
32 | 3:5: b5 | |||
|
33 | 3:6: b6 | |||
21 | % annotate -nf b |
|
34 | % annotate -nf b | |
22 | 0 a: a |
|
35 | 0 a: a | |
23 | 1 a: a |
|
36 | 1 a: a | |
24 | 1 a: a |
|
37 | 1 a: a | |
25 | 3 b: b |
|
38 | 3 b: b4 | |
26 | 3 b: b |
|
39 | 3 b: b5 | |
27 | 3 b: b |
|
40 | 3 b: b6 | |
|
41 | % annotate -nlf b | |||
|
42 | 0 a:1: a | |||
|
43 | 1 a:2: a | |||
|
44 | 1 a:3: a | |||
|
45 | 3 b:4: b4 | |||
|
46 | 3 b:5: b5 | |||
|
47 | 3 b:6: b6 | |||
28 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
48 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
29 | merging b |
|
49 | merging b | |
30 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
50 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
@@ -33,9 +53,16 b' 0 files updated, 1 files merged, 0 files' | |||||
33 | 0 a: a |
|
53 | 0 a: a | |
34 | 1 a: a |
|
54 | 1 a: a | |
35 | 1 a: a |
|
55 | 1 a: a | |
36 | 3 b: b |
|
56 | 3 b: b4 | |
37 | 4 b: c |
|
57 | 4 b: c | |
38 | 3 b: b |
|
58 | 3 b: b5 | |
|
59 | % annotate after merge with -l | |||
|
60 | 0 a:1: a | |||
|
61 | 1 a:2: a | |||
|
62 | 1 a:3: a | |||
|
63 | 3 b:4: b4 | |||
|
64 | 4 b:5: c | |||
|
65 | 3 b:5: b5 | |||
39 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
66 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
40 | merging b |
|
67 | merging b | |
41 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
68 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
@@ -44,14 +71,26 b' 0 files updated, 1 files merged, 0 files' | |||||
44 | 0 a: a |
|
71 | 0 a: a | |
45 | 6 b: z |
|
72 | 6 b: z | |
46 | 1 a: a |
|
73 | 1 a: a | |
47 | 3 b: b |
|
74 | 3 b: b4 | |
48 | 4 b: c |
|
75 | 4 b: c | |
49 | 3 b: b |
|
76 | 3 b: b5 | |
50 | 7 b: d |
|
77 | 7 b: d | |
|
78 | % annotate after rename merge with -l | |||
|
79 | 0 a:1: a | |||
|
80 | 6 b:2: z | |||
|
81 | 1 a:3: a | |||
|
82 | 3 b:4: b4 | |||
|
83 | 4 b:5: c | |||
|
84 | 3 b:5: b5 | |||
|
85 | 7 b:7: d | |||
51 | % linkrev vs rev |
|
86 | % linkrev vs rev | |
52 | 0: a |
|
87 | 0: a | |
53 | 1: a |
|
88 | 1: a | |
54 | 1: a |
|
89 | 1: a | |
|
90 | % linkrev vs rev with -l | |||
|
91 | 0:1: a | |||
|
92 | 1:2: a | |||
|
93 | 1:3: a | |||
55 | % generate ABA rename configuration |
|
94 | % generate ABA rename configuration | |
56 | % annotate after ABA with follow |
|
95 | % annotate after ABA with follow | |
57 | foo: foo |
|
96 | foo: foo |
General Comments 0
You need to be logged in to leave comments.
Login now