/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: 2018-11-16 23:15:15 UTC
  • mfrom: (7180 work)
  • mto: This revision was merged to the branch mainline in revision 7183.
  • Revision ID: jelmer@jelmer.uk-20181116231515-zqd2yn6kj8lfydyp
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')])
178
179
            self.assertEqual([b'foobar\n'], lines)
179
180
        finally:
180
181
            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
182
 
189
183
    def test_get_file_context_manager(self):
190
184
        work_tree = self.make_branch_and_tree('wt')
201
195
        a_id = tree.path2id('a')
202
196
        tree.lock_read()
203
197
        self.addCleanup(tree.unlock)
204
 
        # test read by file-id
205
 
        self.assertEqual(b'foobar\n', tree.get_file_text('a', a_id))
206
198
        # test read by path
207
199
        self.assertEqual(b'foobar\n', tree.get_file_text('a'))
208
200
 
212
204
        a_id = tree.path2id('a')
213
205
        tree.lock_read()
214
206
        self.addCleanup(tree.unlock)
215
 
        # test read by file-id
216
 
        self.assertEqual([b'foobar\n'], tree.get_file_lines('a', a_id))
217
207
        # test read by path
218
208
        self.assertEqual([b'foobar\n'], tree.get_file_lines('a'))
219
209
 
248
238
        self.assertEqual(b'baz', extracted['id3'])
249
239
        self.assertRaises(errors.NoSuchFile, lambda: list(
250
240
                          tree.iter_files_bytes(
251
 
                          [('qux', 'file1-notpresent')])))
 
241
                              [('qux', 'file1-notpresent')])))
252
242
 
253
243
 
254
244
class TestConflicts(TestCaseWithTree):
279
269
        self.build_tree(['a/', 'a/b/', 'a/b/c', 'a/d/', 'a/d/e', 'f/', 'f/g'])
280
270
        work_tree.add(['a', 'a/b', 'a/b/c', 'a/d', 'a/d/e', 'f', 'f/g'])
281
271
        tree = self._convert_tree(work_tree)
282
 
        output = [e.name for e in
283
 
            tree.iter_child_entries('', tree.get_root_id())]
 
272
        output = [e.name for e in tree.iter_child_entries('')]
284
273
        self.assertEqual({'a', 'f'}, set(output))
285
 
        output = [e.name for e in
286
 
            tree.iter_child_entries('a', tree.path2id('a'))]
 
274
        output = [e.name for e in tree.iter_child_entries('a')]
287
275
        self.assertEqual({'b', 'd'}, set(output))
288
276
 
289
277
    def test_does_not_exist(self):
292
280
        work_tree.add(['a'])
293
281
        tree = self._convert_tree(work_tree)
294
282
        self.assertRaises(errors.NoSuchFile, lambda:
295
 
            list(tree.iter_child_entries('unknown')))
 
283
                          list(tree.iter_child_entries('unknown')))
296
284
 
297
285
 
298
286
class TestHasId(TestCaseWithTree):