/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

mergeĀ fromĀ dirstate

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006, 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
27
27
 
28
28
from bzrlib import (
29
29
    errors,
 
30
    tests,
30
31
    transform,
31
32
    )
32
33
from bzrlib.transport import get_transport
200
201
        ids = [
201
202
            '2file',
202
203
            '1top-dir',
203
 
            u'0utf\u1234file',
 
204
            u'0utf\u1234file'.encode('utf8'),
204
205
            '1file-in-1topdir',
205
206
            '0dir-in-1topdir'
206
207
            ]
213
214
        tt.apply()
214
215
        return self.workingtree_to_test_tree(tree)
215
216
 
 
217
    def get_tree_with_utf8(self, tree):
 
218
        """Generate a tree with a utf8 revision and unicode paths."""
 
219
        self._create_tree_with_utf8(tree)
 
220
        return self.workingtree_to_test_tree(tree)
 
221
 
 
222
    def _create_tree_with_utf8(self, tree):
 
223
        """Generate a tree with a utf8 revision and unicode paths."""
 
224
        paths = [u'',
 
225
                 u'f\xf6',
 
226
                 u'b\xe5r/',
 
227
                 u'b\xe5r/b\xe1z',
 
228
                ]
 
229
        # bzr itself does not create unicode file ids, but we want them for
 
230
        # testing.
 
231
        file_ids = [u'TREE_ROOT',
 
232
                    u'f\xf6-id'.encode('utf8'),
 
233
                    u'b\xe5r-id'.encode('utf8'),
 
234
                    u'b\xe1z-id'.encode('utf8'),
 
235
                   ]
 
236
        try:
 
237
            self.build_tree(paths[1:])
 
238
        except UnicodeError:
 
239
            raise tests.TestSkipped('filesystem does not support unicode.')
 
240
        if tree.path2id('') is None:
 
241
            # Some trees do not have a root yet.
 
242
            tree.add(paths, file_ids)
 
243
        else:
 
244
            # Some trees will already have a root
 
245
            tree.set_root_id(file_ids[0])
 
246
            tree.add(paths[1:], file_ids[1:])
 
247
        try:
 
248
            tree.commit(u'in\xedtial', rev_id=u'r\xe9v-1'.encode('utf8'))
 
249
        except errors.NonAsciiRevisionId:
 
250
            raise tests.TestSkipped('non-ascii revision ids not supported')
 
251
 
 
252
    def get_tree_with_merged_utf8(self, tree):
 
253
        """Generate a tree with utf8 ancestors."""
 
254
        self._create_tree_with_utf8(tree)
 
255
        tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
 
256
        self.build_tree([u'tree2/b\xe5r/z\xf7z'])
 
257
        tree2.add([u'b\xe5r/z\xf7z'], [u'z\xf7z-id'.encode('utf8')])
 
258
        tree2.commit(u'to m\xe9rge', rev_id=u'r\xe9v-2'.encode('utf8'))
 
259
 
 
260
        tree.merge_from_branch(tree2.branch)
 
261
        tree.commit(u'm\xe9rge', rev_id=u'r\xe9v-3'.encode('utf8'))
 
262
        return self.workingtree_to_test_tree(tree)
 
263
 
216
264
 
217
265
class TreeTestProviderAdapter(WorkingTreeTestProviderAdapter):
218
266
    """Generate test suites for each Tree implementation in bzrlib.