/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: Jelmer Vernooij
  • Date: 2018-02-18 15:21:06 UTC
  • mto: This revision was merged to the branch mainline in revision 6928.
  • Revision ID: jelmer@jelmer.uk-20180218152106-m8bmfurzlspweyu4
Yet more bees.

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
 
                          for path, ie in tree.iter_entries_by_dir(['b-id'])])
 
260
                          for path, ie in tree.iter_entries_by_dir([b'b-id'])])
261
261
 
262
262
    def test_direct_subtree(self):
263
263
        tree = self.make_simple_tree()
264
264
        subtree = self.make_branch_and_tree('tree/a/b')
265
 
        self.assertEqual([('directory', 'root-id'),
266
 
                          ('directory', 'a-id'),
267
 
                          ('tree-reference', 'b-id')],
 
265
        self.assertEqual([('directory', b'root-id'),
 
266
                          ('directory', b'a-id'),
 
267
                          ('tree-reference', b'b-id')],
268
268
                         [(ie.kind, ie.file_id)
269
269
                          for path, ie in tree.iter_entries_by_dir()])
270
270
 
271
271
    def test_indirect_subtree(self):
272
272
        tree = self.make_simple_tree()
273
273
        subtree = self.make_branch_and_tree('tree/a')
274
 
        self.assertEqual([('directory', 'root-id'),
275
 
                          ('tree-reference', 'a-id')],
 
274
        self.assertEqual([('directory', b'root-id'),
 
275
                          ('tree-reference', b'a-id')],
276
276
                         [(ie.kind, ie.file_id)
277
277
                          for path, ie in tree.iter_entries_by_dir()])
278
278
 
383
383
        this_tree.add(['foo', 'foo/bar'])
384
384
        this_tree.commit('created foo/bar')
385
385
        other_tree = this_tree.controldir.sprout('other-tree').open_workingtree()
386
 
        self.build_tree_contents([('other-tree/foo/bar', 'baz')])
 
386
        self.build_tree_contents([('other-tree/foo/bar', b'baz')])
387
387
        other_tree.commit('changed bar')
388
 
        self.build_tree_contents([('this-tree/foo/bar', 'qux')])
 
388
        self.build_tree_contents([('this-tree/foo/bar', b'qux')])
389
389
        this_tree.commit('changed qux')
390
390
        this_tree.merge_from_branch(other_tree.branch)
391
391
        self.assertEqual(1, len(this_tree.conflicts()))
398
398
    def test_auto_resolve(self):
399
399
        base = self.make_branch_and_tree('base')
400
400
        self.build_tree_contents([('base/hello', b'Hello')])
401
 
        base.add('hello', 'hello_id')
 
401
        base.add('hello', b'hello_id')
402
402
        base.commit('Hello')
403
403
        other = base.controldir.sprout('other').open_workingtree()
404
404
        self.build_tree_contents([('other/hello', b'hELLO')])
408
408
        self.build_tree_contents([('this/hello', b'Hello World')])
409
409
        this.commit('Add World')
410
410
        this.merge_from_branch(other.branch)
411
 
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
 
411
        self.assertEqual([conflicts.TextConflict('hello', b'hello_id')],
412
412
                         this.conflicts())
413
413
        this.auto_resolve()
414
 
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
 
414
        self.assertEqual([conflicts.TextConflict('hello', b'hello_id')],
415
415
                         this.conflicts())
416
416
        self.build_tree_contents([('this/hello', b'<<<<<<<')])
417
417
        this.auto_resolve()
418
 
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
 
418
        self.assertEqual([conflicts.TextConflict('hello', b'hello_id')],
419
419
                         this.conflicts())
420
420
        self.build_tree_contents([('this/hello', b'=======')])
421
421
        this.auto_resolve()
422
 
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
 
422
        self.assertEqual([conflicts.TextConflict('hello', b'hello_id')],
423
423
                         this.conflicts())
424
424
        self.build_tree_contents([('this/hello', b'\n>>>>>>>')])
425
425
        remaining, resolved = this.auto_resolve()
426
 
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
 
426
        self.assertEqual([conflicts.TextConflict('hello', b'hello_id')],
427
427
                         this.conflicts())
428
428
        self.assertEqual([], resolved)
429
429
        self.build_tree_contents([('this/hello', b'hELLO wORLD')])
430
430
        remaining, resolved = this.auto_resolve()
431
431
        self.assertEqual([], this.conflicts())
432
 
        self.assertEqual([conflicts.TextConflict('hello', 'hello_id')],
 
432
        self.assertEqual([conflicts.TextConflict('hello', b'hello_id')],
433
433
                         resolved)
434
434
        self.assertPathDoesNotExist('this/hello.BASE')
435
435
 
436
436
    def test_auto_resolve_dir(self):
437
437
        tree = self.make_branch_and_tree('tree')
438
438
        self.build_tree(['tree/hello/'])
439
 
        tree.add('hello', 'hello-id')
440
 
        file_conflict = conflicts.TextConflict('file', 'hello-id')
 
439
        tree.add('hello', b'hello-id')
 
440
        file_conflict = conflicts.TextConflict('file', b'hello-id')
441
441
        tree.set_conflicts(conflicts.ConflictList([file_conflict]))
442
442
        tree.auto_resolve()
443
443
 
459
459
    def store_uncommitted(self):
460
460
        tree = self.make_branch_and_tree('tree')
461
461
        tree.commit('get root in there')
462
 
        self.build_tree_contents([('tree/file', 'content')])
463
 
        tree.add('file', 'file-id')
 
462
        self.build_tree_contents([('tree/file', b'content')])
 
463
        tree.add('file', b'file-id')
464
464
        tree.store_uncommitted()
465
465
        return tree
466
466