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

  • Committer: Jelmer Vernooij
  • Date: 2019-06-02 02:35:46 UTC
  • mfrom: (7309 work)
  • mto: This revision was merged to the branch mainline in revision 7319.
  • Revision ID: jelmer@jelmer.uk-20190602023546-lqco868tnv26d8ow
merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
129
129
            {'', 'd', 'b', 'b/c'},
130
130
            set(tree.all_versioned_paths()))
131
131
        self.assertEqual(
132
 
            [(p, tree.path2id(p)) for p in ['', 'b', 'd',  'b/c']],
 
132
            [(p, tree.path2id(p)) for p in ['', 'b', 'd', 'b/c']],
133
133
            [(path, node.file_id) for path, node in tree.iter_entries_by_dir()])
134
134
        self.assertEqualDiff(b'bar\n', tree.get_file_text('d'))
135
135
        self.assertFalse(tree.is_executable('b/c'))
141
141
        self.addCleanup(tree.unlock)
142
142
        self.assertEqual([], tree.get_parent_ids())
143
143
        self.assertEqual([], tree.conflicts())
144
 
        if tree.has_versioned_directories() or not tree.has_filename('b'):
145
 
            self.assertEqual([], list(tree.unknowns()))
146
 
        else:
147
 
            self.assertEqual(['b'], list(tree.unknowns()))
 
144
        self.assertEqual([], list(tree.unknowns()))
148
145
        # __iter__ has no strongly defined order
149
146
        expected_paths = (
150
 
                ['', 'a'] +
151
 
                (['b'] if tree.has_versioned_directories() else []) +
152
 
                ['e'])
 
147
            ['', 'a']
 
148
            + (['b'] if tree.has_versioned_directories() else [])
 
149
            + ['e'])
153
150
        self.assertEqual(
154
151
            set(expected_paths),
155
152
            set(tree.all_versioned_paths()))
169
166
        self.addCleanup(tree.unlock)
170
167
        self.assertEqual([], tree.get_parent_ids())
171
168
        self.assertEqual([], tree.conflicts())
172
 
        if tree.has_versioned_directories() or not tree.has_filename('1top-dir/1dir-in-1topdir'):
173
 
            self.assertEqual([], list(tree.unknowns()))
174
 
        else:
175
 
            self.assertEqual(['1top-dir/1dir-in-1topdir'], list(tree.unknowns()))
 
169
        self.assertEqual([], list(tree.unknowns()))
176
170
        # __iter__ has no strongly defined order
177
171
        tree_root = tree.path2id('')
 
172
        try:
 
173
            all_file_ids = set(tree.all_file_ids())
 
174
        except errors.UnsupportedOperation:
 
175
            all_file_ids = None
178
176
        if tree.has_versioned_directories():
179
 
            self.assertEqual(
180
 
                {tree.path2id(p) for p in [
181
 
                    '', '0file', '1top-dir', '1top-dir/1dir-in-1topdir',
182
 
                    '1top-dir/0file-in-1topdir', 'symlink', u'2utf\u1234file']},
183
 
                set(tree.all_file_ids()))
 
177
            if all_file_ids is not None:
 
178
                self.assertEqual(
 
179
                    {tree.path2id(p) for p in [
 
180
                        '', '0file', '1top-dir', '1top-dir/1dir-in-1topdir',
 
181
                        '1top-dir/0file-in-1topdir', 'symlink', u'2utf\u1234file']},
 
182
                    set(tree.all_file_ids()))
184
183
            # note that the order of the paths and fileids is deliberately
185
184
            # mismatched to ensure that the result order is path based.
186
185
            self.assertEqual(
193
192
                 ('1top-dir/1dir-in-1topdir', 'directory')],
194
193
                [(path, node.kind) for path, node in tree.iter_entries_by_dir()])
195
194
        else:
196
 
            self.assertEqual(
197
 
                {tree.path2id(p) for p in [
198
 
                    '', '0file', '1top-dir', 
199
 
                    '1top-dir/0file-in-1topdir', 'symlink', u'2utf\u1234file']},
200
 
                set(tree.all_file_ids()))
 
195
            if all_file_ids is not None:
 
196
                self.assertEqual(
 
197
                    {tree.path2id(p) for p in [
 
198
                        '', '0file', '1top-dir',
 
199
                        '1top-dir/0file-in-1topdir', 'symlink',
 
200
                        u'2utf\u1234file']},
 
201
                    set(tree.all_file_ids()))
