/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: Jelmer Vernooij
  • Date: 2018-03-24 17:48:04 UTC
  • mfrom: (6921 work)
  • mto: This revision was merged to the branch mainline in revision 6923.
  • Revision ID: jelmer@jelmer.uk-20180324174804-xf22o05byoj12x1q
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
317
317
    def test_create_branch(self):
318
318
        branch = self.make_branch('branch')
319
319
        tree = branch.create_checkout('tree', lightweight=True)
320
 
        tree.commit('one', rev_id=b'rev-1')
 
320
        tree.commit('one', rev_id='rev-1')
321
321
        self.run_bzr('switch --create-branch ../branch2', working_dir='tree')
322
322
        tree = WorkingTree.open('tree')
323
323
        self.assertEndsWith(tree.branch.base, '/branch2/')
325
325
    def test_create_branch_local(self):
326
326
        branch = self.make_branch('branch')
327
327
        tree = branch.create_checkout('tree', lightweight=True)
328
 
        tree.commit('one', rev_id=b'rev-1')
 
328
        tree.commit('one', rev_id='rev-1')
329
329
        self.run_bzr('switch --create-branch branch2', working_dir='tree')
330
330
        tree = WorkingTree.open('tree')
331
331
        # The new branch should have been created at the same level as
335
335
    def test_create_branch_short_name(self):
336
336
        branch = self.make_branch('branch')
337
337
        tree = branch.create_checkout('tree', lightweight=True)
338
 
        tree.commit('one', rev_id=b'rev-1')
 
338
        tree.commit('one', rev_id='rev-1')
339
339
        self.run_bzr('switch -b branch2', working_dir='tree')
340
340
        tree = WorkingTree.open('tree')
341
341
        # The new branch should have been created at the same level as
385
385
 
386
386
        # create a source branch
387
387
        a_tree = self.make_branch_and_tree('a')
388
 
        self.build_tree_contents([('a/a', b'initial\n')])
 
388
        self.build_tree_contents([('a/a', 'initial\n')])
389
389
        a_tree.add('a')
390
390
        a_tree.commit(message='initial')
391
391
 
392
392
        # clone and add a differing revision
393
393
        b_tree = a_tree.controldir.sprout('b').open_workingtree()
394
 
        self.build_tree_contents([('b/a', b'initial\nmore\n')])
 
394
        self.build_tree_contents([('b/a', 'initial\nmore\n')])
395
395
        b_tree.commit(message='more')
396
396
 
397
397
        self.run_bzr('checkout --lightweight a checkout')
529
529
        self.assertPathDoesNotExist('checkout/a')
530
530
        self.run_bzr(['switch', '-d', 'checkout', 'orig'])
531
531
        self.assertPathDoesNotExist('checkout/a')
532
 
 
533
 
 
534
 
class TestSwitchStandAloneCorruption(TestCaseWithTransport):
535
 
 
536
 
    def test_empty_tree_switch(self):
537
 
        """switch . on an empty tree gets infinite recursion
538
 
 
539
 
        Inspired by: https://bugs.launchpad.net/bzr/+bug/1018628
540
 
        """
541
 
        self.script_runner = script.ScriptRunner()
542
 
        self.script_runner.run_script(self, '''
543
 
            $ brz init
544
 
            Created a standalone tree (format: 2a)
545
 
            $ brz switch .
546
 
            2>brz: ERROR: switching would create a branch reference loop. Use the "bzr up" command to switch to a different revision.
547
 
            ''')
548
 
 
549
 
    def test_switch_on_previous_rev(self):
550
 
        """switch to previous rev in a standalone directory
551
 
 
552
 
        Inspired by: https://bugs.launchpad.net/brz/+bug/1018628
553
 
        """
554
 
        self.script_runner = script.ScriptRunner()
555
 
        self.script_runner.run_script(self, '''
556
 
           $ brz init
557
 
           Created a standalone tree (format: 2a)
558
 
           $ brz commit -m 1 --unchanged
559
 
           $ brz commit -m 2 --unchanged
560
 
           $ brz switch -r 1
561
 
           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)
563
 
 
564
 
    def test_switch_create_colo_locks_repo_path(self):
565
 
        self.script_runner = script.ScriptRunner()
566
 
        self.script_runner.run_script(self, '''
567
 
            $ mkdir mywork
568
 
            $ cd mywork
569
 
            $ brz init
570
 
            Created a standalone tree (format: 2a)
571
 
            $ echo A > a && brz add a && brz commit -m A
572
 
            $ brz switch -b br1
573
 
            $ cd ..
574
 
            $ mv mywork mywork1
575
 
            $ cd mywork1
576
 
            $ brz branches
577
 
            * br1
578
 
            ''', null_output_matches_anything=True)