Mercurial > hg
annotate tests/test-annotate.py @ 35646:a177c6aa055a
log: rewrite --follow-first -rREV like --follow for consistency (BC)
This helps fixing the "--follow -rREV PATH" issue.
.. bc::
``log --follow-first -rREV``, which is deprecated, now follows the first
parent of merge revisions from the specified ``REV`` just like
``log --follow -rREV``.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 10 Dec 2017 18:25:33 +0900 |
parents | 2f5a135b2b04 |
children | cf887d601014 |
rev | line source |
---|---|
34430
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
1 from __future__ import absolute_import |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
2 from __future__ import print_function |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
3 |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
4 import unittest |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
5 |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
6 from mercurial import ( |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
7 mdiff, |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
8 ) |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
9 from mercurial.context import ( |
34432
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
10 annotateline, |
34430
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
11 _annotatepair, |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
12 ) |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
13 |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
14 class AnnotateTests(unittest.TestCase): |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
15 """Unit tests for annotate code.""" |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
16 |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
17 def testannotatepair(self): |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
18 self.maxDiff = None # camelcase-required |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
19 |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
20 oldfctx = b'old' |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
21 p1fctx, p2fctx, childfctx = b'p1', b'p2', b'c' |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
22 olddata = b'a\nb\n' |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
23 p1data = b'a\nb\nc\n' |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
24 p2data = b'a\nc\nd\n' |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
25 childdata = b'a\nb2\nc\nc2\nd\n' |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
26 diffopts = mdiff.diffopts() |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
27 |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
28 def decorate(text, rev): |
34432
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
29 return ([annotateline(fctx=rev, lineno=i) |
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
30 for i in xrange(1, text.count(b'\n') + 1)], |
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
31 text) |
34430
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
32 |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
33 # Basic usage |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
34 |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
35 oldann = decorate(olddata, oldfctx) |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
36 p1ann = decorate(p1data, p1fctx) |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
37 p1ann = _annotatepair([oldann], p1fctx, p1ann, False, diffopts) |
34432
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
38 self.assertEqual(p1ann[0], [ |
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
39 annotateline('old', 1), |
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
40 annotateline('old', 2), |
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
41 annotateline('p1', 3), |
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
42 ]) |
34430
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
43 |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
44 p2ann = decorate(p2data, p2fctx) |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
45 p2ann = _annotatepair([oldann], p2fctx, p2ann, False, diffopts) |
34432
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
46 self.assertEqual(p2ann[0], [ |
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
47 annotateline('old', 1), |
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
48 annotateline('p2', 2), |
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
49 annotateline('p2', 3), |
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
50 ]) |
34430
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
51 |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
52 # Test with multiple parents (note the difference caused by ordering) |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
53 |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
54 childann = decorate(childdata, childfctx) |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
55 childann = _annotatepair([p1ann, p2ann], childfctx, childann, False, |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
56 diffopts) |
34432
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
57 self.assertEqual(childann[0], [ |
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
58 annotateline('old', 1), |
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
59 annotateline('c', 2), |
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
60 annotateline('p2', 2), |
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
61 annotateline('c', 4), |
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
62 annotateline('p2', 3), |
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
63 ]) |
34430
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
64 |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
65 childann = decorate(childdata, childfctx) |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
66 childann = _annotatepair([p2ann, p1ann], childfctx, childann, False, |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
67 diffopts) |
34432
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
68 self.assertEqual(childann[0], [ |
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
69 annotateline('old', 1), |
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
70 annotateline('c', 2), |
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
71 annotateline('p1', 3), |
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
72 annotateline('c', 4), |
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
73 annotateline('p2', 3), |
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
74 ]) |
34430
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
75 |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
76 # Test with skipchild (note the difference caused by ordering) |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
77 |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
78 childann = decorate(childdata, childfctx) |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
79 childann = _annotatepair([p1ann, p2ann], childfctx, childann, True, |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
80 diffopts) |
34432
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
81 self.assertEqual(childann[0], [ |
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
82 annotateline('old', 1), |
34433
2f5a135b2b04
annotate: track whether a particular annotation was the result of a skip
Siddharth Agarwal <sid0@fb.com>
parents:
34432
diff
changeset
|
83 annotateline('old', 2, True), |
2f5a135b2b04
annotate: track whether a particular annotation was the result of a skip
Siddharth Agarwal <sid0@fb.com>
parents:
34432
diff
changeset
|
84 # note that this line was carried over from earlier so it is *not* |
2f5a135b2b04
annotate: track whether a particular annotation was the result of a skip
Siddharth Agarwal <sid0@fb.com>
parents:
34432
diff
changeset
|
85 # marked skipped |
34432
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
86 annotateline('p2', 2), |
34433
2f5a135b2b04
annotate: track whether a particular annotation was the result of a skip
Siddharth Agarwal <sid0@fb.com>
parents:
34432
diff
changeset
|
87 annotateline('p2', 2, True), |
34432
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
88 annotateline('p2', 3), |
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
89 ]) |
34430
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
90 |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
91 childann = decorate(childdata, childfctx) |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
92 childann = _annotatepair([p2ann, p1ann], childfctx, childann, True, |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
93 diffopts) |
34432
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
94 self.assertEqual(childann[0], [ |
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
95 annotateline('old', 1), |
34433
2f5a135b2b04
annotate: track whether a particular annotation was the result of a skip
Siddharth Agarwal <sid0@fb.com>
parents:
34432
diff
changeset
|
96 annotateline('old', 2, True), |
34432
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
97 annotateline('p1', 3), |
34433
2f5a135b2b04
annotate: track whether a particular annotation was the result of a skip
Siddharth Agarwal <sid0@fb.com>
parents:
34432
diff
changeset
|
98 annotateline('p1', 3, True), |
34432
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
99 annotateline('p2', 3), |
2e32c6a31cc7
annotate: introduce attr for storing per-line annotate data
Siddharth Agarwal <sid0@fb.com>
parents:
34430
diff
changeset
|
100 ]) |
34430
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
101 |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
102 if __name__ == '__main__': |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
103 import silenttestrunner |
80215865d154
annotate: move annotatepair unit tests to a separate file
Siddharth Agarwal <sid0@fb.com>
parents:
diff
changeset
|
104 silenttestrunner.main(__name__) |