/brz/remove-bazaar

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