/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/test_test_trees.py

merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Tests for the test trees used by the tree_implementations tests."""
18
18
 
19
 
from bzrlib.osutils import has_symlinks
20
 
from bzrlib.tests import TestSkipped
21
 
from bzrlib.tests.tree_implementations import TestCaseWithTree
22
 
 
23
 
 
24
 
class TestTreeShapes(TestCaseWithTree):
 
19
from bzrlib import tests
 
20
from bzrlib.tests import tree_implementations
 
21
 
 
22
 
 
23
class TestTreeShapes(tree_implementations.TestCaseWithTree):
25
24
 
26
25
    def test_empty_tree_no_parents(self):
27
26
        tree = self.make_branch_and_tree('.')
52
51
            [('', 'root-id'), ('a', 'a-id'), ('b', 'b-id'), ('b/c', 'c-id')],
53
52
            [(path, node.file_id) for path, node in tree.iter_entries_by_dir()])
54
53
        self.assertEqualDiff('contents of a\n', tree.get_file_text('a-id'))
55
 
        self.assertFalse(tree.is_executable('c-id'))
 
54
        self.assertFalse(tree.is_executable('c-id', path='b/c'))
56
55
 
57
56
    def test_abc_tree_content_2_no_parents(self):
58
57
        tree = self.make_branch_and_tree('.')
148
147
        # currently this test tree requires unicode. It might be good
149
148
        # to have it simply stop having the single unicode file in it
150
149
        # when dealing with a non-unicode filesystem.
151
 
        if not has_symlinks():
152
 
            raise TestSkipped('No symlink support')
 
150
        self.requireFeature(tests.SymlinkFeature)
153
151
        tree = self.get_tree_with_subdirs_and_all_content_types()
154
152
        tree.lock_read()
155
153
        self.addCleanup(tree.unlock)
168
166
                'symlink',
169
167
                 ]),
170
168
            set(iter(tree)))
171
 
        # note that the order of the paths and fileids is deliberately 
 
169
        # note that the order of the paths and fileids is deliberately
172
170
        # mismatched to ensure that the result order is path based.
173
171
        self.assertEqual(
174
172
            [('', tree_root, 'directory'),
201
199
                 u'0utf\u1234file'.encode('utf8'),
202
200
                 ]),
203
201
            set(iter(tree)))
204
 
        # note that the order of the paths and fileids is deliberately 
 
202
        # note that the order of the paths and fileids is deliberately
205
203
        # mismatched to ensure that the result order is path based.
206
204
        self.assertEqual(
207
205
            [('', tree_root, 'directory'),
218
216
 
219
217
        revision_id = u'r\xe9v-1'.encode('utf8')
220
218
        root_id = 'TREE_ROOT'
221
 
        bar_id = u'b\xe5r-id'.encode('utf8')
222
 
        foo_id = u'f\xf6-id'.encode('utf8')
223
 
        baz_id = u'b\xe1z-id'.encode('utf8')
224
 
        path_and_ids = [(u'', root_id, None),
225
 
                        (u'b\xe5r', bar_id, root_id),
226
 
                        (u'f\xf6', foo_id, root_id),
227
 
                        (u'b\xe5r/b\xe1z', baz_id, bar_id),
 
219
        bar_id = u'ba\N{Euro Sign}r-id'.encode('utf8')
 
220
        foo_id = u'fo\N{Euro Sign}o-id'.encode('utf8')
 
221
        baz_id = u'ba\N{Euro Sign}z-id'.encode('utf8')
 
222
        path_and_ids = [(u'', root_id, None, None),
 
223
                        (u'ba\N{Euro Sign}r', bar_id, root_id, revision_id),
 
224
                        (u'fo\N{Euro Sign}o', foo_id, root_id, revision_id),
 
225
                        (u'ba\N{Euro Sign}r/ba\N{Euro Sign}z',
 
226
                         baz_id, bar_id, revision_id),
228
227
                       ]
229
228
        tree.lock_read()
230
229
        try:
262
261
        revision_id_1 = u'r\xe9v-1'.encode('utf8')
263
262
        revision_id_2 = u'r\xe9v-2'.encode('utf8')
264
263
        root_id = 'TREE_ROOT'
265
 
        bar_id = u'b\xe5r-id'.encode('utf8')
266
 
        foo_id = u'f\xf6-id'.encode('utf8')
267
 
        baz_id = u'b\xe1z-id'.encode('utf8')
268
 
        zez_id = u'z\xf7z-id'.encode('utf8')
 
264
        bar_id = u'ba\N{Euro Sign}r-id'.encode('utf8')
 
265
        foo_id = u'fo\N{Euro Sign}o-id'.encode('utf8')
 
266
        baz_id = u'ba\N{Euro Sign}z-id'.encode('utf8')
 
267
        qux_id = u'qu\N{Euro Sign}x-id'.encode('utf8')
269
268
        path_and_ids = [(u'', root_id, None, None),
270
 
                        (u'b\xe5r', bar_id, root_id, revision_id_1),
271
 
                        (u'f\xf6', foo_id, root_id, revision_id_1),
272
 
                        (u'b\xe5r/b\xe1z', baz_id, bar_id, revision_id_1),
273
 
                        (u'b\xe5r/z\xf7z', zez_id, bar_id, revision_id_2),
 
269
                        (u'ba\N{Euro Sign}r', bar_id, root_id, revision_id_1),
 
270
                        (u'fo\N{Euro Sign}o', foo_id, root_id, revision_id_1),
 
271
                        (u'ba\N{Euro Sign}r/ba\N{Euro Sign}z',
 
272
                         baz_id, bar_id, revision_id_1),
 
273
                        (u'ba\N{Euro Sign}r/qu\N{Euro Sign}x',
 
274
                         qux_id, bar_id, revision_id_2),
274
275
                       ]
275
276
        tree.lock_read()
276
277
        try:
278
279
        finally:
279
280
            tree.unlock()
280
281
 
281
 
        for expected, (path, ie) in zip(path_and_ids, path_entries):
282
 
            self.assertEqual(expected[0], path) # Paths should match
 
282
        for (epath, efid, eparent, erev), (path, ie) in zip(path_and_ids,
 
283
                                                            path_entries):
 
284
            self.assertEqual(epath, path) # Paths should match
283
285
            self.assertIsInstance(path, unicode)
284
 
            self.assertEqual(expected[1], ie.file_id)
 
286
            self.assertEqual(efid, ie.file_id)
285
287
            self.assertIsInstance(ie.file_id, str)
286
 
            self.assertEqual(expected[2], ie.parent_id)
287
 
            if expected[2] is not None:
 
288
            self.assertEqual(eparent, ie.parent_id)
 
289
            if eparent is not None:
288
290
                self.assertIsInstance(ie.parent_id, str)
289
291
            # WorkingTree's return None for the last modified revision
290
292
            if ie.revision is not None:
291
293
                self.assertIsInstance(ie.revision, str)
292
 
                if expected[0] == '':
 
294
                if epath == '':
293
295
                    # Some trees will preserve the revision id of the tree root,
294
296
                    # but not all will
295
297
                    continue
296
 
                self.assertEqual(expected[3], ie.revision)
 
298
                self.assertEqual(erev, ie.revision)
297
299
        self.assertEqual(len(path_and_ids), len(path_entries))
298
300
        get_revision_id = getattr(tree, 'get_revision_id', None)
299
301
        if get_revision_id is not None: