/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/plugins/weave_fmt/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:
45
45
        tree = self.create_format2_tree('.')
46
46
        self.assertRaises(errors.UnsupportedOperation, tree.set_conflicts,
47
47
                          None)
48
 
        file('lala.BASE', 'wb').write('labase')
 
48
        with open('lala.BASE', 'wb') as f:
 
49
            f.write(b'labase')
49
50
        expected = conflicts.ContentsConflict('lala')
50
51
        self.assertEqual(list(tree.conflicts()), [expected])
51
 
        file('lala', 'wb').write('la')
52
 
        tree.add('lala', 'lala-id')
 
52
        with open('lala', 'wb') as f:
 
53
            f.write(b'la')
 
54
        tree.add('lala', b'lala-id')
53
55
        expected = conflicts.ContentsConflict('lala', file_id='lala-id')
54
56
        self.assertEqual(list(tree.conflicts()), [expected])
55
 
        file('lala.THIS', 'wb').write('lathis')
56
 
        file('lala.OTHER', 'wb').write('laother')
 
57
        with open('lala.THIS', 'wb') as f:
 
58
            f.write(b'lathis')
 
59
        with open('lala.OTHER', 'wb') as f:
 
60
            f.write(b'laother')
57
61
        # When "text conflict"s happen, stem, THIS and OTHER are text
58
62
        expected = conflicts.TextConflict('lala', file_id='lala-id')
59
63
        self.assertEqual(list(tree.conflicts()), [expected])
65
69
    def test_detect_conflicts(self):
66
70
        """Conflicts are detected properly"""
67
71
        tree = self.create_format2_tree('.')
68
 
        self.build_tree_contents([('hello', 'hello world4'),
69
 
                                  ('hello.THIS', 'hello world2'),
70
 
                                  ('hello.BASE', 'hello world1'),
71
 
                                  ('hello.OTHER', 'hello world3'),
72
 
                                  ('hello.sploo.BASE', 'yellowworld'),
73
 
                                  ('hello.sploo.OTHER', 'yellowworld2'),
 
72
        self.build_tree_contents([('hello', b'hello world4'),
 
73
                                  ('hello.THIS', b'hello world2'),
 
74
                                  ('hello.BASE', b'hello world1'),
 
75
                                  ('hello.OTHER', b'hello world3'),
 
76
                                  ('hello.sploo.BASE', b'yellowworld'),
 
77
                                  ('hello.sploo.OTHER', b'yellowworld2'),
74
78
                                  ])
75
79
        tree.lock_read()
76
80
        self.assertLength(6, list(tree.list_files()))
82
86
        conflicts.restore('hello')
83
87
        conflicts.restore('hello.sploo')
84
88
        self.assertLength(0, tree.conflicts())
85
 
        self.assertFileEqual('hello world2', 'hello')
 
89
        self.assertFileEqual('hello world2', b'hello')
86
90
        self.assertFalse(os.path.lexists('hello.sploo'))
87
91
        self.assertRaises(errors.NotConflicted, conflicts.restore, 'hello')
88
92
        self.assertRaises(errors.NotConflicted,