~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_push.py

  • Committer: Jonathan Lange
  • Date: 2009-06-26 08:46:52 UTC
  • mto: (4484.1.1 bring-1.16.1-back)
  • mto: This revision was merged to the branch mainline in revision 4485.
  • Revision ID: jml@canonical.com-20090626084652-x7wn8yimd3fj0j0y
Tweak NEWS slightly based on mbp's feedback.

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
                           working_dir='branch_a', retcode=3)
87
87
        self.assertEquals(out,
88
88
                ('','bzr: ERROR: These branches have diverged.  '
89
 
                 'See "bzr help diverged-branches" for more information.\n'))
 
89
                    'Try using "merge" and then "push".\n'))
90
90
        self.assertEquals(osutils.abspath(branch_a.get_push_location()),
91
91
                          osutils.abspath(branch_b.bzrdir.root_transport.base))
92
92
 
475
475
        # subsequent log is accurate
476
476
        self.assertNotContainsRe(out, 'rev1')
477
477
 
478
 
    def test_push_from_subdir(self):
479
 
        t = self.make_branch_and_tree('tree')
480
 
        self.build_tree(['tree/dir/', 'tree/dir/file'])
481
 
        t.add('dir', 'dir/file')
482
 
        t.commit('r1')
483
 
        out, err = self.run_bzr('push ../../pushloc', working_dir='tree/dir')
484
 
        self.assertEqual('', out)
485
 
        self.assertEqual('Created new branch.\n', err)
486
 
 
487
478
 
488
479
class RedirectingMemoryTransport(memory.MemoryTransport):
489
480
 
564
555
             % re.escape(destination_url)],
565
556
            ['push', '-d', 'tree', destination_url], retcode=3)
566
557
        self.assertEqual('', out)
567
 
 
568
 
 
569
 
class TestPushStrict(tests.TestCaseWithTransport):
570
 
 
571
 
    def make_local_branch_and_tree(self):
572
 
        tree = self.make_branch_and_tree('local')
573
 
        self.build_tree_contents([('local/file', 'initial')])
574
 
        tree.add('file')
575
 
        tree.commit('adding file', rev_id='from-1')
576
 
        return tree
577
 
 
578
 
    def make_local_branch_and_tree_with_changes(self):
579
 
        tree = self.make_local_branch_and_tree()
580
 
        # Make some changes
581
 
        self.build_tree_contents([('local/file', 'modified')])
582
 
        return tree
583
 
 
584
 
    def set_config_push_strict(self, tree, value):
585
 
        # set config var (any of bazaar.conf, locations.conf, branch.conf
586
 
        # should do)
587
 
        conf = tree.branch.get_config()
588
 
        conf.set_user_option('push_strict', value)
589
 
 
590
 
    def assertPushFails(self, location, *args):
591
 
        self.run_bzr_error(['Working tree ".*/local/"'
592
 
                            ' has uncommitted changes.$',],
593
 
                           ['push', '../' + location] + list(args),
594
 
                           working_dir='local', retcode=3)
595
 
 
596
 
    def assertPushSucceeds(self, location, *args):
597
 
        self.run_bzr(['push', '../' + location] + list(args),
598
 
                     working_dir='local')
599
 
        tree_to = workingtree.WorkingTree.open(location)
600
 
        repo_to = tree_to.branch.repository
601
 
        self.assertTrue(repo_to.has_revision('from-1'))
602
 
        self.assertEqual(tree_to.branch.last_revision_info()[1], 'from-1')
603
 
 
604
 
    def test_push_default(self):
605
 
        tree = self.make_local_branch_and_tree_with_changes()
606
 
        self.assertPushSucceeds('to')
607
 
 
608
 
    def test_push_no_strict_with_changes(self):
609
 
        tree = self.make_local_branch_and_tree_with_changes()
610
 
        self.assertPushSucceeds('to', '--no-strict')
611
 
 
612
 
    def test_push_strict_with_changes(self):
613
 
        tree = self.make_local_branch_and_tree_with_changes()
614
 
        self.assertPushFails('to', '--strict')
615
 
 
616
 
    def test_push_strict_without_changes(self):
617
 
        tree = self.make_local_branch_and_tree()
618
 
        self.assertPushSucceeds('to', '--strict')
619
 
 
620
 
    def test_push_respect_config_var_strict(self):
621
 
        tree = self.make_local_branch_and_tree_with_changes()
622
 
        self.set_config_push_strict(tree, 'true')
623
 
        self.assertPushFails('to')
624
 
 
625
 
    def test_push_bogus_config_var_ignored(self):
626
 
        tree = self.make_local_branch_and_tree_with_changes()
627
 
        self.set_config_push_strict(tree, "I don't want you to be strict")
628
 
        self.assertPushSucceeds('to')
629
 
 
630
 
    def test_push_no_strict_command_line_override_config(self):
631
 
        tree = self.make_local_branch_and_tree_with_changes()
632
 
        self.set_config_push_strict(tree, 'yES')
633
 
        self.assertPushFails('to')
634
 
        self.assertPushSucceeds('to', '--no-strict')
635
 
 
636
 
    def test_push_strict_command_line_override_config(self):
637
 
        tree = self.make_local_branch_and_tree_with_changes()
638
 
        self.set_config_push_strict(tree, 'oFF')
639
 
        self.assertPushFails('to', '--strict')
640
 
        self.assertPushSucceeds('to')