/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/tree_implementations/__init__.py

1st cut merge of bzr.dev r3907

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
from bzrlib import (
29
29
    errors,
30
30
    osutils,
 
31
    progress,
31
32
    tests,
32
33
    transform,
33
34
    )
42
43
from bzrlib.tests.workingtree_implementations import (
43
44
    WorkingTreeTestProviderAdapter,
44
45
    )
 
46
from bzrlib.revision import NULL_REVISION
45
47
from bzrlib.revisiontree import RevisionTree
46
48
from bzrlib.transform import TransformPreview
47
49
from bzrlib.workingtree import (
79
81
    return preview_tree
80
82
 
81
83
 
 
84
def preview_tree_post(testcase, tree):
 
85
    basis = tree.basis_tree()
 
86
    tt = TransformPreview(basis)
 
87
    testcase.addCleanup(tt.finalize)
 
88
    pp = progress.ProgressPhase('', 1, progress.DummyProgress())
 
89
    tree.lock_read()
 
90
    testcase.addCleanup(tree.unlock)
 
91
    transform._prepare_revert_transform(basis, tree, tt, None, False, pp,
 
92
                                        basis, {})
 
93
    preview_tree = tt.get_preview_tree()
 
94
    preview_tree.set_parent_ids(tree.get_parent_ids())
 
95
    return preview_tree
 
96
 
 
97
 
82
98
class TestTreeImplementationSupport(TestCaseWithTransport):
83
99
 
84
100
    def test_revision_tree_from_workingtree(self):
265
281
 
266
282
    def _create_tree_with_utf8(self, tree):
267
283
        """Generate a tree with a utf8 revision and unicode paths."""
 
284
        # We avoid combining characters in file names here, normalization
 
285
        # checks (as performed by some file systems (OSX) are outside the scope
 
286
        # of these tests).  We use the euro sign \N{Euro Sign} or \u20ac in
 
287
        # unicode strings or '\xe2\x82\ac' (its utf-8 encoding) in raw strings.
268
288
        paths = [u'',
269
 
                 u'f\xf6',
270
 
                 u'b\xe5r/',
271
 
                 u'b\xe5r/b\xe1z',
 
289
                 u'fo\N{Euro Sign}o',
 
290
                 u'ba\N{Euro Sign}r/',
 
291
                 u'ba\N{Euro Sign}r/ba\N{Euro Sign}z',
272
292
                ]
273
293
        # bzr itself does not create unicode file ids, but we want them for
274
294
        # testing.
275
295
        file_ids = ['TREE_ROOT',
276
 
                    'f\xc3\xb6-id',
277
 
                    'b\xc3\xa5r-id',
278
 
                    'b\xc3\xa1z-id',
 
296
                    'fo\xe2\x82\xaco-id',
 
297
                    'ba\xe2\x82\xacr-id',
 
298
                    'ba\xe2\x82\xacz-id',
279
299
                   ]
280
300
        try:
281
301
            self.build_tree(paths[1:])
297
317
        """Generate a tree with utf8 ancestors."""
298
318
        self._create_tree_with_utf8(tree)
299
319
        tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
300
 
        self.build_tree([u'tree2/b\xe5r/z\xf7z'])
301
 
        tree2.add([u'b\xe5r/z\xf7z'], [u'z\xf7z-id'.encode('utf-8')])
 
320
        self.build_tree([u'tree2/ba\N{Euro Sign}r/qu\N{Euro Sign}x'])
 
321
        tree2.add([u'ba\N{Euro Sign}r/qu\N{Euro Sign}x'],
 
322
                  [u'qu\N{Euro Sign}x-id'.encode('utf-8')])
302
323
        tree2.commit(u'to m\xe9rge', rev_id=u'r\xe9v-2'.encode('utf8'))
303
324
 
304
325
        tree.merge_from_branch(tree2.branch)
336
357
            WorkingTreeFormat4()))
337
358
        self.scenarios.append(self.create_tree_scenario('PreviewTree',
338
359
            preview_tree_pre))
 
360
        self.scenarios.append(self.create_tree_scenario('PreviewTreePost',
 
361
            preview_tree_post))
339
362
 
340
363
    def create_tree_scenario(self, name, converter, workingtree_format=None):
341
364
        """Create a scenario for the specified converter