/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/blackbox/test_switch.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-11-16 18:59:44 UTC
  • mfrom: (7143.15.15 more-cleanups)
  • Revision ID: breezy.the.bot@gmail.com-20181116185944-biefv1sub37qfybm
Sprinkle some PEP8iness.

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

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
        tree1 = self.make_branch_and_tree('branch1')
78
78
        tree2 = self.make_branch_and_tree('branch2')
79
79
        tree2.pull(tree1.branch)
80
 
        checkout =  tree1.branch.create_checkout('checkout',
81
 
            lightweight=lightweight)
 
80
        checkout = tree1.branch.create_checkout('checkout',
 
81
                                                lightweight=lightweight)
82
82
        self.assertEqual(checkout.branch.nick, tree1.branch.nick)
83
83
        self.assertEqual(checkout.branch.get_config().has_explicit_nickname(),
84
 
            False)
 
84
                         False)
85
85
        self.run_bzr('switch branch2', working_dir='checkout')
86
86
 
87
87
        # we need to get the tree again, otherwise we don't get the new branch
88
88
        checkout = WorkingTree.open('checkout')
89
89
        self.assertEqual(checkout.branch.nick, tree2.branch.nick)
90
90
        self.assertEqual(checkout.branch.get_config().has_explicit_nickname(),
91
 
            False)
 
91
                         False)
92
92
 
93
93
    def test_switch_nick(self):
94
94
        self._test_switch_nick(lightweight=False)
101
101
        tree1 = self.make_branch_and_tree('branch1')
102
102
        tree2 = self.make_branch_and_tree('branch2')
103
103
        tree2.pull(tree1.branch)
104
 
        checkout =  tree1.branch.create_checkout('checkout',
105
 
            lightweight=lightweight)
 
104
        checkout = tree1.branch.create_checkout('checkout',
 
105
                                                lightweight=lightweight)
106
106
        self.assertEqual(checkout.branch.nick, tree1.branch.nick)
107
107
        checkout.branch.nick = "explicit_nick"
108
108
        self.assertEqual(checkout.branch.nick, "explicit_nick")
109
109
        self.assertEqual(checkout.branch.get_config()._get_explicit_nickname(),
110
 
            "explicit_nick")
 
110
                         "explicit_nick")
111
111
        self.run_bzr('switch branch2', working_dir='checkout')
112
112
 
113
113
        # we need to get the tree again, otherwise we don't get the new branch
114
114
        checkout = WorkingTree.open('checkout')
115
115
        self.assertEqual(checkout.branch.nick, tree2.branch.nick)
116
116
        self.assertEqual(checkout.branch.get_config()._get_explicit_nickname(),
117
 
            tree2.branch.nick)
 
117
                         tree2.branch.nick)
118
118
 
119
119
    def test_switch_explicit_nick(self):
120
120
        self._test_switch_explicit_nick(lightweight=False)
130
130
        tree2 = self.make_branch_and_tree('repo/branchb')
131
131
        tree2.pull(tree1.branch)
132
132
        branchb_id = tree2.commit('bar')
133
 
        checkout =  tree1.branch.create_checkout('checkout', lightweight=True)
 
133
        checkout = tree1.branch.create_checkout('checkout', lightweight=True)
134
134
        self.run_bzr(['switch', 'branchb'], working_dir='checkout')
135
135
        self.assertEqual(branchb_id, checkout.last_revision())
136
136
        checkout = checkout.controldir.open_workingtree()
168
168
        tree2 = self.make_branch_and_tree(u'repo/branch\xe9')
169
169
        tree2.pull(tree1.branch)
170
170
        branchb_id = tree2.commit('bar')
171
 
        checkout =  tree1.branch.create_checkout('checkout', lightweight=True)
 
171
        checkout = tree1.branch.create_checkout('checkout', lightweight=True)
172
172
        self.run_bzr(['switch', u'branch\xe9'], working_dir='checkout')
173
173
        self.assertEqual(branchb_id, checkout.last_revision())
174
174
        checkout = checkout.controldir.open_workingtree()
