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