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

  • Committer: Jelmer Vernooij
  • Date: 2019-03-04 00:16:27 UTC
  • mfrom: (7293 work)
  • mto: This revision was merged to the branch mainline in revision 7318.
  • Revision ID: jelmer@jelmer.uk-20190304001627-v6u7o6pf97tukhek
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
        self.build_tree_contents([('wta/file', b'b\nc\nd\ne\n')])
58
58
        tree_a = self.workingtree_to_test_tree(work_a)
59
59
        if getattr(tree_a, 'plan_file_merge', None) is None:
60
 
            raise tests.TestNotApplicable('Tree does not support plan_file_merge')
 
60
            raise tests.TestNotApplicable(
 
61
                'Tree does not support plan_file_merge')
61
62
        tree_a.lock_read()
62
63
        self.addCleanup(tree_a.unlock)
63
64
        self.build_tree_contents([('wtb/file', b'a\nc\nd\nf\n')])
146
147
        tree = self.get_tree_no_parents_abc_content(work_tree)
147
148
        tree.lock_read()
148
149
        self.addCleanup(tree.unlock)
149
 
        self.assertEqual(tree.all_file_ids(),
150
 
                         {tree.path2id('a'), tree.path2id(''),
151
 
                          tree.path2id('b'), tree.path2id('b/c')})
 
150
        try:
 
151
            self.assertEqual(tree.all_file_ids(),
 
152
                             {tree.path2id('a'), tree.path2id(''),
 
153
                              tree.path2id('b'), tree.path2id('b/c')})
 
154
        except errors.UnsupportedOperation:
 
155
            raise tests.TestNotApplicable(
 
156
                'Tree does not support all_file_ids')
152
157
 
153
158
 
154
159
class TestStoredKind(TestCaseWithTree):
178
183
            self.assertEqual([b'foobar\n'], lines)
179
184
        finally:
180
185
            file_without_path.close()
181
 
        # Test lookup with path works
182
 
        file_with_path = tree.get_file('a', a_id)
183
 
        try:
184
 
            lines = file_with_path.readlines()
185
 
            self.assertEqual([b'foobar\n'], lines)
186
 
        finally:
187
 
            file_with_path.close()
188
186
 
189
187
    def test_get_file_context_manager(self):
190
188
        work_tree = self.make_branch_and_tree('wt')
201
199
        a_id = tree.path2id('a')
202
200
        tree.lock_read()
203
201
        self.addCleanup(tree.unlock)
204
 
        # test read by file-id
205
 
        self.assertEqual(b'foobar\n', tree.get_file_text('a', a_id))
206
202
        # test read by path
207
203
        self.assertEqual(b'foobar\n', tree.get_file_text('a'))
208
204
 
212
208
        a_id = tree.path2id('a')
213
209
        tree.lock_read()
214
210
        self.addCleanup(tree.unlock)
215
 
        # test read by file-id
216
 
        self.assertEqual([b'foobar\n'], tree.get_file_lines('a', a_id))
217
211
        # test read by path
218
212
        self.assertEqual([b'foobar\n'], tree.get_file_lines('a'))
219
213
 
248
242
        self.assertEqual(b'baz', extracted['id3'])
249
243
        self.assertRaises(errors.NoSuchFile, lambda: list(
250
244
                          tree.iter_files_bytes(
251
 
                          [('qux', 'file1-notpresent')])))
 
245
                              [('qux', 'file1-notpresent')])))
252
246
 
253
247
 
254
248
class TestConflicts(TestCaseWithTree):
279
273
        self.build_tree(['a/', 'a/b/', 'a/b/c', 'a/d/', 'a/d/e', 'f/', 'f/g'])
280
274
        work_tree.add(['a', 'a/b', 'a/b/c', 'a/d', 'a/d/e', 'f', 'f/g'])
281
275
        tree = self._convert_tree(work_tree)
282
 
        output = [e.name for e in
283
 
            tree.iter_child_entries('', tree.get_root_id())]
 
276
        output = [e.name for e in tree.iter_child_entries('')]
284
277
        self.assertEqual({'a', 'f'}, set(output))
285
 
        output = [e.name for e in
286
 
            tree.iter_child_entries('a', tree.path2id('a'))]
 
278
        output = [e.name for e in tree.iter_child_entries('a')]
287
279
        self.assertEqual({'b', 'd'}, set(output))
288
280
 
289
281
    def test_does_not_exist(self):
292
284
        work_tree.add(['a'])
293
285
        tree = self._convert_tree(work_tree)
294
286
        self.assertRaises(errors.NoSuchFile, lambda:
295
 
            list(tree.iter_child_entries('unknown')))
 
287
                          list(tree.iter_child_entries('unknown')))
296
288
 
297
289
 
298
290
class TestHasId(TestCaseWithTree):