~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-02-22 14:45:05 UTC
  • mfrom: (2294.1.11 utf8_file_ids)
  • Revision ID: pqm@pqm.ubuntu.com-20070222144505-5f7551602cad9332
(John Arbash Meinel, r=robert) Update apis to expect UTF-8 file ids instead of Unicode

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
164
165
        tt.apply()
165
166
        return self._convert_tree(tree, converter)
166
167
 
 
168
    def get_tree_with_utf8(self, tree):
 
169
        """Generate a tree with a utf8 revision and unicode paths."""
 
170
        self._create_tree_with_utf8(tree)
 
171
        return self.workingtree_to_test_tree(tree)
 
172
 
 
173
    def _create_tree_with_utf8(self, tree):
 
174
        """Generate a tree with a utf8 revision and unicode paths."""
 
175
        paths = [u'',
 
176
                 u'f\xf6',
 
177
                 u'b\xe5r/',
 
178
                 u'b\xe5r/b\xe1z',
 
179
                ]
 
180
        # bzr itself does not create unicode file ids, but we want them for
 
181
        # testing.
 
182
        file_ids = [u'TREE_ROOT',
 
183
                    u'f\xf6-id',
 
184
                    u'b\xe5r-id',
 
185
                    u'b\xe1z-id',
 
186
                   ]
 
187
        try:
 
188
            self.build_tree(paths[1:])
 
189
        except UnicodeError:
 
190
            raise tests.TestSkipped('filesystem does not support unicode.')
 
191
        tree.add(paths, file_ids)
 
192
        try:
 
193
            tree.commit(u'in\xedtial', rev_id=u'r\xe9v-1'.encode('utf8'))
 
194
        except errors.NonAsciiRevisionId:
 
195
            raise tests.TestSkipped('non-ascii revision ids not supported')
 
196
 
 
197
    def get_tree_with_merged_utf8(self, tree):
 
198
        """Generate a tree with utf8 ancestors."""
 
199
        self._create_tree_with_utf8(tree)
 
200
        tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
 
201
        self.build_tree([u'tree2/b\xe5r/z\xf7z'])
 
202
        tree2.add([u'b\xe5r/z\xf7z'], [u'z\xf7z-id'])
 
203
        tree2.commit(u'to m\xe9rge', rev_id=u'r\xe9v-2'.encode('utf8'))
 
204
 
 
205
        tree.merge_from_branch(tree2.branch)
 
206
        tree.commit(u'm\xe9rge', rev_id=u'r\xe9v-3'.encode('utf8'))
 
207
        return self.workingtree_to_test_tree(tree)
 
208
 
167
209
 
168
210
class TreeTestProviderAdapter(WorkingTreeTestProviderAdapter):
169
211
    """Generate test suites for each Tree implementation in bzrlib.