bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1 |
# Copyright (C) 2005-2011, 2016 Canonical Ltd
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
|
0.1.2
by Martin Pool
Import testsweet module adapted from bzr. |
3 |
# This program is free software; you can redistribute it and/or modify
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
7 |
#
|
|
0.1.2
by Martin Pool
Import testsweet module adapted from bzr. |
8 |
# This program is distributed in the hope that it will be useful,
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
12 |
#
|
|
0.1.2
by Martin Pool
Import testsweet module adapted from bzr. |
13 |
# You should have received a copy of the GNU General Public License
|
14 |
# along with this program; if not, write to the Free Software
|
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
0.1.2
by Martin Pool
Import testsweet module adapted from bzr. |
16 |
|
17 |
||
|
1083
by Martin Pool
- add space to store revision-id in weave files |
18 |
# TODO: tests regarding version names
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
19 |
# TODO: rbc 20050108 test that join does not leave an inconsistent weave
|
|
1185.13.4
by Robert Collins
make reweave visible as a weave method, and quickly integrate into fetch |
20 |
# if it fails.
|
|
0.1.2
by Martin Pool
Import testsweet module adapted from bzr. |
21 |
|
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
22 |
"""test suite for weave algorithm"""
|
|
0.1.2
by Martin Pool
Import testsweet module adapted from bzr. |
23 |
|
|
1323
by Martin Pool
- caller can pass SHA-1 to Weave.add for efficiency |
24 |
from pprint import pformat |
|
0.1.2
by Martin Pool
Import testsweet module adapted from bzr. |
25 |
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
26 |
from .. import ( |
|
2024.1.1
by John Arbash Meinel
When a weave file is empty, we should get WeaveFormatError, not StopIteration |
27 |
errors, |
28 |
)
|
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
29 |
from ..osutils import sha_string |
30 |
from ..sixish import ( |
|
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
31 |
BytesIO, |
32 |
)
|
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
33 |
from . import TestCase, TestCaseInTempDir |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
34 |
from ..bzr.weave import Weave, WeaveFormatError |
35 |
from ..bzr.weavefile import write_weave, read_weave |
|
|
0.1.66
by Martin Pool
Cope without set/frozenset classes |
36 |
|
37 |
||
|
0.1.2
by Martin Pool
Import testsweet module adapted from bzr. |
38 |
# texts for use in testing
|
|
0.1.3
by Martin Pool
Change storage of texts for testing |
39 |
TEXT_0 = ["Hello world"] |
40 |
TEXT_1 = ["Hello world", |
|
41 |
"A second line"] |
|
|
0.1.2
by Martin Pool
Import testsweet module adapted from bzr. |
42 |
|
43 |
||
|
1233
by Martin Pool
- fix up weave tests for new test framework |
44 |
class TestBase(TestCase): |
|
2776.1.1
by Robert Collins
* The ``add_lines`` methods on ``VersionedFile`` implementations has changed |
45 |
|
|
0.1.75
by Martin Pool
Remove VerInfo class; just store sets directly in the list of |
46 |
def check_read_write(self, k): |
47 |
"""Check the weave k can be written & re-read.""" |
|
48 |
from tempfile import TemporaryFile |
|
49 |
tf = TemporaryFile() |
|
50 |
||
51 |
write_weave(k, tf) |
|
52 |
tf.seek(0) |
|
53 |
k2 = read_weave(tf) |
|
54 |
||
55 |
if k != k2: |
|
56 |
tf.seek(0) |
|
57 |
self.log('serialized weave:') |
|
58 |
self.log(tf.read()) |
|
|
1083
by Martin Pool
- add space to store revision-id in weave files |
59 |
|
60 |
self.log('') |
|
61 |
self.log('parents: %s' % (k._parents == k2._parents)) |
|
62 |
self.log(' %r' % k._parents) |
|
63 |
self.log(' %r' % k2._parents) |
|
64 |
self.log('') |
|
|
0.1.75
by Martin Pool
Remove VerInfo class; just store sets directly in the list of |
65 |
self.fail('read/write check failed') |
|
1185.16.125
by Martin Pool
Test for 'name in weave' |
66 |
|
67 |
||
68 |
class WeaveContains(TestBase): |
|
69 |
"""Weave __contains__ operator""" |
|
|
5582.10.32
by Jelmer Vernooij
Cleanups. |
70 |
|
|
1185.16.125
by Martin Pool
Test for 'name in weave' |
71 |
def runTest(self): |
|
3316.2.3
by Robert Collins
Remove manual notification of transaction finishing on versioned files. |
72 |
k = Weave(get_scope=lambda:None) |
|
1185.16.125
by Martin Pool
Test for 'name in weave' |
73 |
self.assertFalse('foo' in k) |
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
74 |
k.add_lines('foo', [], TEXT_1) |
|
1185.16.125
by Martin Pool
Test for 'name in weave' |
75 |
self.assertTrue('foo' in k) |
|
0.1.75
by Martin Pool
Remove VerInfo class; just store sets directly in the list of |
76 |
|
77 |
||
|
0.1.2
by Martin Pool
Import testsweet module adapted from bzr. |
78 |
class Easy(TestBase): |
|
5582.10.32
by Jelmer Vernooij
Cleanups. |
79 |
|
|
0.1.2
by Martin Pool
Import testsweet module adapted from bzr. |
80 |
def runTest(self): |
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
81 |
k = Weave() |
|
0.1.2
by Martin Pool
Import testsweet module adapted from bzr. |
82 |
|
83 |
||
|
0.1.7
by Martin Pool
Add trivial annotate text |
84 |
class AnnotateOne(TestBase): |
|
5582.10.32
by Jelmer Vernooij
Cleanups. |
85 |
|
|
0.1.7
by Martin Pool
Add trivial annotate text |
86 |
def runTest(self): |
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
87 |
k = Weave() |
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
88 |
k.add_lines('text0', [], TEXT_0) |
89 |
self.assertEqual(k.annotate('text0'), |
|
90 |
[('text0', TEXT_0[0])]) |
|
|
0.1.7
by Martin Pool
Add trivial annotate text |
91 |
|
92 |
||
|
0.1.27
by Martin Pool
Check that version numbers passed in are reasonable |
93 |
class InvalidAdd(TestBase): |
94 |
"""Try to use invalid version number during add.""" |
|
|
5582.10.32
by Jelmer Vernooij
Cleanups. |
95 |
|
|
0.1.27
by Martin Pool
Check that version numbers passed in are reasonable |
96 |
def runTest(self): |
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
97 |
k = Weave() |
|
0.1.27
by Martin Pool
Check that version numbers passed in are reasonable |
98 |
|
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
99 |
self.assertRaises(errors.RevisionNotPresent, |
100 |
k.add_lines, |
|
|
1083
by Martin Pool
- add space to store revision-id in weave files |
101 |
'text0', |
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
102 |
['69'], |
|
0.1.27
by Martin Pool
Check that version numbers passed in are reasonable |
103 |
['new text!']) |
104 |
||
105 |
||
|
1237
by Martin Pool
- allow the same version to be repeatedly added to a weave |
106 |
class RepeatedAdd(TestBase): |
107 |
"""Add the same version twice; harmless.""" |
|
|
2776.1.1
by Robert Collins
* The ``add_lines`` methods on ``VersionedFile`` implementations has changed |
108 |
|
109 |
def test_duplicate_add(self): |
|
|
1237
by Martin Pool
- allow the same version to be repeatedly added to a weave |
110 |
k = Weave() |
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
111 |
idx = k.add_lines('text0', [], TEXT_0) |
112 |
idx2 = k.add_lines('text0', [], TEXT_0) |
|
|
1237
by Martin Pool
- allow the same version to be repeatedly added to a weave |
113 |
self.assertEqual(idx, idx2) |
114 |
||
115 |
||
116 |
class InvalidRepeatedAdd(TestBase): |
|
|
5582.10.32
by Jelmer Vernooij
Cleanups. |
117 |
|
|
1237
by Martin Pool
- allow the same version to be repeatedly added to a weave |
118 |
def runTest(self): |
119 |
k = Weave() |
|
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
120 |
k.add_lines('basis', [], TEXT_0) |
121 |
idx = k.add_lines('text0', [], TEXT_0) |
|
|
1563.2.1
by Robert Collins
Merge in a variation of the versionedfile api from versioned-file. |
122 |
self.assertRaises(errors.RevisionAlreadyPresent, |
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
123 |
k.add_lines, |
|
1237
by Martin Pool
- allow the same version to be repeatedly added to a weave |
124 |
'text0', |
125 |
[],
|
|
126 |
['not the same text']) |
|
|
1563.2.1
by Robert Collins
Merge in a variation of the versionedfile api from versioned-file. |
127 |
self.assertRaises(errors.RevisionAlreadyPresent, |
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
128 |
k.add_lines, |
|
1237
by Martin Pool
- allow the same version to be repeatedly added to a weave |
129 |
'text0', |
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
130 |
['basis'], # not the right parents |
|
1237
by Martin Pool
- allow the same version to be repeatedly added to a weave |
131 |
TEXT_0) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
132 |
|
|
1237
by Martin Pool
- allow the same version to be repeatedly added to a weave |
133 |
|
|
0.1.26
by Martin Pool
Refactor parameters to add command |
134 |
class InsertLines(TestBase): |
|
0.1.13
by Martin Pool
Knit structure now allows for versions to include the lines present in other |
135 |
"""Store a revision that adds one line to the original. |
136 |
||
137 |
Look at the annotations to make sure that the first line is matched
|
|
138 |
and not stored repeatedly."""
|
|
139 |
def runTest(self): |
|
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
140 |
k = Weave() |
|
0.1.13
by Martin Pool
Knit structure now allows for versions to include the lines present in other |
141 |
|
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
142 |
k.add_lines('text0', [], ['line 1']) |
143 |
k.add_lines('text1', ['text0'], ['line 1', 'line 2']) |
|
144 |
||
145 |
self.assertEqual(k.annotate('text0'), |
|
146 |
[('text0', 'line 1')]) |
|
147 |
||
148 |
self.assertEqual(k.get_lines(1), |
|
|
0.1.25
by Martin Pool
Handle insertion of new weave layers that insert text on top of the basis |
149 |
['line 1', |
150 |
'line 2']) |
|
151 |
||
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
152 |
self.assertEqual(k.annotate('text1'), |
153 |
[('text0', 'line 1'), |
|
154 |
('text1', 'line 2')]) |
|
155 |
||
156 |
k.add_lines('text2', ['text0'], ['line 1', 'diverged line']) |
|
157 |
||
158 |
self.assertEqual(k.annotate('text2'), |
|
159 |
[('text0', 'line 1'), |
|
160 |
('text2', 'diverged line')]) |
|
|
0.1.28
by Martin Pool
More tests for insertion of lines in new versions. |
161 |
|
|
0.1.54
by Martin Pool
Fix weave line calculation when making deltas |
162 |
text3 = ['line 1', 'middle line', 'line 2'] |
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
163 |
k.add_lines('text3', |
164 |
['text0', 'text1'], |
|
|
0.1.54
by Martin Pool
Fix weave line calculation when making deltas |
165 |
text3) |
166 |
||
|
937
by Martin Pool
- weave raises IndexError when an invalid revision is given |
167 |
# self.log("changes to text3: " + pformat(list(k._delta(set([0, 1]), text3))))
|
|
0.1.54
by Martin Pool
Fix weave line calculation when making deltas |
168 |
|
|
944
by Martin Pool
- refactor member names in Weave code |
169 |
self.log("k._weave=" + pformat(k._weave)) |
|
0.1.28
by Martin Pool
More tests for insertion of lines in new versions. |
170 |
|
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
171 |
self.assertEqual(k.annotate('text3'), |
172 |
[('text0', 'line 1'), |
|
173 |
('text3', 'middle line'), |
|
174 |
('text1', 'line 2')]) |
|
|
0.1.28
by Martin Pool
More tests for insertion of lines in new versions. |
175 |
|
|
0.1.31
by Martin Pool
Fix insertion of multiple regions, calculating the right line offset as we go. |
176 |
# now multiple insertions at different places
|
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
177 |
k.add_lines('text4', |
178 |
['text0', 'text1', 'text3'], |
|
|
0.1.31
by Martin Pool
Fix insertion of multiple regions, calculating the right line offset as we go. |
179 |
['line 1', 'aaa', 'middle line', 'bbb', 'line 2', 'ccc']) |
180 |
||
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
181 |
self.assertEqual(k.annotate('text4'), |
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
182 |
[('text0', 'line 1'), |
183 |
('text4', 'aaa'), |
|
184 |
('text3', 'middle line'), |
|
185 |
('text4', 'bbb'), |
|
186 |
('text1', 'line 2'), |
|
187 |
('text4', 'ccc')]) |
|
|
0.1.13
by Martin Pool
Knit structure now allows for versions to include the lines present in other |
188 |
|
|
0.1.40
by Martin Pool
Add test for extracting from weave with nested insertions |
189 |
|
|
0.1.56
by Martin Pool
Handle deletion of lines by marking the region with a deletion |
190 |
class DeleteLines(TestBase): |
191 |
"""Deletion of lines from existing text. |
|
192 |
||
193 |
Try various texts all based on a common ancestor."""
|
|
194 |
def runTest(self): |
|
195 |
k = Weave() |
|
196 |
||
197 |
base_text = ['one', 'two', 'three', 'four'] |
|
198 |
||
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
199 |
k.add_lines('text0', [], base_text) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
200 |
|
|
0.1.56
by Martin Pool
Handle deletion of lines by marking the region with a deletion |
201 |
texts = [['one', 'two', 'three'], |
202 |
['two', 'three', 'four'], |
|
203 |
['one', 'four'], |
|
204 |
['one', 'two', 'three', 'four'], |
|
205 |
]
|
|
206 |
||
|
1083
by Martin Pool
- add space to store revision-id in weave files |
207 |
i = 1 |
|
0.1.56
by Martin Pool
Handle deletion of lines by marking the region with a deletion |
208 |
for t in texts: |
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
209 |
ver = k.add_lines('text%d' % i, |
210 |
['text0'], t) |
|
|
1083
by Martin Pool
- add space to store revision-id in weave files |
211 |
i += 1 |
|
0.1.56
by Martin Pool
Handle deletion of lines by marking the region with a deletion |
212 |
|
213 |
self.log('final weave:') |
|
|
944
by Martin Pool
- refactor member names in Weave code |
214 |
self.log('k._weave=' + pformat(k._weave)) |
|
0.1.56
by Martin Pool
Handle deletion of lines by marking the region with a deletion |
215 |
|
216 |
for i in range(len(texts)): |
|
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
217 |
self.assertEqual(k.get_lines(i+1), |
|
0.1.56
by Martin Pool
Handle deletion of lines by marking the region with a deletion |
218 |
texts[i]) |
219 |
||
220 |
||
|
0.1.49
by Martin Pool
Add another constraint: revisions should not delete text that they |
221 |
class SuicideDelete(TestBase): |
|
0.1.55
by Martin Pool
doc |
222 |
"""Invalid weave which tries to add and delete simultaneously.""" |
|
0.1.49
by Martin Pool
Add another constraint: revisions should not delete text that they |
223 |
def runTest(self): |
224 |
k = Weave() |
|
225 |
||
|
944
by Martin Pool
- refactor member names in Weave code |
226 |
k._parents = [(), |
|
0.1.49
by Martin Pool
Add another constraint: revisions should not delete text that they |
227 |
]
|
|
944
by Martin Pool
- refactor member names in Weave code |
228 |
k._weave = [('{', 0), |
|
0.1.49
by Martin Pool
Add another constraint: revisions should not delete text that they |
229 |
'first line', |
230 |
('[', 0), |
|
231 |
'deleted in 0', |
|
232 |
(']', 0), |
|
233 |
('}', 0), |
|
234 |
]
|
|
|
891
by Martin Pool
- fix up refactoring of weave |
235 |
################################### SKIPPED
|
236 |
# Weave.get doesn't trap this anymore
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
237 |
return
|
|
0.1.49
by Martin Pool
Add another constraint: revisions should not delete text that they |
238 |
|
239 |
self.assertRaises(WeaveFormatError, |
|
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
240 |
k.get_lines, |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
241 |
0) |
|
0.1.49
by Martin Pool
Add another constraint: revisions should not delete text that they |
242 |
|
243 |
||
|
0.1.48
by Martin Pool
Basic parsing of delete instructions. |
244 |
class CannedDelete(TestBase): |
245 |
"""Unpack canned weave with deleted lines.""" |
|
246 |
def runTest(self): |
|
247 |
k = Weave() |
|
248 |
||
|
944
by Martin Pool
- refactor member names in Weave code |
249 |
k._parents = [(), |
|
0.1.75
by Martin Pool
Remove VerInfo class; just store sets directly in the list of |
250 |
frozenset([0]), |
|
0.1.48
by Martin Pool
Basic parsing of delete instructions. |
251 |
]
|
|
944
by Martin Pool
- refactor member names in Weave code |
252 |
k._weave = [('{', 0), |
|
0.1.48
by Martin Pool
Basic parsing of delete instructions. |
253 |
'first line', |
254 |
('[', 1), |
|
255 |
'line to be deleted', |
|
256 |
(']', 1), |
|
257 |
'last line', |
|
258 |
('}', 0), |
|
259 |
]
|
|
|
1185.50.23
by John Arbash Meinel
Adding sha1 check when weave extracts a text. |
260 |
k._sha1s = [sha_string('first lineline to be deletedlast line') |
261 |
, sha_string('first linelast line')] |
|
|
0.1.48
by Martin Pool
Basic parsing of delete instructions. |
262 |
|
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
263 |
self.assertEqual(k.get_lines(0), |
|
0.1.48
by Martin Pool
Basic parsing of delete instructions. |
264 |
['first line', |
265 |
'line to be deleted', |
|
266 |
'last line', |
|
267 |
])
|
|
268 |
||
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
269 |
self.assertEqual(k.get_lines(1), |
|
0.1.50
by Martin Pool
Basic implementation of deletion markers |
270 |
['first line', |
271 |
'last line', |
|
272 |
])
|
|
273 |
||
|
0.1.48
by Martin Pool
Basic parsing of delete instructions. |
274 |
|
|
0.1.51
by Martin Pool
Add test for replacement lines |
275 |
class CannedReplacement(TestBase): |
276 |
"""Unpack canned weave with deleted lines.""" |
|
277 |
def runTest(self): |
|
278 |
k = Weave() |
|
279 |
||
|
944
by Martin Pool
- refactor member names in Weave code |
280 |
k._parents = [frozenset(), |
|
0.1.75
by Martin Pool
Remove VerInfo class; just store sets directly in the list of |
281 |
frozenset([0]), |
|
0.1.51
by Martin Pool
Add test for replacement lines |
282 |
]
|
|
944
by Martin Pool
- refactor member names in Weave code |
283 |
k._weave = [('{', 0), |
|
0.1.51
by Martin Pool
Add test for replacement lines |
284 |
'first line', |
285 |
('[', 1), |
|
286 |
'line to be deleted', |
|
287 |
(']', 1), |
|
288 |
('{', 1), |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
289 |
'replacement line', |
|
0.1.51
by Martin Pool
Add test for replacement lines |
290 |
('}', 1), |
291 |
'last line', |
|
292 |
('}', 0), |
|
293 |
]
|
|
|
1185.50.23
by John Arbash Meinel
Adding sha1 check when weave extracts a text. |
294 |
k._sha1s = [sha_string('first lineline to be deletedlast line') |
295 |
, sha_string('first linereplacement linelast line')] |
|
|
0.1.51
by Martin Pool
Add test for replacement lines |
296 |
|
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
297 |
self.assertEqual(k.get_lines(0), |
|
0.1.51
by Martin Pool
Add test for replacement lines |
298 |
['first line', |
299 |
'line to be deleted', |
|
300 |
'last line', |
|
301 |
])
|
|
302 |
||
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
303 |
self.assertEqual(k.get_lines(1), |
|
0.1.51
by Martin Pool
Add test for replacement lines |
304 |
['first line', |
305 |
'replacement line', |
|
306 |
'last line', |
|
307 |
])
|
|
308 |
||
309 |
||
|
0.1.46
by Martin Pool
More constraints on structure of weave, and checks that they work |
310 |
class BadWeave(TestBase): |
311 |
"""Test that we trap an insert which should not occur.""" |
|
312 |
def runTest(self): |
|
313 |
k = Weave() |
|
314 |
||
|
944
by Martin Pool
- refactor member names in Weave code |
315 |
k._parents = [frozenset(), |
|
0.1.46
by Martin Pool
More constraints on structure of weave, and checks that they work |
316 |
]
|
|
944
by Martin Pool
- refactor member names in Weave code |
317 |
k._weave = ['bad line', |
|
0.1.46
by Martin Pool
More constraints on structure of weave, and checks that they work |
318 |
('{', 0), |
319 |
'foo {', |
|
320 |
('{', 1), |
|
321 |
' added in version 1', |
|
322 |
('{', 2), |
|
323 |
' added in v2', |
|
324 |
('}', 2), |
|
325 |
' also from v1', |
|
326 |
('}', 1), |
|
327 |
'}', |
|
328 |
('}', 0)] |
|
329 |
||
|
891
by Martin Pool
- fix up refactoring of weave |
330 |
################################### SKIPPED
|
331 |
# Weave.get doesn't trap this anymore
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
332 |
return
|
|
891
by Martin Pool
- fix up refactoring of weave |
333 |
|
334 |
||
|
0.1.47
by Martin Pool
New WeaveError and WeaveFormatError rather than assertions. |
335 |
self.assertRaises(WeaveFormatError, |
|
0.1.46
by Martin Pool
More constraints on structure of weave, and checks that they work |
336 |
k.get, |
337 |
0) |
|
338 |
||
339 |
||
340 |
class BadInsert(TestBase): |
|
341 |
"""Test that we trap an insert which should not occur.""" |
|
342 |
def runTest(self): |
|
343 |
k = Weave() |
|
344 |
||
|
944
by Martin Pool
- refactor member names in Weave code |
345 |
k._parents = [frozenset(), |
|
0.1.75
by Martin Pool
Remove VerInfo class; just store sets directly in the list of |
346 |
frozenset([0]), |
347 |
frozenset([0]), |
|
348 |
frozenset([0,1,2]), |
|
|
0.1.46
by Martin Pool
More constraints on structure of weave, and checks that they work |
349 |
]
|
|
944
by Martin Pool
- refactor member names in Weave code |
350 |
k._weave = [('{', 0), |
|
0.1.46
by Martin Pool
More constraints on structure of weave, and checks that they work |
351 |
'foo {', |
352 |
('{', 1), |
|
353 |
' added in version 1', |
|
354 |
('{', 1), |
|
355 |
' more in 1', |
|
356 |
('}', 1), |
|
357 |
('}', 1), |
|
358 |
('}', 0)] |
|
359 |
||
|
891
by Martin Pool
- fix up refactoring of weave |
360 |
|
361 |
# this is not currently enforced by get
|
|
362 |
return ########################################## |
|
363 |
||
|
0.1.47
by Martin Pool
New WeaveError and WeaveFormatError rather than assertions. |
364 |
self.assertRaises(WeaveFormatError, |
|
0.1.46
by Martin Pool
More constraints on structure of weave, and checks that they work |
365 |
k.get, |
366 |
0) |
|
367 |
||
|
0.1.47
by Martin Pool
New WeaveError and WeaveFormatError rather than assertions. |
368 |
self.assertRaises(WeaveFormatError, |
|
0.1.46
by Martin Pool
More constraints on structure of weave, and checks that they work |
369 |
k.get, |
370 |
1) |
|
371 |
||
|
0.1.40
by Martin Pool
Add test for extracting from weave with nested insertions |
372 |
|
373 |
class InsertNested(TestBase): |
|
374 |
"""Insertion with nested instructions.""" |
|
375 |
def runTest(self): |
|
376 |
k = Weave() |
|
377 |
||
|
944
by Martin Pool
- refactor member names in Weave code |
378 |
k._parents = [frozenset(), |
|
0.1.75
by Martin Pool
Remove VerInfo class; just store sets directly in the list of |
379 |
frozenset([0]), |
380 |
frozenset([0]), |
|
381 |
frozenset([0,1,2]), |
|
|
0.1.40
by Martin Pool
Add test for extracting from weave with nested insertions |
382 |
]
|
|
944
by Martin Pool
- refactor member names in Weave code |
383 |
k._weave = [('{', 0), |
|
0.1.40
by Martin Pool
Add test for extracting from weave with nested insertions |
384 |
'foo {', |
385 |
('{', 1), |
|
386 |
' added in version 1', |
|
|
0.1.42
by Martin Pool
More tests for nested insert instructions |
387 |
('{', 2), |
388 |
' added in v2', |
|
389 |
('}', 2), |
|
390 |
' also from v1', |
|
|
0.1.40
by Martin Pool
Add test for extracting from weave with nested insertions |
391 |
('}', 1), |
392 |
'}', |
|
393 |
('}', 0)] |
|
394 |
||
|
1185.50.23
by John Arbash Meinel
Adding sha1 check when weave extracts a text. |
395 |
k._sha1s = [sha_string('foo {}') |
396 |
, sha_string('foo { added in version 1 also from v1}') |
|
397 |
, sha_string('foo { added in v2}') |
|
398 |
, sha_string('foo { added in version 1 added in v2 also from v1}') |
|
399 |
]
|
|
400 |
||
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
401 |
self.assertEqual(k.get_lines(0), |
|
0.1.40
by Martin Pool
Add test for extracting from weave with nested insertions |
402 |
['foo {', |
403 |
'}']) |
|
404 |
||
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
405 |
self.assertEqual(k.get_lines(1), |
|
0.1.40
by Martin Pool
Add test for extracting from weave with nested insertions |
406 |
['foo {', |
407 |
' added in version 1', |
|
|
0.1.42
by Martin Pool
More tests for nested insert instructions |
408 |
' also from v1', |
|
0.1.40
by Martin Pool
Add test for extracting from weave with nested insertions |
409 |
'}']) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
410 |
|
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
411 |
self.assertEqual(k.get_lines(2), |
|
0.1.44
by Martin Pool
More tests for nested insert instructions |
412 |
['foo {', |
413 |
' added in v2', |
|
414 |
'}']) |
|
415 |
||
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
416 |
self.assertEqual(k.get_lines(3), |
|
0.1.44
by Martin Pool
More tests for nested insert instructions |
417 |
['foo {', |
418 |
' added in version 1', |
|
419 |
' added in v2', |
|
420 |
' also from v1', |
|
421 |
'}']) |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
422 |
|
|
0.1.45
by Martin Pool
doc |
423 |
|
|
0.1.56
by Martin Pool
Handle deletion of lines by marking the region with a deletion |
424 |
class DeleteLines2(TestBase): |
|
0.1.30
by Martin Pool
Start adding tests for line deletion |
425 |
"""Test recording revisions that delete lines. |
426 |
||
427 |
This relies on the weave having a way to represent lines knocked
|
|
428 |
out by a later revision."""
|
|
429 |
def runTest(self): |
|
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
430 |
k = Weave() |
|
0.1.30
by Martin Pool
Start adding tests for line deletion |
431 |
|
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
432 |
k.add_lines('text0', [], ["line the first", |
|
0.1.30
by Martin Pool
Start adding tests for line deletion |
433 |
"line 2", |
434 |
"line 3", |
|
435 |
"fine"]) |
|
436 |
||
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
437 |
self.assertEqual(len(k.get_lines(0)), 4) |
|
0.1.30
by Martin Pool
Start adding tests for line deletion |
438 |
|
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
439 |
k.add_lines('text1', ['text0'], ["line the first", |
|
0.1.30
by Martin Pool
Start adding tests for line deletion |
440 |
"fine"]) |
441 |
||
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
442 |
self.assertEqual(k.get_lines(1), |
|
0.1.30
by Martin Pool
Start adding tests for line deletion |
443 |
["line the first", |
444 |
"fine"]) |
|
445 |
||
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
446 |
self.assertEqual(k.annotate('text1'), |
447 |
[('text0', "line the first"), |
|
448 |
('text0', "fine")]) |
|
|
0.1.56
by Martin Pool
Handle deletion of lines by marking the region with a deletion |
449 |
|
|
0.1.30
by Martin Pool
Start adding tests for line deletion |
450 |
|
|
0.1.13
by Martin Pool
Knit structure now allows for versions to include the lines present in other |
451 |
class IncludeVersions(TestBase): |
452 |
"""Check texts that are stored across multiple revisions. |
|
453 |
||
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
454 |
Here we manually create a weave with particular encoding and make
|
|
0.1.13
by Martin Pool
Knit structure now allows for versions to include the lines present in other |
455 |
sure it unpacks properly.
|
456 |
||
457 |
Text 0 includes nothing; text 1 includes text 0 and adds some
|
|
458 |
lines.
|
|
459 |
"""
|
|
460 |
||
461 |
def runTest(self): |
|
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
462 |
k = Weave() |
|
0.1.13
by Martin Pool
Knit structure now allows for versions to include the lines present in other |
463 |
|
|
944
by Martin Pool
- refactor member names in Weave code |
464 |
k._parents = [frozenset(), frozenset([0])] |
465 |
k._weave = [('{', 0), |
|
|
0.1.39
by Martin Pool
Change to a more realistic weave structure which can represent insertions and |
466 |
"first line", |
467 |
('}', 0), |
|
468 |
('{', 1), |
|
469 |
"second line", |
|
470 |
('}', 1)] |
|
|
0.1.13
by Martin Pool
Knit structure now allows for versions to include the lines present in other |
471 |
|
|
1185.50.23
by John Arbash Meinel
Adding sha1 check when weave extracts a text. |
472 |
k._sha1s = [sha_string('first line') |
473 |
, sha_string('first linesecond line')] |
|
474 |
||
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
475 |
self.assertEqual(k.get_lines(1), |
|
0.1.13
by Martin Pool
Knit structure now allows for versions to include the lines present in other |
476 |
["first line", |
477 |
"second line"]) |
|
478 |
||
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
479 |
self.assertEqual(k.get_lines(0), |
|
0.1.13
by Martin Pool
Knit structure now allows for versions to include the lines present in other |
480 |
["first line"]) |
481 |
||
|
0.1.5
by Martin Pool
Add test for storing two text versions. |
482 |
|
|
0.1.14
by Martin Pool
Another test for version inclusion |
483 |
class DivergedIncludes(TestBase): |
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
484 |
"""Weave with two diverged texts based on version 0. |
|
0.1.14
by Martin Pool
Another test for version inclusion |
485 |
"""
|
486 |
def runTest(self): |
|
|
1563.2.1
by Robert Collins
Merge in a variation of the versionedfile api from versioned-file. |
487 |
# FIXME make the weave, dont poke at it.
|
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
488 |
k = Weave() |
|
0.1.14
by Martin Pool
Another test for version inclusion |
489 |
|
|
1563.2.1
by Robert Collins
Merge in a variation of the versionedfile api from versioned-file. |
490 |
k._names = ['0', '1', '2'] |
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
491 |
k._name_map = {'0':0, '1':1, '2':2} |
|
944
by Martin Pool
- refactor member names in Weave code |
492 |
k._parents = [frozenset(), |
|
0.1.75
by Martin Pool
Remove VerInfo class; just store sets directly in the list of |
493 |
frozenset([0]), |
494 |
frozenset([0]), |
|
|
0.1.17
by Martin Pool
Use objects rather than tuples for tracking VerInfo for |
495 |
]
|
|
944
by Martin Pool
- refactor member names in Weave code |
496 |
k._weave = [('{', 0), |
|
0.1.39
by Martin Pool
Change to a more realistic weave structure which can represent insertions and |
497 |
"first line", |
498 |
('}', 0), |
|
499 |
('{', 1), |
|
500 |
"second line", |
|
501 |
('}', 1), |
|
502 |
('{', 2), |
|
503 |
"alternative second line", |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
504 |
('}', 2), |
|
0.1.39
by Martin Pool
Change to a more realistic weave structure which can represent insertions and |
505 |
]
|
|
0.1.14
by Martin Pool
Another test for version inclusion |
506 |
|
|
1185.50.23
by John Arbash Meinel
Adding sha1 check when weave extracts a text. |
507 |
k._sha1s = [sha_string('first line') |
508 |
, sha_string('first linesecond line') |
|
509 |
, sha_string('first linealternative second line')] |
|
510 |
||
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
511 |
self.assertEqual(k.get_lines(0), |
|
0.1.14
by Martin Pool
Another test for version inclusion |
512 |
["first line"]) |
513 |
||
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
514 |
self.assertEqual(k.get_lines(1), |
|
0.1.14
by Martin Pool
Another test for version inclusion |
515 |
["first line", |
516 |
"second line"]) |
|
517 |
||
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
518 |
self.assertEqual(k.get_lines('2'), |
|
0.1.14
by Martin Pool
Another test for version inclusion |
519 |
["first line", |
520 |
"alternative second line"]) |
|
521 |
||
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
522 |
self.assertEqual(list(k.get_ancestry(['2'])), |
|
1563.2.1
by Robert Collins
Merge in a variation of the versionedfile api from versioned-file. |
523 |
['0', '2']) |
|
0.1.77
by Martin Pool
New Weave.get_included() does transitive expansion |
524 |
|
|
0.1.57
by Martin Pool
Fix bug in an update edit that both deletes and inserts -- previously |
525 |
|
526 |
class ReplaceLine(TestBase): |
|
527 |
def runTest(self): |
|
528 |
k = Weave() |
|
529 |
||
530 |
text0 = ['cheddar', 'stilton', 'gruyere'] |
|
531 |
text1 = ['cheddar', 'blue vein', 'neufchatel', 'chevre'] |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
532 |
|
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
533 |
k.add_lines('text0', [], text0) |
534 |
k.add_lines('text1', ['text0'], text1) |
|
|
0.1.57
by Martin Pool
Fix bug in an update edit that both deletes and inserts -- previously |
535 |
|
|
944
by Martin Pool
- refactor member names in Weave code |
536 |
self.log('k._weave=' + pformat(k._weave)) |
|
0.1.57
by Martin Pool
Fix bug in an update edit that both deletes and inserts -- previously |
537 |
|
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
538 |
self.assertEqual(k.get_lines(0), text0) |
539 |
self.assertEqual(k.get_lines(1), text1) |
|
|
0.1.57
by Martin Pool
Fix bug in an update edit that both deletes and inserts -- previously |
540 |
|
|
0.1.64
by Martin Pool
Add test for merging versions |
541 |
|
542 |
class Merge(TestBase): |
|
|
0.1.95
by Martin Pool
- preliminary merge conflict detection |
543 |
"""Storage of versions that merge diverged parents""" |
|
5582.10.32
by Jelmer Vernooij
Cleanups. |
544 |
|
|
0.1.64
by Martin Pool
Add test for merging versions |
545 |
def runTest(self): |
546 |
k = Weave() |
|
547 |
||
548 |
texts = [['header'], |
|
549 |
['header', '', 'line from 1'], |
|
550 |
['header', '', 'line from 2', 'more from 2'], |
|
551 |
['header', '', 'line from 1', 'fixup line', 'line from 2'], |
|
552 |
]
|
|
553 |
||
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
554 |
k.add_lines('text0', [], texts[0]) |
555 |
k.add_lines('text1', ['text0'], texts[1]) |
|
556 |
k.add_lines('text2', ['text0'], texts[2]) |
|
557 |
k.add_lines('merge', ['text0', 'text1', 'text2'], texts[3]) |
|
|
0.1.64
by Martin Pool
Add test for merging versions |
558 |
|
559 |
for i, t in enumerate(texts): |
|
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
560 |
self.assertEqual(k.get_lines(i), t) |
|
0.1.64
by Martin Pool
Add test for merging versions |
561 |
|
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
562 |
self.assertEqual(k.annotate('merge'), |
563 |
[('text0', 'header'), |
|
564 |
('text1', ''), |
|
565 |
('text1', 'line from 1'), |
|
566 |
('merge', 'fixup line'), |
|
567 |
('text2', 'line from 2'), |
|
|
0.1.64
by Martin Pool
Add test for merging versions |
568 |
])
|
569 |
||
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
570 |
self.assertEqual(list(k.get_ancestry(['merge'])), |
|
1563.2.1
by Robert Collins
Merge in a variation of the versionedfile api from versioned-file. |
571 |
['text0', 'text1', 'text2', 'merge']) |
|
0.1.77
by Martin Pool
New Weave.get_included() does transitive expansion |
572 |
|
|
944
by Martin Pool
- refactor member names in Weave code |
573 |
self.log('k._weave=' + pformat(k._weave)) |
|
0.1.64
by Martin Pool
Add test for merging versions |
574 |
|
|
0.1.75
by Martin Pool
Remove VerInfo class; just store sets directly in the list of |
575 |
self.check_read_write(k) |
|
0.1.65
by Martin Pool
Add Weave.merge_iter to get automerged lines |
576 |
|
577 |
||
|
0.1.95
by Martin Pool
- preliminary merge conflict detection |
578 |
class Conflicts(TestBase): |
579 |
"""Test detection of conflicting regions during a merge. |
|
580 |
||
581 |
A base version is inserted, then two descendents try to
|
|
582 |
insert different lines in the same place. These should be
|
|
583 |
reported as a possible conflict and forwarded to the user."""
|
|
584 |
def runTest(self): |
|
585 |
return # NOT RUN |
|
586 |
k = Weave() |
|
587 |
||
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
588 |
k.add_lines([], ['aaa', 'bbb']) |
589 |
k.add_lines([0], ['aaa', '111', 'bbb']) |
|
590 |
k.add_lines([1], ['aaa', '222', 'bbb']) |
|
|
0.1.95
by Martin Pool
- preliminary merge conflict detection |
591 |
|
592 |
merged = k.merge([1, 2]) |
|
593 |
||
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
594 |
self.assertEqual([[['aaa']], |
|
0.1.95
by Martin Pool
- preliminary merge conflict detection |
595 |
[['111'], ['222']], |
596 |
[['bbb']]]) |
|
597 |
||
598 |
||
599 |
class NonConflict(TestBase): |
|
600 |
"""Two descendants insert compatible changes. |
|
601 |
||
602 |
No conflict should be reported."""
|
|
603 |
def runTest(self): |
|
604 |
return # NOT RUN |
|
605 |
k = Weave() |
|
606 |
||
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
607 |
k.add_lines([], ['aaa', 'bbb']) |
608 |
k.add_lines([0], ['111', 'aaa', 'ccc', 'bbb']) |
|
609 |
k.add_lines([1], ['aaa', 'ccc', 'bbb', '222']) |
|
|
0.1.95
by Martin Pool
- preliminary merge conflict detection |
610 |
|
611 |
||
|
0.1.57
by Martin Pool
Fix bug in an update edit that both deletes and inserts -- previously |
612 |
class Khayyam(TestBase): |
|
0.1.75
by Martin Pool
Remove VerInfo class; just store sets directly in the list of |
613 |
"""Test changes to multi-line texts, and read/write""" |
|
1563.2.1
by Robert Collins
Merge in a variation of the versionedfile api from versioned-file. |
614 |
|
615 |
def test_multi_line_merge(self): |
|
|
0.1.57
by Martin Pool
Fix bug in an update edit that both deletes and inserts -- previously |
616 |
rawtexts = [ |
617 |
"""A Book of Verses underneath the Bough, |
|
618 |
A Jug of Wine, a Loaf of Bread, -- and Thou
|
|
619 |
Beside me singing in the Wilderness --
|
|
620 |
Oh, Wilderness were Paradise enow!""", |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
621 |
|
|
0.1.57
by Martin Pool
Fix bug in an update edit that both deletes and inserts -- previously |
622 |
"""A Book of Verses underneath the Bough, |
623 |
A Jug of Wine, a Loaf of Bread, -- and Thou
|
|
624 |
Beside me singing in the Wilderness --
|
|
625 |
Oh, Wilderness were Paradise now!""", |
|
|
0.1.59
by Martin Pool
More modification tests |
626 |
|
627 |
"""A Book of poems underneath the tree, |
|
628 |
A Jug of Wine, a Loaf of Bread,
|
|
629 |
and Thou
|
|
630 |
Beside me singing in the Wilderness --
|
|
631 |
Oh, Wilderness were Paradise now!
|
|
632 |
||
633 |
-- O. Khayyam""", |
|
634 |
||
635 |
"""A Book of Verses underneath the Bough, |
|
636 |
A Jug of Wine, a Loaf of Bread,
|
|
637 |
and Thou
|
|
638 |
Beside me singing in the Wilderness --
|
|
|
0.1.75
by Martin Pool
Remove VerInfo class; just store sets directly in the list of |
639 |
Oh, Wilderness were Paradise now!""", |
|
0.1.57
by Martin Pool
Fix bug in an update edit that both deletes and inserts -- previously |
640 |
]
|
641 |
texts = [[l.strip() for l in t.split('\n')] for t in rawtexts] |
|
642 |
||
643 |
k = Weave() |
|
644 |
parents = set() |
|
|
1083
by Martin Pool
- add space to store revision-id in weave files |
645 |
i = 0 |
|
0.1.57
by Martin Pool
Fix bug in an update edit that both deletes and inserts -- previously |
646 |
for t in texts: |
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
647 |
ver = k.add_lines('text%d' % i, |
|
1083
by Martin Pool
- add space to store revision-id in weave files |
648 |
list(parents), t) |
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
649 |
parents.add('text%d' % i) |
|
1083
by Martin Pool
- add space to store revision-id in weave files |
650 |
i += 1 |
|
0.1.57
by Martin Pool
Fix bug in an update edit that both deletes and inserts -- previously |
651 |
|
|
944
by Martin Pool
- refactor member names in Weave code |
652 |
self.log("k._weave=" + pformat(k._weave)) |
|
0.1.59
by Martin Pool
More modification tests |
653 |
|
|
0.1.57
by Martin Pool
Fix bug in an update edit that both deletes and inserts -- previously |
654 |
for i, t in enumerate(texts): |
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
655 |
self.assertEqual(k.get_lines(i), t) |
|
0.1.57
by Martin Pool
Fix bug in an update edit that both deletes and inserts -- previously |
656 |
|
|
0.1.75
by Martin Pool
Remove VerInfo class; just store sets directly in the list of |
657 |
self.check_read_write(k) |
|
0.1.57
by Martin Pool
Fix bug in an update edit that both deletes and inserts -- previously |
658 |
|
659 |
||
|
1393.1.48
by Martin Pool
- Add stub Weave.join() method |
660 |
class JoinWeavesTests(TestBase): |
|
5582.10.32
by Jelmer Vernooij
Cleanups. |
661 |
|
|
1393.1.50
by Martin Pool
- more development of Weave.join() |
662 |
def setUp(self): |
663 |
super(JoinWeavesTests, self).setUp() |
|
664 |
self.weave1 = Weave() |
|
665 |
self.lines1 = ['hello\n'] |
|
666 |
self.lines3 = ['hello\n', 'cruel\n', 'world\n'] |
|
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
667 |
self.weave1.add_lines('v1', [], self.lines1) |
668 |
self.weave1.add_lines('v2', ['v1'], ['hello\n', 'world\n']) |
|
669 |
self.weave1.add_lines('v3', ['v2'], self.lines3) |
|
|
1185.50.23
by John Arbash Meinel
Adding sha1 check when weave extracts a text. |
670 |
|
671 |
def test_written_detection(self): |
|
|
1185.50.29
by John Arbash Meinel
Whitespace and other formatting cleanups suggested by Robert. |
672 |
# Test detection of weave file corruption.
|
673 |
#
|
|
674 |
# Make sure that we can detect if a weave file has
|
|
675 |
# been corrupted. This doesn't test all forms of corruption,
|
|
676 |
# but it at least helps verify the data you get, is what you want.
|
|
|
1185.50.23
by John Arbash Meinel
Adding sha1 check when weave extracts a text. |
677 |
|
678 |
w = Weave() |
|
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
679 |
w.add_lines('v1', [], ['hello\n']) |
680 |
w.add_lines('v2', ['v1'], ['hello\n', 'there\n']) |
|
|
1185.50.23
by John Arbash Meinel
Adding sha1 check when weave extracts a text. |
681 |
|
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
682 |
tmpf = BytesIO() |
|
1185.50.23
by John Arbash Meinel
Adding sha1 check when weave extracts a text. |
683 |
write_weave(w, tmpf) |
684 |
||
685 |
# Because we are corrupting, we need to make sure we have the exact text
|
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
686 |
self.assertEqual('# bzr weave file v5\n' |
|
1185.50.23
by John Arbash Meinel
Adding sha1 check when weave extracts a text. |
687 |
'i\n1 f572d396fae9206628714fb2ce00f72e94f2258f\nn v1\n\n' |
688 |
'i 0\n1 90f265c6e75f1c8f9ab76dcf85528352c5f215ef\nn v2\n\n' |
|
689 |
'w\n{ 0\n. hello\n}\n{ 1\n. there\n}\nW\n', |
|
690 |
tmpf.getvalue()) |
|
691 |
||
692 |
# Change a single letter
|
|
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
693 |
tmpf = BytesIO(b'# bzr weave file v5\n' |
694 |
b'i\n1 f572d396fae9206628714fb2ce00f72e94f2258f\nn v1\n\n' |
|
695 |
b'i 0\n1 90f265c6e75f1c8f9ab76dcf85528352c5f215ef\nn v2\n\n' |
|
696 |
b'w\n{ 0\n. hello\n}\n{ 1\n. There\n}\nW\n') |
|
|
1185.50.23
by John Arbash Meinel
Adding sha1 check when weave extracts a text. |
697 |
|
698 |
w = read_weave(tmpf) |
|
699 |
||
700 |
self.assertEqual('hello\n', w.get_text('v1')) |
|
|
5582.9.20
by Jelmer Vernooij
remove some of the weave changes. |
701 |
self.assertRaises(errors.WeaveInvalidChecksum, w.get_text, 'v2') |
702 |
self.assertRaises(errors.WeaveInvalidChecksum, w.get_lines, 'v2') |
|
703 |
self.assertRaises(errors.WeaveInvalidChecksum, w.check) |
|
|
1185.50.23
by John Arbash Meinel
Adding sha1 check when weave extracts a text. |
704 |
|
705 |
# Change the sha checksum
|
|
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
706 |
tmpf = BytesIO(b'# bzr weave file v5\n' |
707 |
b'i\n1 f572d396fae9206628714fb2ce00f72e94f2258f\nn v1\n\n' |
|
708 |
b'i 0\n1 f0f265c6e75f1c8f9ab76dcf85528352c5f215ef\nn v2\n\n' |
|
709 |
b'w\n{ 0\n. hello\n}\n{ 1\n. there\n}\nW\n') |
|
|
1185.50.23
by John Arbash Meinel
Adding sha1 check when weave extracts a text. |
710 |
|
711 |
w = read_weave(tmpf) |
|
712 |
||
713 |
self.assertEqual('hello\n', w.get_text('v1')) |
|
|
5582.9.20
by Jelmer Vernooij
remove some of the weave changes. |
714 |
self.assertRaises(errors.WeaveInvalidChecksum, w.get_text, 'v2') |
715 |
self.assertRaises(errors.WeaveInvalidChecksum, w.get_lines, 'v2') |
|
716 |
self.assertRaises(errors.WeaveInvalidChecksum, w.check) |
|
|
1185.50.23
by John Arbash Meinel
Adding sha1 check when weave extracts a text. |
717 |
|
718 |
||
|
3514.2.2
by John Arbash Meinel
Restore a real weave merge to 'bzr merge --weave'. |
719 |
class TestWeave(TestCase): |
720 |
||
721 |
def test_allow_reserved_false(self): |
|
722 |
w = Weave('name', allow_reserved=False) |
|
723 |
# Add lines is checked at the WeaveFile level, not at the Weave level
|
|
724 |
w.add_lines('name:', [], TEXT_1) |
|
725 |
# But get_lines is checked at this level
|
|
726 |
self.assertRaises(errors.ReservedId, w.get_lines, 'name:') |
|
727 |
||
728 |
def test_allow_reserved_true(self): |
|
729 |
w = Weave('name', allow_reserved=True) |
|
730 |
w.add_lines('name:', [], TEXT_1) |
|
731 |
self.assertEqual(TEXT_1, w.get_lines('name:')) |
|
732 |
||
733 |
||
|
1551.3.11
by Aaron Bentley
Merge from Robert |
734 |
class InstrumentedWeave(Weave): |
735 |
"""Keep track of how many times functions are called.""" |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
736 |
|
|
1551.3.11
by Aaron Bentley
Merge from Robert |
737 |
def __init__(self, weave_name=None): |
738 |
self._extract_count = 0 |
|
739 |
Weave.__init__(self, weave_name=weave_name) |
|
740 |
||
741 |
def _extract(self, versions): |
|
742 |
self._extract_count += 1 |
|
743 |
return Weave._extract(self, versions) |
|
744 |
||
745 |
||
|
1616.1.18
by Martin Pool
(weave-merge) don't treat killed-both lines as points of agreement; |
746 |
class TestNeedsReweave(TestCase): |
|
1563.2.24
by Robert Collins
Make join cheaper for compatibly inconsistent parents. |
747 |
"""Internal corner cases for when reweave is needed.""" |
748 |
||
749 |
def test_compatible_parents(self): |
|
750 |
w1 = Weave('a') |
|
|
6619.3.12
by Jelmer Vernooij
Use 2to3 set_literal fixer. |
751 |
my_parents = {1, 2, 3} |
|
1563.2.24
by Robert Collins
Make join cheaper for compatibly inconsistent parents. |
752 |
# subsets are ok
|
|
6619.3.12
by Jelmer Vernooij
Use 2to3 set_literal fixer. |
753 |
self.assertTrue(w1._compatible_parents(my_parents, {3})) |
|
1563.2.24
by Robert Collins
Make join cheaper for compatibly inconsistent parents. |
754 |
# same sets
|
755 |
self.assertTrue(w1._compatible_parents(my_parents, set(my_parents))) |
|
756 |
# same empty corner case
|
|
757 |
self.assertTrue(w1._compatible_parents(set(), set())) |
|
758 |
# other cannot contain stuff my_parents does not
|
|
|
6619.3.12
by Jelmer Vernooij
Use 2to3 set_literal fixer. |
759 |
self.assertFalse(w1._compatible_parents(set(), {1})) |
760 |
self.assertFalse(w1._compatible_parents(my_parents, {1, 2, 3, 4})) |
|
761 |
self.assertFalse(w1._compatible_parents(my_parents, {4})) |
|
|
2024.1.1
by John Arbash Meinel
When a weave file is empty, we should get WeaveFormatError, not StopIteration |
762 |
|
763 |
||
764 |
class TestWeaveFile(TestCaseInTempDir): |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
765 |
|
|
2024.1.1
by John Arbash Meinel
When a weave file is empty, we should get WeaveFormatError, not StopIteration |
766 |
def test_empty_file(self): |
767 |
f = open('empty.weave', 'wb+') |
|
768 |
try: |
|
|
5582.9.20
by Jelmer Vernooij
remove some of the weave changes. |
769 |
self.assertRaises(errors.WeaveFormatError, |
770 |
read_weave, f) |
|
|
2024.1.1
by John Arbash Meinel
When a weave file is empty, we should get WeaveFormatError, not StopIteration |
771 |
finally: |
772 |
f.close() |