bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.9.1
by Aaron Bentley
Get trivial case passing |
1 |
from unittest import TestCase |
2 |
||
3 |
import multiparent |
|
4 |
||
|
0.9.3
by Aaron Bentley
Get three-parent comparisions under test |
5 |
|
|
0.9.1
by Aaron Bentley
Get trivial case passing |
6 |
LINES_1 = "a\nb\nc\nd\ne\n".splitlines(True) |
|
0.9.2
by Aaron Bentley
Get single-parent comparison working |
7 |
LINES_2 = "a\nc\nd\ne\n".splitlines(True) |
|
0.9.3
by Aaron Bentley
Get three-parent comparisions under test |
8 |
LINES_3 = "a\nb\nc\nd\n".splitlines(True) |
|
0.9.2
by Aaron Bentley
Get single-parent comparison working |
9 |
|
10 |
||
11 |
class Mock(object): |
|
12 |
||
13 |
def __init__(self, **kwargs): |
|
14 |
self.__dict__ = kwargs |
|
15 |
||
|
0.9.1
by Aaron Bentley
Get trivial case passing |
16 |
|
17 |
class TestMulti(TestCase): |
|
18 |
||
|
0.9.2
by Aaron Bentley
Get single-parent comparison working |
19 |
def test_compare_no_parent(self): |
20 |
diff = multiparent.MultiParent.from_lines(LINES_1) |
|
21 |
self.assertEqual([multiparent.NewText(LINES_1)], diff.hunks) |
|
22 |
||
23 |
def test_compare_one_parent(self): |
|
24 |
diff = multiparent.MultiParent.from_lines(LINES_1, [LINES_2]) |
|
25 |
self.assertEqual([multiparent.ParentText(0, 0, 0, 1), |
|
26 |
multiparent.NewText(['b\n']), |
|
27 |
multiparent.ParentText(0, 1, 2, 3)], |
|
28 |
diff.hunks) |
|
29 |
||
|
0.9.3
by Aaron Bentley
Get three-parent comparisions under test |
30 |
def test_compare_two_parents(self): |
31 |
diff = multiparent.MultiParent.from_lines(LINES_1, [LINES_2, LINES_3]) |
|
32 |
self.assertEqual([multiparent.ParentText(1, 0, 0, 4), |
|
33 |
multiparent.ParentText(0, 3, 4, 1)], |
|
34 |
diff.hunks) |
|
35 |
||
|
0.9.9
by Aaron Bentley
Much progress on non-naive text reconstruction |
36 |
def test_range_iterator(self): |
37 |
diff = multiparent.MultiParent.from_lines(LINES_1, [LINES_2, LINES_3]) |
|
38 |
diff.hunks.append(multiparent.NewText(['q\n'])) |
|
39 |
self.assertEqual([(0, 4, 'parent', (1, 0, 4)), |
|
40 |
(4, 5, 'parent', (0, 3, 4)), |
|
41 |
(5, 6, 'new', ['q\n'])], |
|
42 |
list(diff.range_iterator())) |
|
43 |
||
|
0.9.2
by Aaron Bentley
Get single-parent comparison working |
44 |
def test_eq(self): |
45 |
diff = multiparent.MultiParent.from_lines(LINES_1) |
|
46 |
diff2 = multiparent.MultiParent.from_lines(LINES_1) |
|
47 |
self.assertEqual(diff, diff2) |
|
48 |
diff3 = multiparent.MultiParent.from_lines(LINES_2) |
|
49 |
self.assertFalse(diff == diff3) |
|
50 |
self.assertFalse(diff == Mock(hunks=[multiparent.NewText(LINES_1)])) |
|
51 |
self.assertEqual(multiparent.MultiParent( |
|
52 |
[multiparent.NewText(LINES_1), |
|
53 |
multiparent.ParentText(0, 1, 2, 3)]), |
|
54 |
multiparent.MultiParent( |
|
55 |
[multiparent.NewText(LINES_1), |
|
56 |
multiparent.ParentText(0, 1, 2, 3)])) |
|
|
0.9.1
by Aaron Bentley
Get trivial case passing |
57 |
|
|
0.9.4
by Aaron Bentley
Start supporting serialization |
58 |
def test_to_patch(self): |
59 |
self.assertEqual(['i 1\n', 'a\n', '\n', 'c 0 1 2 3\n'], |
|
60 |
list(multiparent.MultiParent([multiparent.NewText(['a\n']), |
|
61 |
multiparent.ParentText(0, 1, 2, 3)]).to_patch())) |
|
62 |
||
|
0.9.1
by Aaron Bentley
Get trivial case passing |
63 |
|
64 |
class TestNewText(TestCase): |
|
65 |
||
66 |
def test_eq(self): |
|
67 |
self.assertEqual(multiparent.NewText([]), multiparent.NewText([])) |
|
68 |
self.assertFalse(multiparent.NewText(['a']) == |
|
69 |
multiparent.NewText(['b'])) |
|
|
0.9.2
by Aaron Bentley
Get single-parent comparison working |
70 |
self.assertFalse(multiparent.NewText(['a']) == Mock(lines=['a'])) |
71 |
||
|
0.9.4
by Aaron Bentley
Start supporting serialization |
72 |
def test_to_patch(self): |
73 |
self.assertEqual(['i 0\n', '\n'], |
|
74 |
list(multiparent.NewText([]).to_patch())) |
|
75 |
self.assertEqual(['i 1\n', 'a', '\n'], |
|
76 |
list(multiparent.NewText(['a']).to_patch())) |
|
77 |
self.assertEqual(['i 1\n', 'a\n', '\n'], |
|
78 |
list(multiparent.NewText(['a\n']).to_patch())) |
|
79 |
||
|
0.9.2
by Aaron Bentley
Get single-parent comparison working |
80 |
|
81 |
class TestParentText(TestCase): |
|
82 |
||
83 |
def test_eq(self): |
|
84 |
self.assertEqual(multiparent.ParentText(1, 2, 3, 4), |
|
85 |
multiparent.ParentText(1, 2, 3, 4)) |
|
86 |
self.assertFalse(multiparent.ParentText(1, 2, 3, 4) == |
|
87 |
multiparent.ParentText(2, 2, 3, 4)) |
|
88 |
self.assertFalse(multiparent.ParentText(1, 2, 3, 4) == |
|
89 |
Mock(parent=1, parent_pos=2, child_pos=3, |
|
90 |
num_lines=4)) |
|
|
0.9.4
by Aaron Bentley
Start supporting serialization |
91 |
|
92 |
def test_to_patch(self): |
|
93 |
self.assertEqual(['c 0 1 2 3\n'], |
|
94 |
list(multiparent.ParentText(0, 1, 2, 3).to_patch())) |
|
|
0.9.8
by Aaron Bentley
get add_version working |
95 |
|
96 |
||
|
0.9.9
by Aaron Bentley
Much progress on non-naive text reconstruction |
97 |
REV_A = ['a\n', 'b\n', 'c\n', 'd\n'] |
98 |
REV_B = ['a\n', 'c\n', 'd\n', 'e\n'] |
|
99 |
REV_C = ['a\n', 'b\n', 'e\n', 'f\n'] |
|
100 |
||
101 |
||
|
0.9.8
by Aaron Bentley
get add_version working |
102 |
class TestVersionedFile(TestCase): |
103 |
||
104 |
def add_version(self, vf, text, version_id, parent_ids): |
|
105 |
vf.add_version([(t+'\n') for t in text], version_id, parent_ids) |
|
106 |
||
|
0.9.9
by Aaron Bentley
Much progress on non-naive text reconstruction |
107 |
def make_vf(self): |
|
0.9.8
by Aaron Bentley
get add_version working |
108 |
vf = multiparent.MultiVersionedFile() |
109 |
self.add_version(vf, 'abcd', 'rev-a', []) |
|
|
0.9.9
by Aaron Bentley
Much progress on non-naive text reconstruction |
110 |
self.add_version(vf, 'acde', 'rev-b', []) |
111 |
self.add_version(vf, 'abef', 'rev-c', ['rev-a', 'rev-b']) |
|
112 |
return vf |
|
113 |
||
114 |
def test_add_version(self): |
|
115 |
vf = self.make_vf() |
|
116 |
self.assertEqual(REV_A, vf._lines['rev-a']) |
|
|
0.9.8
by Aaron Bentley
get add_version working |
117 |
vf.clear_cache() |
118 |
self.assertEqual(vf._lines, {}) |
|
|
0.9.9
by Aaron Bentley
Much progress on non-naive text reconstruction |
119 |
|
120 |
def test_get_line_list(self): |
|
121 |
vf = self.make_vf() |
|
122 |
vf.clear_cache() |
|
123 |
self.assertEqual(REV_A, vf.get_line_list(['rev-a'])[0]) |
|
124 |
self.assertEqual([REV_B, REV_C], vf.get_line_list(['rev-b', 'rev-c'])) |
|
125 |
||
126 |
@staticmethod
|
|
127 |
def reconstruct(vf, revision_id, start, end): |
|
128 |
reconstructor = multiparent._Reconstructor(vf._diffs, vf._lines, |
|
129 |
vf._parents) |
|
130 |
lines = [] |
|
131 |
reconstructor._reconstruct(lines, revision_id, start, end) |
|
132 |
return lines |
|
133 |
||
134 |
def test_reconstructor(self): |
|
135 |
vf = self.make_vf() |
|
136 |
self.assertEqual(['a\n', 'b\n'], self.reconstruct(vf, 'rev-a', 0, 2)) |
|
137 |
self.assertEqual(['c\n', 'd\n'], self.reconstruct(vf, 'rev-a', 2, 4)) |
|
138 |
self.assertEqual(['e\n', 'f\n'], self.reconstruct(vf, 'rev-c', 2, 4)) |