201
202
            # note that the order of the paths and fileids is deliberately
202
203
            # mismatched to ensure that the result order is path based.
203
204
            self.assertEqual(
213
214
        # currently this test tree requires unicode. It might be good
214
215
        # to have it simply stop having the single unicode file in it
215
216
        # when dealing with a non-unicode filesystem.
216
 
        tree = self.get_tree_with_subdirs_and_all_supported_content_types(False)
 
217
        tree = self.get_tree_with_subdirs_and_all_supported_content_types(
 
218
            False)
217
219
        tree.lock_read()
218
220
        self.addCleanup(tree.unlock)
219
221
        self.assertEqual([], tree.get_parent_ids())
220
222
        self.assertEqual([], tree.conflicts())
221
 
        if tree.has_versioned_directories() or not tree.has_filename('1top-dir/1dir-in-1topdir'):
222
 
            self.assertEqual([], list(tree.unknowns()))
223
 
        else:
224
 
            self.assertEqual(['1top-dir/1dir-in-1topdir'], list(tree.unknowns()))
 
223
        self.assertEqual([], list(tree.unknowns()))
225
224
        # __iter__ has no strongly defined order
226
225
        tree_root = tree.path2id('')
227
226
        if tree.has_versioned_directories():
265
264
                 u'fo\N{Euro Sign}o',
266
265
                 u'ba\N{Euro Sign}r/',
267
266
                 u'ba\N{Euro Sign}r/ba\N{Euro Sign}z',
268
 
                ]
 
267
                 ]
269
268
        # bzr itself does not create unicode file ids, but we want them for
270
269
        # testing.
271
270
        file_ids = [b'TREE_ROOT',
272
271
                    b'fo\xe2\x82\xaco-id',
273
272
                    b'ba\xe2\x82\xacr-id',
274
273
                    b'ba\xe2\x82\xacz-id',
275
 
                   ]
 
274
                    ]
276
275
        self.build_tree(paths[1:])
277
276
        if tree.get_root_id() is None:
278
277
            # Some trees do not have a root yet.
313
312
                        (u'fo\N{Euro Sign}o', foo_id, root_id, revision_id),
314
313
                        (u'ba\N{Euro Sign}r/ba\N{Euro Sign}z',
315
314
                         baz_id, bar_id, revision_id),
316
 
                       ]
 
315
                        ]
317
316
        with tree.lock_read():
318
317
            path_entries = list(tree.iter_entries_by_dir())
319
318
 
320
319
        for expected, (path, ie) in zip(path_and_ids, path_entries):
321
 
            self.assertEqual(expected[0], path) # Paths should match
 
320
            self.assertEqual(expected[0], path)  # Paths should match
322
321
            self.assertIsInstance(path, text_type)
323
322
            self.assertEqual(expected[1], ie.file_id)
324
323
            self.assertIsInstance(ie.file_id, bytes)
357
356
        else:
358
357
            tree2.commit(u'to m\xe9rge')
359
358
 
360
 
        self.assertTrue(tree2.is_versioned(u'ba\N{Euro Sign}r/qu\N{Euro Sign}x'))
 
359
        self.assertTrue(tree2.is_versioned(
 
360
            u'ba\N{Euro Sign}r/qu\N{Euro Sign}x'))
361
361
        wt.merge_from_branch(tree2.branch)
362
362
        self.assertTrue(wt.is_versioned(u'ba\N{Euro Sign}r/qu\N{Euro Sign}x'))
363
363
 
381
381
                         baz_id, bar_id, revision_id_1),
382
382
                        (u'ba\N{Euro Sign}r/qu\N{Euro Sign}x',
383
383
                         qux_id, bar_id, revision_id_2),
384
 
                       ]
 
384
                        ]
385
385
        with tree.lock_read():
386
386
            path_entries = list(tree.iter_entries_by_dir())
387
387
 
388
388
        for (epath, efid, eparent, erev), (path, ie) in zip(path_and_ids,
389
389
                                                            path_entries):
390
 
            self.assertEqual(epath, path) # Paths should match
 
390
            self.assertEqual(epath, path)  # Paths should match
391
391
            self.assertIsInstance(path, text_type)
392
392
            self.assertIsInstance(ie.file_id, bytes)
393
393
            if wt.supports_setting_file_ids():