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

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-03-25 11:54:30 UTC
  • mfrom: (6855.4.10 more-bees)
  • Revision ID: breezy.the.bot@gmail.com-20180325115430-75xnlbrmzjoomd83
Add more bees. In particular:

* for file ids
* for revision ids
* for file contents in build_tree_contents()

Merged from https://code.launchpad.net/~jelmer/brz/more-bees/+merge/337919

Show diffs side-by-side

added added

removed removed

Lines of Context:
241
241
    def make_simple_tree(self):
242
242
        tree = self.make_branch_and_tree('tree', format='development-subtree')
243
243
        self.build_tree(['tree/a/', 'tree/a/b/', 'tree/a/b/c'])
244
 
        tree.set_root_id('root-id')
245
 
        tree.add(['a', 'a/b', 'a/b/c'], ['a-id', 'b-id', 'c-id'])
 
244
        tree.set_root_id(b'root-id')
 
245
        tree.add(['a', 'a/b', 'a/b/c'], [b'a-id', b'b-id', b'c-id'])
246
246
        tree.commit('initial')
247
247
        return tree
248
248
 
249
249
    def test_just_directory(self):
250
250
        tree = self.make_simple_tree()
251
 
        self.assertEqual([('directory', 'root-id'),
252
 
                          ('directory', 'a-id'),
253
 
                          ('directory', 'b-id'),
254
 
                          ('file', 'c-id')],
 
251
        self.assertEqual([('directory', b'root-id'),
 
252
                          ('directory', b'a-id'),
 
253
                          ('directory', b'b-id'),
 
254
                          ('file', b'c-id')],
255
255
                         [(ie.kind, ie.file_id)
256
256
                          for path, ie in tree.iter_entries_by_dir()])
257
257
        subtree = self.make_branch_and_tree('tree/a/b')
258
 
        self.assertEqual([('tree-reference', 'b-id')],
 
258
        self.assertEqual([('tree-reference', b'b-id')],
259
259
                         [(ie.kind, ie.file_id)
260
260
                          for path, ie in tree.iter_entries_by_dir(
261
261
                              specific_files=['a/b'])])
263
263
    def test_direct_subtree(self):
264
264
        tree = self.make_simple_tree()
265
265
        subtree = self.make_branch_and_tree('tree/a/b')
266
 
        self.assertEqual([('directory', 'root-id'),
267
 
                          ('directory', 'a-id'),
268
 
                          ('tree-reference', 'b-id')],
 
266
        self.assertEqual([('directory', b'root-id'),
 
267
                          ('directory', b'a-id'),
 
268
                          ('tree-reference', b'b-id')],
269
269
                         [(ie.kind, ie.file_id)
270
270
                          for path, ie in tree.iter_entries_by_dir()])
271
271
 
272
272
    def test_indirect_subtree(self):
273
273
        tree = self.make_simple_tree()
274
274
        subtree = self.make_branch_and_tree('tree/a')
275
 
        self.assertEqual([('directory', 'root-id'),
276
 
                          ('tree-reference', 'a-id')],
 
275
        self.assertEqual([('directory', b'root-id'),
 
276
                          ('tree-reference', b'a-id')],
277
277
                         [(ie.kind, ie.file_id)
278
278
                          for path, ie in tree.iter_entries_by_dir()])
279
279
 
384
384
        this_tree.add(['foo', 'foo/bar'])
385
385
        this_tree.commit('created foo/bar')
386
386
        other_tree = this_tree.controldir.sprout('other-tree').open_workingtree()
387
 
        self.build_tree_contents([('other-tree/foo/bar', 'baz')])
 
387
        self.build_tree_contents([('other-tree/foo/bar', b'baz')])
388
388
        other_tree.commit('changed bar')
389
 
        self.build_tree_contents([('this-tree/foo/bar', 'qux')])
 
389
        self.build_tree_contents([('this-tree/foo/bar', b'qux')])
390
390
        this_tree.commit('changed qux')
391
391
        this_tree.merge_from_branch(other_tree.branch)
392
392
        self.assertEqual(1, len(this_tree.conflicts()))
399
399
    def test_auto_resolve(self):
400
400
        base = self.make_branch_and_tree('base')
401
401
        self.build_tree_contents([('base/hello', b'Hello')])
402
 
        base.add('hello', 'hello_id')
 
402
        base.add('hello', b'hello_id')
403
403
        base.commit('Hello')
404
404
        other = base.controldir.sprout('other').open_workingtree()
405
405
        self.build_tree_contents([('other/hello', b'hELLO')])
409
409
        self.build_tree_contents([('this/hello', b'Hello World')])
410
410
        this.commit('Add World')
411
411
        this.merge_from_branch(other.branch)
412
 
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
 
412
        self.assertEqual([conflicts.TextConflict('hello', b'hello_id')],
413
413
                         this.conflicts())
414
414
        this.auto_resolve()
415
 
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
 
415
        self.assertEqual([conflicts.TextConflict('hello', b'hello_id')],
416
416
                         this.conflicts())
417
417
        self.build_tree_contents([('this/hello', b'<<<<<<<')])
418
418
        this.auto_resolve()
419
 
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
 
419
        self.assertEqual([conflicts.TextConflict('hello', b'hello_id')],
420
420
                         this.conflicts())
421
421
        self.build_tree_contents([('this/hello', b'=======')])
422
422
        this.auto_resolve()
423
 
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
 
423
        self.assertEqual([conflicts.TextConflict('hello', b'hello_id')],
424
424
                         this.conflicts())
425
425
        self.build_tree_contents([('this/hello', b'\n>>>>>>>')])
426
426
        remaining, resolved = this.auto_resolve()
427
 
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
 
427
        self.assertEqual([conflicts.TextConflict('hello', b'hello_id')],
428
428
                         this.conflicts())
429
429
        self.assertEqual([], resolved)
430
430
        self.build_tree_contents([('this/hello', b'hELLO wORLD')])
431
431
        remaining, resolved = this.auto_resolve()
432
432
        self.assertEqual([], this.conflicts())
433
 
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
 
433
        self.assertEqual([conflicts.TextConflict('hello', b'hello_id')],
434
434
                         resolved)
435
435
        self.assertPathDoesNotExist('this/hello.BASE')
436
436
 
437
437
    def test_auto_resolve_dir(self):
438
438
        tree = self.make_branch_and_tree('tree')
439
439
        self.build_tree(['tree/hello/'])
440
 
        tree.add('hello', 'hello-id')
441
 
        file_conflict = conflicts.TextConflict('file', 'hello-id')
 
440
        tree.add('hello', b'hello-id')
 
441
        file_conflict = conflicts.TextConflict('file', b'hello-id')
442
442
        tree.set_conflicts(conflicts.ConflictList([file_conflict]))
443
443
        tree.auto_resolve()
444
444
 
460
460
    def store_uncommitted(self):
461
461
        tree = self.make_branch_and_tree('tree')
462
462
        tree.commit('get root in there')
463
 
        self.build_tree_contents([('tree/file', 'content')])
464
 
        tree.add('file', 'file-id')
 
463
        self.build_tree_contents([('tree/file', b'content')])
 
464
        tree.add('file', b'file-id')
465
465
        tree.store_uncommitted()
466
466
        return tree
467
467