183
183
        tree2 = self.make_branch_and_tree(u'repo/branch\xe9')
184
184
        tree2.pull(tree1.branch)
185
185
        branchb_id = tree2.commit('bar')
186
 
        checkout =  tree1.branch.create_checkout('checkout', lightweight=True)
 
186
        checkout = tree1.branch.create_checkout('checkout', lightweight=True)
187
187
        self.run_bzr(['switch', u'branch\xe9'], working_dir='checkout')
188
188
        self.assertEqual(branchb_id, checkout.last_revision())
189
189
        checkout = checkout.controldir.open_workingtree()
219
219
        revid2 = tree.commit('rev2')
220
220
        tree.controldir.create_branch(name='foo')
221
221
        self.run_bzr_error(['Cannot switch a branch, only a checkout.'],
222
 
            'switch foo')
 
222
                           'switch foo')
223
223
        self.run_bzr(['switch', '--force', 'foo'])
224
224
 
225
225
    def test_switch_existing_colocated(self):
312
312
    def test_create_branch_no_branch(self):
313
313
        self.prepare_lightweight_switch()
314
314
        self.run_bzr_error(['cannot create branch without source branch'],
315
 
            'switch --create-branch ../branch2', working_dir='tree')
 
315
                           'switch --create-branch ../branch2', working_dir='tree')
316
316
 
317
317
    def test_create_branch(self):
318
318
        branch = self.make_branch('branch')
345
345
    def test_create_branch_directory_services(self):
346
346
        branch = self.make_branch('branch')
347
347
        tree = branch.create_checkout('tree', lightweight=True)
 
348
 
348
349
        class FooLookup(object):
349
350
            def look_up(self, name, url):
350
 
                return 'foo-'+name
 
351
                return 'foo-' + name
351
352
        directories.register('foo:', FooLookup, 'Create branches named foo-')
352
353
        self.addCleanup(directories.remove, 'foo:')
353
354
        self.run_bzr('switch -b foo:branch2', working_dir='tree')
358
359
        from breezy import branch as _mod_branch
359
360
        calls = []
360
361
        _mod_branch.Branch.hooks.install_named_hook('post_switch',
361
 
            calls.append, None)
 
362
                                                    calls.append, None)
362
363
        self.make_branch_and_tree('branch')
363
364
        self.run_bzr('branch branch branch2')
364
365
        self.run_bzr('checkout branch checkout')
371
372
        from breezy import branch as _mod_branch
372
373
        calls = []
373
374
        _mod_branch.Branch.hooks.install_named_hook('post_switch',
374
 
            calls.append, None)
 
375
                                                    calls.append, None)
375
376
        self.make_branch_and_tree('branch')
376
377
        self.run_bzr('branch branch branch2')
377
378
        self.run_bzr('checkout --lightweight branch checkout')
461
462
        # Note: not a lightweight checkout
462
463
        checkout = master.branch.create_checkout('checkout')
463
464
        opened = []
 
465
 
464
466
        def open_hook(branch):
465
467
            # Just append the final directory of the branch
466
468
            name = branch.base.rstrip('/').rsplit('/', 1)[1]
482
484
        for count in range(9):
483
485
            t.commit(message='commit %d' % count)
484
486
        out, err = self.run_bzr(['checkout', '--lightweight', self.get_url('from'),
485
 
            'target'])
 
487
                                 'target'])
486
488
        self.reset_smart_call_log()
487
489
        self.run_bzr(['switch', self.get_url('from')], working_dir='target')
488
490
        # This figure represent the amount of work to perform this use case. It
559
561
           $ brz commit -m 2 --unchanged
560
562
           $ brz switch -r 1
561
563
           2>brz: ERROR: switching would create a branch reference loop. Use the "bzr up" command to switch to a different revision.''',
562
 
           null_output_matches_anything=True)
 
564
                                      null_output_matches_anything=True)
563
565
 
564
566
    def test_switch_create_colo_locks_repo_path(self):
565
567
        self.script_runner = script.ScriptRunner()