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

  • Committer: Jelmer Vernooij
  • Date: 2018-11-11 04:08:32 UTC
  • mto: (7143.16.20 even-more-cleanups)
  • mto: This revision was merged to the branch mainline in revision 7175.
  • Revision ID: jelmer@jelmer.uk-20181111040832-nsljjynzzwmznf3h
Run autopep8.

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
            tree.remove('file-1')
61
61
            tree.commit('rev2')
62
62
        checkout = tree.branch.create_checkout('checkout',
63
 
            lightweight=self.lightweight)
 
63
                                               lightweight=self.lightweight)
64
64
        self.build_tree(['checkout/file-3'])
65
65
        checkout.add('file-3')
66
66
        return checkout, to_branch
112
112
        """Test switch after the branch is moved."""
113
113
        tree = self._setup_tree()
114
114
        checkout = tree.branch.create_checkout('checkout',
115
 
            lightweight=self.lightweight)
 
115
                                               lightweight=self.lightweight)
116
116
        self.build_tree(['branch-1/file-2'])
117
117
        tree.add('file-2')
118
118
        tree.remove('file-1')
129
129
            switch.switch, checkout.controldir, to_branch)
130
130
        if isinstance(err, errors.BzrCommandError):
131
131
            self.assertContainsRe(str(err),
132
 
                'Unable to connect to current master branch .*'
133
 
                'To switch anyway, use --force.')
 
132
                                  'Unable to connect to current master branch .*'
 
133
                                  'To switch anyway, use --force.')
134
134
        switch.switch(checkout.controldir, to_branch, force=True)
135
135
        self.assertPathDoesNotExist('checkout/file-1')
136
136
        self.assertPathExists('checkout/file-2')
142
142
        tree = self._setup_tree()
143
143
        tree2 = tree.controldir.sprout('branch-2').open_workingtree()
144
144
        checkout = tree.branch.create_checkout('checkout',
145
 
            lightweight=self.lightweight)
 
145
                                               lightweight=self.lightweight)
146
146
        # Change tree2 and merge it into the checkout without committing
147
147
        self.build_tree(['branch-2/file-2'])
148
148
        tree2.add('file-2')
150
150
        checkout.merge_from_branch(tree2.branch)
151
151
        # Check the error reporting is as expected
152
152
        err = self.assertRaises(errors.BzrCommandError,
153
 
            switch.switch, checkout.controldir, tree2.branch)
 
153
                                switch.switch, checkout.controldir, tree2.branch)
154
154
        self.assertContainsRe(str(err),
155
 
            "Pending merges must be committed or reverted before using switch")
 
155
                              "Pending merges must be committed or reverted before using switch")
156
156
 
157
157
    def test_switch_with_revision(self):
158
158
        """Test switch when a revision is given."""
166
166
        tree.commit(rev_id=b'rev2', message='rev2')
167
167
        # Check it out and switch to revision 1
168
168
        checkout = tree.branch.create_checkout('checkout',
169
 
            lightweight=self.lightweight)
 
169
                                               lightweight=self.lightweight)
170
170
        switch.switch(checkout.controldir, tree.branch, revision_id=b"rev1")
171
171
        self.assertPathExists('checkout/file-1')
172
172
        self.assertPathDoesNotExist('checkout/file-2')
179
179
        tree2.add(['file-2'])
180
180
        tree2.commit('rev1b')
181
181
        checkout = tree.branch.create_checkout('checkout',
182
 
            lightweight=self.lightweight)
 
182
                                               lightweight=self.lightweight)
183
183
        switch.switch(checkout.controldir, tree2.branch)
184
184
        self.assertEqual(b'custom-root-id', tree2.get_root_id())
185
185
 
223
223
        self.build_tree(['checkout/file-4'])
224
224
        # Check the error reporting is as expected
225
225
        err = self.assertRaises(errors.BzrCommandError,
226
 
            switch.switch, checkout.controldir, to_branch)
 
226
                                switch.switch, checkout.controldir, to_branch)
227
227
        self.assertContainsRe(str(err),
228
 
            'Cannot switch as local commits found in the checkout.')
 
228
                              'Cannot switch as local commits found in the checkout.')
229
229
        # Check all is ok when force is given
230
230
        self.assertPathDoesNotExist('checkout/file-1')
231
231
        self.assertPathExists('checkout/file-2')