23 p2data = b'a\nc\nd\n' |
24 p2data = b'a\nc\nd\n' |
24 childdata = b'a\nb2\nc\nc2\nd\n' |
25 childdata = b'a\nb2\nc\nc2\nd\n' |
25 diffopts = mdiff.diffopts() |
26 diffopts = mdiff.diffopts() |
26 |
27 |
27 def decorate(text, rev): |
28 def decorate(text, rev): |
28 return ([(rev, i) for i in xrange(1, text.count(b'\n') + 1)], text) |
29 return ([annotateline(fctx=rev, lineno=i) |
|
30 for i in xrange(1, text.count(b'\n') + 1)], |
|
31 text) |
29 |
32 |
30 # Basic usage |
33 # Basic usage |
31 |
34 |
32 oldann = decorate(olddata, oldfctx) |
35 oldann = decorate(olddata, oldfctx) |
33 p1ann = decorate(p1data, p1fctx) |
36 p1ann = decorate(p1data, p1fctx) |
34 p1ann = _annotatepair([oldann], p1fctx, p1ann, False, diffopts) |
37 p1ann = _annotatepair([oldann], p1fctx, p1ann, False, diffopts) |
35 self.assertEqual(p1ann[0], [('old', 1), ('old', 2), ('p1', 3)]) |
38 self.assertEqual(p1ann[0], [ |
|
39 annotateline('old', 1), |
|
40 annotateline('old', 2), |
|
41 annotateline('p1', 3), |
|
42 ]) |
36 |
43 |
37 p2ann = decorate(p2data, p2fctx) |
44 p2ann = decorate(p2data, p2fctx) |
38 p2ann = _annotatepair([oldann], p2fctx, p2ann, False, diffopts) |
45 p2ann = _annotatepair([oldann], p2fctx, p2ann, False, diffopts) |
39 self.assertEqual(p2ann[0], [('old', 1), ('p2', 2), ('p2', 3)]) |
46 self.assertEqual(p2ann[0], [ |
|
47 annotateline('old', 1), |
|
48 annotateline('p2', 2), |
|
49 annotateline('p2', 3), |
|
50 ]) |
40 |
51 |
41 # Test with multiple parents (note the difference caused by ordering) |
52 # Test with multiple parents (note the difference caused by ordering) |
42 |
53 |
43 childann = decorate(childdata, childfctx) |
54 childann = decorate(childdata, childfctx) |
44 childann = _annotatepair([p1ann, p2ann], childfctx, childann, False, |
55 childann = _annotatepair([p1ann, p2ann], childfctx, childann, False, |
45 diffopts) |
56 diffopts) |
46 self.assertEqual(childann[0], |
57 self.assertEqual(childann[0], [ |
47 [('old', 1), ('c', 2), ('p2', 2), ('c', 4), ('p2', 3)] |
58 annotateline('old', 1), |
48 ) |
59 annotateline('c', 2), |
|
60 annotateline('p2', 2), |
|
61 annotateline('c', 4), |
|
62 annotateline('p2', 3), |
|
63 ]) |
49 |
64 |
50 childann = decorate(childdata, childfctx) |
65 childann = decorate(childdata, childfctx) |
51 childann = _annotatepair([p2ann, p1ann], childfctx, childann, False, |
66 childann = _annotatepair([p2ann, p1ann], childfctx, childann, False, |
52 diffopts) |
67 diffopts) |
53 self.assertEqual(childann[0], |
68 self.assertEqual(childann[0], [ |
54 [('old', 1), ('c', 2), ('p1', 3), ('c', 4), ('p2', 3)] |
69 annotateline('old', 1), |
55 ) |
70 annotateline('c', 2), |
|
71 annotateline('p1', 3), |
|
72 annotateline('c', 4), |
|
73 annotateline('p2', 3), |
|
74 ]) |
56 |
75 |
57 # Test with skipchild (note the difference caused by ordering) |
76 # Test with skipchild (note the difference caused by ordering) |
58 |
77 |
59 childann = decorate(childdata, childfctx) |
78 childann = decorate(childdata, childfctx) |
60 childann = _annotatepair([p1ann, p2ann], childfctx, childann, True, |
79 childann = _annotatepair([p1ann, p2ann], childfctx, childann, True, |
61 diffopts) |
80 diffopts) |
62 self.assertEqual(childann[0], |
81 self.assertEqual(childann[0], [ |
63 [('old', 1), ('old', 2), ('p2', 2), ('p2', 2), ('p2', 3)] |
82 annotateline('old', 1), |
64 ) |
83 annotateline('old', 2), |
|
84 annotateline('p2', 2), |
|
85 annotateline('p2', 2), |
|
86 annotateline('p2', 3), |
|
87 ]) |
65 |
88 |
66 childann = decorate(childdata, childfctx) |
89 childann = decorate(childdata, childfctx) |
67 childann = _annotatepair([p2ann, p1ann], childfctx, childann, True, |
90 childann = _annotatepair([p2ann, p1ann], childfctx, childann, True, |
68 diffopts) |
91 diffopts) |
69 self.assertEqual(childann[0], |
92 self.assertEqual(childann[0], [ |
70 [('old', 1), ('old', 2), ('p1', 3), ('p1', 3), ('p2', 3)] |
93 annotateline('old', 1), |
71 ) |
94 annotateline('old', 2), |
|
95 annotateline('p1', 3), |
|
96 annotateline('p1', 3), |
|
97 annotateline('p2', 3), |
|
98 ]) |
72 |
99 |
73 if __name__ == '__main__': |
100 if __name__ == '__main__': |
74 import silenttestrunner |
101 import silenttestrunner |
75 silenttestrunner.main(__name__) |
102 silenttestrunner.main(__name__) |