bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
4988.10.5
by John Arbash Meinel
Merge bzr.dev 5021 to resolve NEWS |
1 |
# Copyright (C) 2006-2010 Canonical Ltd
|
|
1852.6.7
by Robert Collins
Fix up new tree_implementations __init__.py header. |
2 |
#
|
|
1852.6.1
by Robert Collins
Start tree implementation tests. |
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.
|
|
|
1852.6.7
by Robert Collins
Fix up new tree_implementations __init__.py header. |
7 |
#
|
|
1852.6.1
by Robert Collins
Start tree implementation tests. |
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.
|
|
|
1852.6.7
by Robert Collins
Fix up new tree_implementations __init__.py header. |
12 |
#
|
|
1852.6.1
by Robert Collins
Start tree implementation tests. |
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
|
|
1852.6.1
by Robert Collins
Start tree implementation tests. |
16 |
|
17 |
||
18 |
"""Tree implementation tests for bzr.
|
|
19 |
||
20 |
These test the conformance of all the tree variations to the expected API.
|
|
21 |
Specific tests for individual variations are in other places such as:
|
|
|
4523.1.5
by Vincent Ladeuil
Fixed as asked in review. |
22 |
- tests/per_workingtree/*.py.
|
|
1852.6.1
by Robert Collins
Start tree implementation tests. |
23 |
- tests/test_tree.py
|
24 |
- tests/test_revision.py
|
|
25 |
- tests/test_workingtree.py
|
|
26 |
"""
|
|
27 |
||
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
28 |
from bzrlib import ( |
29 |
errors, |
|
|
2309.4.10
by John Arbash Meinel
(fixed) Fix the last few tests that were explicitly passing around unicode ids |
30 |
osutils, |
|
3363.2.17
by Aaron Bentley
Start implementing post-change PreviewTree functionality |
31 |
progress, |
|
2294.1.1
by John Arbash Meinel
Track down some non-ascii deficiencies in commit logic. |
32 |
tests, |
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
33 |
transform, |
34 |
)
|
|
|
4523.1.2
by Martin Pool
Rename bzrdir_implementations to per_bzrdir |
35 |
from bzrlib.tests.per_bzrdir.test_bzrdir import TestCaseWithBzrDir |
|
4523.1.4
by Martin Pool
Rename remaining *_implementations tests |
36 |
from bzrlib.tests.per_workingtree import ( |
|
4084.5.1
by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters. |
37 |
make_scenarios as wt_make_scenarios, |
38 |
make_scenario as wt_make_scenario, |
|
|
2553.2.10
by Robert Collins
And overhaul WorkingTreeTestProviderAdapter too. |
39 |
)
|
|
3363.10.2
by Aaron Bentley
Fake merge of removal of PreviewTreePost scenarios |
40 |
from bzrlib.revision import NULL_REVISION |
|
2079.1.1
by John Arbash Meinel
Create a deprecated bzrlib.tree.RevisionTree() in favor of bzrlib.revisiontree.RevisionTree() |
41 |
from bzrlib.revisiontree import RevisionTree |
|
3363.2.2
by Aaron Bentley
Add PreviewTree pre scenarios |
42 |
from bzrlib.transform import TransformPreview |
|
2255.2.164
by Martin Pool
Change the default format for some tests from AB1 back to WorkingTreeFormat3 |
43 |
from bzrlib.workingtree import ( |
44 |
WorkingTreeFormat, |
|
45 |
WorkingTreeFormat3, |
|
46 |
_legacy_formats, |
|
47 |
)
|
|
|
2255.2.64
by John Arbash Meinel
Add the DirStateRevisionTree to the list of 'tree_implementations' |
48 |
from bzrlib.workingtree_4 import ( |
49 |
DirStateRevisionTree, |
|
50 |
WorkingTreeFormat4, |
|
|
3907.2.3
by Ian Clatworthy
DirStateWorkingTree and DirStateWorkingTreeFormat base classes introduced |
51 |
WorkingTreeFormat5, |
|
2255.2.64
by John Arbash Meinel
Add the DirStateRevisionTree to the list of 'tree_implementations' |
52 |
)
|
|
1852.6.1
by Robert Collins
Start tree implementation tests. |
53 |
|
54 |
||
|
3363.1.2
by Aaron Bentley
Add TestCase as converter param |
55 |
def return_parameter(testcase, something): |
|
1852.6.1
by Robert Collins
Start tree implementation tests. |
56 |
"""A trivial thunk to return its input.""" |
57 |
return something |
|
58 |
||
59 |
||
|
3363.1.2
by Aaron Bentley
Add TestCase as converter param |
60 |
def revision_tree_from_workingtree(testcase, tree): |
|
1852.6.1
by Robert Collins
Start tree implementation tests. |
61 |
"""Create a revision tree from a working tree.""" |
|
2100.3.36
by Aaron Bentley
avoid subtree commit when converting a work tree into a revision tree |
62 |
revid = tree.commit('save tree', allow_pointless=True, recursive=None) |
|
1852.6.1
by Robert Collins
Start tree implementation tests. |
63 |
return tree.branch.repository.revision_tree(revid) |
64 |
||
65 |
||
|
3363.1.2
by Aaron Bentley
Add TestCase as converter param |
66 |
def _dirstate_tree_from_workingtree(testcase, tree): |
|
3504.2.1
by John Arbash Meinel
Shortcut iter_references when we know references aren't supported. |
67 |
revid = tree.commit('save tree', allow_pointless=True, recursive=None) |
|
2255.2.64
by John Arbash Meinel
Add the DirStateRevisionTree to the list of 'tree_implementations' |
68 |
return tree.basis_tree() |
69 |
||
70 |
||
|
3363.2.2
by Aaron Bentley
Add PreviewTree pre scenarios |
71 |
def preview_tree_pre(testcase, tree): |
72 |
tt = TransformPreview(tree) |
|
73 |
testcase.addCleanup(tt.finalize) |
|
|
3363.9.7
by Aaron Bentley
Fix up to use set_parent_ids |
74 |
preview_tree = tt.get_preview_tree() |
75 |
preview_tree.set_parent_ids(tree.get_parent_ids()) |
|
76 |
return preview_tree |
|
|
3363.2.2
by Aaron Bentley
Add PreviewTree pre scenarios |
77 |
|
78 |
||
|
3363.10.2
by Aaron Bentley
Fake merge of removal of PreviewTreePost scenarios |
79 |
def preview_tree_post(testcase, tree): |
|
3363.10.13
by Aaron Bentley
Preserve past commits when converting to a PreviewTreePost |
80 |
basis = tree.basis_tree() |
81 |
tt = TransformPreview(basis) |
|
|
3363.10.2
by Aaron Bentley
Fake merge of removal of PreviewTreePost scenarios |
82 |
testcase.addCleanup(tt.finalize) |
|
3363.10.5
by Aaron Bentley
Fix locking issue |
83 |
tree.lock_read() |
84 |
testcase.addCleanup(tree.unlock) |
|
|
4961.2.9
by Martin Pool
Rip out most remaining uses of DummyProgressBar |
85 |
pp = None |
86 |
transform._prepare_revert_transform(basis, tree, tt, None, False, None, |
|
|
3363.10.13
by Aaron Bentley
Preserve past commits when converting to a PreviewTreePost |
87 |
basis, {}) |
|
3363.10.22
by Aaron Bentley
Fix support for plan_file_merge in PreviewTreePost |
88 |
preview_tree = tt.get_preview_tree() |
89 |
preview_tree.set_parent_ids(tree.get_parent_ids()) |
|
90 |
return preview_tree |
|
|
3363.10.2
by Aaron Bentley
Fake merge of removal of PreviewTreePost scenarios |
91 |
|
92 |
||
|
4285.2.1
by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests. |
93 |
class TestTreeImplementationSupport(tests.TestCaseWithTransport): |
|
1852.6.1
by Robert Collins
Start tree implementation tests. |
94 |
|
95 |
def test_revision_tree_from_workingtree(self): |
|
96 |
tree = self.make_branch_and_tree('.') |
|
|
3363.1.3
by Aaron Bentley
Hide workingtree_to_test_tree behind a method, to get bound self |
97 |
tree = revision_tree_from_workingtree(self, tree) |
|
1852.6.1
by Robert Collins
Start tree implementation tests. |
98 |
self.assertIsInstance(tree, RevisionTree) |
99 |
||
100 |
||
101 |
class TestCaseWithTree(TestCaseWithBzrDir): |
|
102 |
||
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
103 |
def make_branch_and_tree(self, relpath): |
104 |
made_control = self.make_bzrdir(relpath, format= |
|
105 |
self.workingtree_format._matchingbzrdir) |
|
|
1852.6.1
by Robert Collins
Start tree implementation tests. |
106 |
made_control.create_repository() |
107 |
made_control.create_branch() |
|
108 |
return self.workingtree_format.initialize(made_control) |
|
109 |
||
|
3363.1.3
by Aaron Bentley
Hide workingtree_to_test_tree behind a method, to get bound self |
110 |
def workingtree_to_test_tree(self, tree): |
111 |
return self._workingtree_to_test_tree(self, tree) |
|
112 |
||
|
1852.8.7
by Robert Collins
Update tree_implementation test tree factories to be intertree ready. |
113 |
def _convert_tree(self, tree, converter=None): |
114 |
"""helper to convert using the converter or a supplied one.""" |
|
115 |
# convert that to the final shape
|
|
116 |
if converter is None: |
|
117 |
converter = self.workingtree_to_test_tree |
|
|
3363.1.3
by Aaron Bentley
Hide workingtree_to_test_tree behind a method, to get bound self |
118 |
return converter(tree) |
|
1852.8.7
by Robert Collins
Update tree_implementation test tree factories to be intertree ready. |
119 |
|
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
120 |
def get_tree_no_parents_no_content(self, empty_tree, converter=None): |
121 |
"""Make a tree with no parents and no contents from empty_tree. |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
122 |
|
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
123 |
:param empty_tree: A working tree with no content and no parents to
|
124 |
modify.
|
|
125 |
"""
|
|
|
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
126 |
empty_tree.set_root_id('empty-root-id') |
|
1852.8.7
by Robert Collins
Update tree_implementation test tree factories to be intertree ready. |
127 |
return self._convert_tree(empty_tree, converter) |
|
1852.6.1
by Robert Collins
Start tree implementation tests. |
128 |
|
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
129 |
def _make_abc_tree(self, tree): |
130 |
"""setup an abc content tree.""" |
|
131 |
files = ['a', 'b/', 'b/c'] |
|
|
2255.2.15
by Robert Collins
Dirstate - truncate state file fixing bug in saving a smaller file, get more tree_implementation tests passing. |
132 |
self.build_tree(files, line_endings='binary', |
|
1982.1.4
by Alexander Belchenko
tree_implementations tests: build_tree with binary (LF) line-endings |
133 |
transport=tree.bzrdir.root_transport) |
|
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
134 |
tree.set_root_id('root-id') |
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
135 |
tree.add(files, ['a-id', 'b-id', 'c-id']) |
136 |
||
|
1852.8.7
by Robert Collins
Update tree_implementation test tree factories to be intertree ready. |
137 |
def get_tree_no_parents_abc_content(self, tree, converter=None): |
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
138 |
"""return a test tree with a, b/, b/c contents.""" |
139 |
self._make_abc_tree(tree) |
|
|
1852.8.7
by Robert Collins
Update tree_implementation test tree factories to be intertree ready. |
140 |
return self._convert_tree(tree, converter) |
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
141 |
|
|
1852.8.7
by Robert Collins
Update tree_implementation test tree factories to be intertree ready. |
142 |
def get_tree_no_parents_abc_content_2(self, tree, converter=None): |
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
143 |
"""return a test tree with a, b/, b/c contents. |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
144 |
|
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
145 |
This variation changes the content of 'a' to foobar\n.
|
146 |
"""
|
|
147 |
self._make_abc_tree(tree) |
|
148 |
f = open(tree.basedir + '/a', 'wb') |
|
149 |
try: |
|
150 |
f.write('foobar\n') |
|
151 |
finally: |
|
152 |
f.close() |
|
|
1852.8.7
by Robert Collins
Update tree_implementation test tree factories to be intertree ready. |
153 |
return self._convert_tree(tree, converter) |
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
154 |
|
|
1852.8.7
by Robert Collins
Update tree_implementation test tree factories to be intertree ready. |
155 |
def get_tree_no_parents_abc_content_3(self, tree, converter=None): |
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
156 |
"""return a test tree with a, b/, b/c contents. |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
157 |
|
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
158 |
This variation changes the executable flag of b/c to True.
|
159 |
"""
|
|
160 |
self._make_abc_tree(tree) |
|
161 |
tt = transform.TreeTransform(tree) |
|
162 |
trans_id = tt.trans_id_tree_path('b/c') |
|
163 |
tt.set_executability(True, trans_id) |
|
164 |
tt.apply() |
|
|
1852.8.7
by Robert Collins
Update tree_implementation test tree factories to be intertree ready. |
165 |
return self._convert_tree(tree, converter) |
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
166 |
|
|
1852.8.7
by Robert Collins
Update tree_implementation test tree factories to be intertree ready. |
167 |
def get_tree_no_parents_abc_content_4(self, tree, converter=None): |
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
168 |
"""return a test tree with d, b/, b/c contents. |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
169 |
|
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
170 |
This variation renames a to d.
|
171 |
"""
|
|
172 |
self._make_abc_tree(tree) |
|
173 |
tree.rename_one('a', 'd') |
|
|
1852.8.7
by Robert Collins
Update tree_implementation test tree factories to be intertree ready. |
174 |
return self._convert_tree(tree, converter) |
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
175 |
|
|
1852.8.7
by Robert Collins
Update tree_implementation test tree factories to be intertree ready. |
176 |
def get_tree_no_parents_abc_content_5(self, tree, converter=None): |
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
177 |
"""return a test tree with d, b/, b/c contents. |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
178 |
|
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
179 |
This variation renames a to d and alters its content to 'bar\n'.
|
180 |
"""
|
|
181 |
self._make_abc_tree(tree) |
|
182 |
tree.rename_one('a', 'd') |
|
183 |
f = open(tree.basedir + '/d', 'wb') |
|
184 |
try: |
|
185 |
f.write('bar\n') |
|
186 |
finally: |
|
187 |
f.close() |
|
|
1852.8.7
by Robert Collins
Update tree_implementation test tree factories to be intertree ready. |
188 |
return self._convert_tree(tree, converter) |
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
189 |
|
|
1852.8.7
by Robert Collins
Update tree_implementation test tree factories to be intertree ready. |
190 |
def get_tree_no_parents_abc_content_6(self, tree, converter=None): |
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
191 |
"""return a test tree with a, b/, e contents. |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
192 |
|
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
193 |
This variation renames b/c to e, and makes it executable.
|
194 |
"""
|
|
195 |
self._make_abc_tree(tree) |
|
196 |
tt = transform.TreeTransform(tree) |
|
197 |
trans_id = tt.trans_id_tree_path('b/c') |
|
198 |
parent_trans_id = tt.trans_id_tree_path('') |
|
199 |
tt.adjust_path('e', parent_trans_id, trans_id) |
|
200 |
tt.set_executability(True, trans_id) |
|
201 |
tt.apply() |
|
|
1852.8.7
by Robert Collins
Update tree_implementation test tree factories to be intertree ready. |
202 |
return self._convert_tree(tree, converter) |
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
203 |
|
|
4570.2.3
by Robert Collins
Change the way iter_changes treats specific files to prevent InconsistentDeltas. |
204 |
def get_tree_no_parents_abc_content_7(self, tree, converter=None): |
205 |
"""return a test tree with a, b/, d/e contents. |
|
206 |
||
207 |
This variation adds a dir 'd' ('d-id'), renames b to d/e.
|
|
208 |
"""
|
|
209 |
self._make_abc_tree(tree) |
|
210 |
self.build_tree(['d/'], transport=tree.bzrdir.root_transport) |
|
211 |
tree.add(['d'], ['d-id']) |
|
212 |
tt = transform.TreeTransform(tree) |
|
213 |
trans_id = tt.trans_id_tree_path('b') |
|
214 |
parent_trans_id = tt.trans_id_tree_path('d') |
|
215 |
tt.adjust_path('e', parent_trans_id, trans_id) |
|
216 |
tt.apply() |
|
217 |
return self._convert_tree(tree, converter) |
|
218 |
||
|
1852.15.1
by Robert Collins
Add a complex test tree for use with Tree.walkdirs. |
219 |
def get_tree_with_subdirs_and_all_content_types(self): |
220 |
"""Return a test tree with subdirs and all content types. |
|
|
2408.1.3
by Alexander Belchenko
tree_implementations: make usage of symlinks optional |
221 |
See get_tree_with_subdirs_and_all_supported_content_types for details.
|
222 |
"""
|
|
|
2408.1.8
by Alexander Belchenko
forget to return tree |
223 |
return self.get_tree_with_subdirs_and_all_supported_content_types(True) |
|
2408.1.3
by Alexander Belchenko
tree_implementations: make usage of symlinks optional |
224 |
|
225 |
def get_tree_with_subdirs_and_all_supported_content_types(self, symlinks): |
|
226 |
"""Return a test tree with subdirs and all supported content types. |
|
227 |
Some content types may not be created on some platforms
|
|
228 |
(like symlinks on native win32)
|
|
229 |
||
230 |
:param symlinks: control is symlink should be created in the tree.
|
|
231 |
Note: if you wish to automatically set this
|
|
232 |
parameters depending on underlying system,
|
|
233 |
please use value returned
|
|
234 |
by bzrlib.osutils.has_symlinks() function.
|
|
|
1852.15.1
by Robert Collins
Add a complex test tree for use with Tree.walkdirs. |
235 |
|
236 |
The returned tree has the following inventory:
|
|
237 |
[('', inventory.ROOT_ID),
|
|
238 |
('0file', '2file'),
|
|
239 |
('1top-dir', '1top-dir'),
|
|
240 |
(u'2utf\u1234file', u'0utf\u1234file'),
|
|
|
2408.1.3
by Alexander Belchenko
tree_implementations: make usage of symlinks optional |
241 |
('symlink', 'symlink'), # only if symlinks arg is True
|
|
1852.15.1
by Robert Collins
Add a complex test tree for use with Tree.walkdirs. |
242 |
('1top-dir/0file-in-1topdir', '1file-in-1topdir'),
|
243 |
('1top-dir/1dir-in-1topdir', '0dir-in-1topdir')]
|
|
|
2408.1.3
by Alexander Belchenko
tree_implementations: make usage of symlinks optional |
244 |
where each component has the type of its name -
|
245 |
i.e. '1file..' is afile.
|
|
|
1852.15.1
by Robert Collins
Add a complex test tree for use with Tree.walkdirs. |
246 |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
247 |
note that the order of the paths and fileids is deliberately
|
|
1852.15.1
by Robert Collins
Add a complex test tree for use with Tree.walkdirs. |
248 |
mismatched to ensure that the result order is path based.
|
249 |
"""
|
|
|
4285.2.1
by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests. |
250 |
self.requireFeature(tests.UnicodeFilenameFeature) |
|
1852.15.1
by Robert Collins
Add a complex test tree for use with Tree.walkdirs. |
251 |
tree = self.make_branch_and_tree('.') |
252 |
paths = ['0file', |
|
253 |
'1top-dir/', |
|
254 |
u'2utf\u1234file', |
|
255 |
'1top-dir/0file-in-1topdir', |
|
256 |
'1top-dir/1dir-in-1topdir/'
|
|
257 |
]
|
|
258 |
ids = [ |
|
259 |
'2file', |
|
260 |
'1top-dir', |
|
|
2255.2.107
by John Arbash Meinel
(working), fix dirstate to use utf8 file ids. |
261 |
u'0utf\u1234file'.encode('utf8'), |
|
1852.15.1
by Robert Collins
Add a complex test tree for use with Tree.walkdirs. |
262 |
'1file-in-1topdir', |
263 |
'0dir-in-1topdir'
|
|
264 |
]
|
|
|
4285.2.1
by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests. |
265 |
self.build_tree(paths) |
|
1852.15.1
by Robert Collins
Add a complex test tree for use with Tree.walkdirs. |
266 |
tree.add(paths, ids) |
267 |
tt = transform.TreeTransform(tree) |
|
|
2408.1.3
by Alexander Belchenko
tree_implementations: make usage of symlinks optional |
268 |
if symlinks: |
269 |
root_transaction_id = tt.trans_id_tree_path('') |
|
270 |
tt.new_symlink('symlink', |
|
271 |
root_transaction_id, 'link-target', 'symlink') |
|
|
1852.15.1
by Robert Collins
Add a complex test tree for use with Tree.walkdirs. |
272 |
tt.apply() |
273 |
return self.workingtree_to_test_tree(tree) |
|
274 |
||
|
2294.1.1
by John Arbash Meinel
Track down some non-ascii deficiencies in commit logic. |
275 |
def get_tree_with_utf8(self, tree): |
276 |
"""Generate a tree with a utf8 revision and unicode paths.""" |
|
|
2294.1.2
by John Arbash Meinel
Track down and add tests that all tree.commit() can handle |
277 |
self._create_tree_with_utf8(tree) |
278 |
return self.workingtree_to_test_tree(tree) |
|
279 |
||
280 |
def _create_tree_with_utf8(self, tree): |
|
281 |
"""Generate a tree with a utf8 revision and unicode paths.""" |
|
|
4285.2.1
by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests. |
282 |
self.requireFeature(tests.UnicodeFilenameFeature) |
|
3638.3.11
by Vincent Ladeuil
Fix failing tests by avoiding unicode combinig encodings (we test |
283 |
# We avoid combining characters in file names here, normalization
|
284 |
# checks (as performed by some file systems (OSX) are outside the scope
|
|
285 |
# of these tests). We use the euro sign \N{Euro Sign} or \u20ac in
|
|
286 |
# unicode strings or '\xe2\x82\ac' (its utf-8 encoding) in raw strings.
|
|
|
2294.1.3
by John Arbash Meinel
Make sure the inventory enrtries returned are properly formed. |
287 |
paths = [u'', |
|
3638.3.11
by Vincent Ladeuil
Fix failing tests by avoiding unicode combinig encodings (we test |
288 |
u'fo\N{Euro Sign}o', |
289 |
u'ba\N{Euro Sign}r/', |
|
290 |
u'ba\N{Euro Sign}r/ba\N{Euro Sign}z', |
|
|
2294.1.1
by John Arbash Meinel
Track down some non-ascii deficiencies in commit logic. |
291 |
]
|
292 |
# bzr itself does not create unicode file ids, but we want them for
|
|
293 |
# testing.
|
|
|
2309.4.10
by John Arbash Meinel
(fixed) Fix the last few tests that were explicitly passing around unicode ids |
294 |
file_ids = ['TREE_ROOT', |
|
3638.3.11
by Vincent Ladeuil
Fix failing tests by avoiding unicode combinig encodings (we test |
295 |
'fo\xe2\x82\xaco-id', |
296 |
'ba\xe2\x82\xacr-id', |
|
297 |
'ba\xe2\x82\xacz-id', |
|
|
2294.1.1
by John Arbash Meinel
Track down some non-ascii deficiencies in commit logic. |
298 |
]
|
|
4285.2.1
by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests. |
299 |
self.build_tree(paths[1:]) |
|
2946.3.3
by John Arbash Meinel
Prefer tree.get_root_id() as more explicit than tree.path2id('') |
300 |
if tree.get_root_id() is None: |
|
2255.2.107
by John Arbash Meinel
(working), fix dirstate to use utf8 file ids. |
301 |
# Some trees do not have a root yet.
|
302 |
tree.add(paths, file_ids) |
|
303 |
else: |
|
304 |
# Some trees will already have a root
|
|
305 |
tree.set_root_id(file_ids[0]) |
|
306 |
tree.add(paths[1:], file_ids[1:]) |
|
|
2294.1.1
by John Arbash Meinel
Track down some non-ascii deficiencies in commit logic. |
307 |
try: |
308 |
tree.commit(u'in\xedtial', rev_id=u'r\xe9v-1'.encode('utf8')) |
|
309 |
except errors.NonAsciiRevisionId: |
|
310 |
raise tests.TestSkipped('non-ascii revision ids not supported') |
|
|
2294.1.2
by John Arbash Meinel
Track down and add tests that all tree.commit() can handle |
311 |
|
312 |
def get_tree_with_merged_utf8(self, tree): |
|
313 |
"""Generate a tree with utf8 ancestors.""" |
|
314 |
self._create_tree_with_utf8(tree) |
|
315 |
tree2 = tree.bzrdir.sprout('tree2').open_workingtree() |
|
|
3638.3.11
by Vincent Ladeuil
Fix failing tests by avoiding unicode combinig encodings (we test |
316 |
self.build_tree([u'tree2/ba\N{Euro Sign}r/qu\N{Euro Sign}x']) |
317 |
tree2.add([u'ba\N{Euro Sign}r/qu\N{Euro Sign}x'], |
|
318 |
[u'qu\N{Euro Sign}x-id'.encode('utf-8')]) |
|
|
2294.1.2
by John Arbash Meinel
Track down and add tests that all tree.commit() can handle |
319 |
tree2.commit(u'to m\xe9rge', rev_id=u'r\xe9v-2'.encode('utf8')) |
320 |
||
321 |
tree.merge_from_branch(tree2.branch) |
|
322 |
tree.commit(u'm\xe9rge', rev_id=u'r\xe9v-3'.encode('utf8')) |
|
|
2294.1.1
by John Arbash Meinel
Track down some non-ascii deficiencies in commit logic. |
323 |
return self.workingtree_to_test_tree(tree) |
324 |
||
|
1852.6.1
by Robert Collins
Start tree implementation tests. |
325 |
|
|
4084.5.1
by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters. |
326 |
def make_scenarios(transport_server, transport_readonly_server, formats): |
|
1852.6.1
by Robert Collins
Start tree implementation tests. |
327 |
"""Generate test suites for each Tree implementation in bzrlib. |
328 |
||
|
2553.2.10
by Robert Collins
And overhaul WorkingTreeTestProviderAdapter too. |
329 |
Currently this covers all working tree formats, and RevisionTree and
|
330 |
DirStateRevisionTree by committing a working tree to create the revision
|
|
331 |
tree.
|
|
|
1852.6.1
by Robert Collins
Start tree implementation tests. |
332 |
"""
|
|
4084.5.1
by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters. |
333 |
scenarios = wt_make_scenarios(transport_server, transport_readonly_server, |
334 |
formats) |
|
335 |
# now adjust the scenarios and add the non-working-tree tree scenarios.
|
|
336 |
for scenario in scenarios: |
|
337 |
# for working tree format tests, preserve the tree
|
|
338 |
scenario[1]["_workingtree_to_test_tree"] = return_parameter |
|
|
4285.2.1
by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests. |
339 |
# add RevisionTree scenario
|
|
4084.5.1
by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters. |
340 |
workingtree_format = WorkingTreeFormat._default_format |
341 |
scenarios.append((RevisionTree.__name__, |
|
342 |
create_tree_scenario(transport_server, transport_readonly_server, |
|
343 |
workingtree_format, revision_tree_from_workingtree,))) |
|
344 |
||
345 |
# also test WorkingTree4/5's RevisionTree implementation which is
|
|
346 |
# specialised.
|
|
347 |
# XXX: Ask igc if WT5 revision tree actually is different.
|
|
348 |
scenarios.append((DirStateRevisionTree.__name__ + ",WT4", |
|
349 |
create_tree_scenario(transport_server, transport_readonly_server, |
|
350 |
WorkingTreeFormat4(), _dirstate_tree_from_workingtree))) |
|
351 |
scenarios.append((DirStateRevisionTree.__name__ + ",WT5", |
|
352 |
create_tree_scenario(transport_server, transport_readonly_server, |
|
353 |
WorkingTreeFormat5(), _dirstate_tree_from_workingtree))) |
|
354 |
scenarios.append(("PreviewTree", create_tree_scenario(transport_server, |
|
355 |
transport_readonly_server, workingtree_format, preview_tree_pre))) |
|
356 |
scenarios.append(("PreviewTreePost", create_tree_scenario(transport_server, |
|
357 |
transport_readonly_server, workingtree_format, preview_tree_post))) |
|
358 |
return scenarios |
|
359 |
||
360 |
||
361 |
def create_tree_scenario(transport_server, transport_readonly_server, |
|
362 |
workingtree_format, converter): |
|
363 |
"""Create a scenario for the specified converter |
|
364 |
||
365 |
:param converter: A function that converts a workingtree into the
|
|
366 |
desired format.
|
|
367 |
:param workingtree_format: The particular workingtree format to
|
|
368 |
convert from.
|
|
369 |
:return: a (name, options) tuple, where options is a dict of values
|
|
370 |
to be used as members of the TestCase.
|
|
371 |
"""
|
|
|
4285.2.1
by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests. |
372 |
scenario_options = wt_make_scenario(transport_server, |
373 |
transport_readonly_server, |
|
374 |
workingtree_format) |
|
|
4084.5.1
by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters. |
375 |
scenario_options["_workingtree_to_test_tree"] = converter |
376 |
return scenario_options |
|
377 |
||
378 |
||
379 |
def load_tests(standard_tests, module, loader): |
|
|
4523.1.5
by Vincent Ladeuil
Fixed as asked in review. |
380 |
per_tree_mod_names = [ |
381 |
'annotate_iter', |
|
382 |
'get_file_mtime', |
|
383 |
'get_file_with_stat', |
|
384 |
'get_root_id', |
|
385 |
'get_symlink_target', |
|
386 |
'inv', |
|
387 |
'iter_search_rules', |
|
388 |
'list_files', |
|
|
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
389 |
'locking', |
|
4523.1.5
by Vincent Ladeuil
Fixed as asked in review. |
390 |
'path_content_summary', |
391 |
'revision_tree', |
|
392 |
'test_trees', |
|
393 |
'tree', |
|
394 |
'walkdirs', |
|
395 |
]
|
|
396 |
submod_tests = loader.loadTestsFromModuleNames( |
|
397 |
['bzrlib.tests.per_tree.test_' + name |
|
398 |
for name in per_tree_mod_names]) |
|
|
4084.5.1
by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters. |
399 |
scenarios = make_scenarios( |
|
4285.2.1
by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests. |
400 |
tests.default_transport, |
|
1852.6.1
by Robert Collins
Start tree implementation tests. |
401 |
# None here will cause a readonly decorator to be created
|
402 |
# by the TestCaseWithTransport.get_readonly_transport method.
|
|
403 |
None, |
|
|
3543.1.1
by Michael Hudson
change the scenario multiplication to get the bzrdir format from the tree and |
404 |
WorkingTreeFormat._formats.values() + _legacy_formats) |
|
3302.9.27
by Vincent Ladeuil
Fixed as per Ian's review. |
405 |
# add the tests for the sub modules
|
|
4285.2.1
by Vincent Ladeuil
Cleanup test imports and use features to better track skipped tests. |
406 |
return tests.multiply_tests(submod_tests, scenarios, standard_tests) |