/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_annotate.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-12-17 19:55:27 UTC
  • mfrom: (1551.9.21 Aaron's mergeable stuff)
  • Revision ID: pqm@pqm.ubuntu.com-20061217195527-29196a8633600671
Add Tree.annotate_iter

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    )
28
28
 
29
29
 
 
30
def annotation(text):
 
31
    return [tuple(l.split(' ', 1)) for l in text.splitlines(True)]
 
32
 
 
33
 
 
34
parent_1 = annotation("""\
 
35
rev1 a
 
36
rev2 b
 
37
rev3 c
 
38
rev4 d
 
39
rev5 e
 
40
""")
 
41
 
 
42
 
 
43
parent_2 = annotation("""\
 
44
rev1 a
 
45
rev3 c
 
46
rev4 d
 
47
rev6 f
 
48
rev7 e
 
49
rev8 h
 
50
""")
 
51
 
 
52
 
 
53
expected_2_1 = annotation("""\
 
54
rev1 a
 
55
blahblah b
 
56
rev3 c
 
57
rev4 d
 
58
rev7 e
 
59
""")
 
60
 
 
61
 
 
62
# a: in both, same value, kept
 
63
# b: in 1, kept
 
64
# c: in both, same value, kept
 
65
# d: in both, same value, kept
 
66
# e: 1 and 2 disagree, so it goes to blahblah
 
67
# f: in 2, but not in new, so ignored
 
68
# g: not in 1 or 2, so it goes to blahblah
 
69
# h: only in parent 2, so 2 gets it
 
70
expected_1_2_2 = annotation("""\
 
71
rev1 a
 
72
rev2 b
 
73
rev3 c
 
74
rev4 d
 
75
blahblah e
 
76
blahblah g
 
77
rev8 h
 
78
""")
 
79
 
 
80
 
 
81
new_1 = """\
 
82
a
 
83
b
 
84
c
 
85
d
 
86
e
 
87
""".splitlines(True)
 
88
 
 
89
 
 
90
new_2 = """\
 
91
a
 
92
b
 
93
c
 
94
d
 
95
e
 
96
g
 
97
h
 
98
""".splitlines(True)
 
99
 
 
100
 
30
101
class TestAnnotate(tests.TestCaseWithTransport):
31
102
 
32
103
    def create_merged_trees(self):
178
249
                             'rev-1_1_1_1_1_1_1 | fifth\n'
179
250
                             'rev-1_1_1_1_1_1_1 | sixth\n',
180
251
                             sio.getvalue())
 
252
 
 
253
 
 
254
class TestReannotate(tests.TestCase):
 
255
 
 
256
    def annotateEqual(self, expected, parents, newlines, revision_id):
 
257
        annotate_list = list(annotate.reannotate(parents, newlines,
 
258
                             revision_id))
 
259
        self.assertEqual(len(expected), len(annotate_list))
 
260
        for e, a in zip(expected, annotate_list):
 
261
            self.assertEqual(e, a)
 
262
 
 
263
    def test_reannotate(self):
 
264
        self.annotateEqual(parent_1, [parent_1], new_1, 'blahblah')
 
265
        self.annotateEqual(expected_2_1, [parent_2], new_1, 'blahblah')
 
266
        self.annotateEqual(expected_1_2_2, [parent_1, parent_2], new_2, 
 
267
                           'blahblah')