~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Gary van der Merwe
  • Date: 2010-08-02 19:56:52 UTC
  • mfrom: (5050.3.18 2.2)
  • mto: (5050.3.19 2.2)
  • mto: This revision was merged to the branch mainline in revision 5371.
  • Revision ID: garyvdm@gmail.com-20100802195652-o1ppjemhwrr98i61
MergeĀ lp:bzr/2.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
661
661
    _default_wd = 'local'
662
662
    _default_errors = ['Working tree ".*/local/" has uncommitted '
663
663
                       'changes \(See bzr status\)\.',]
664
 
    _default_pushed_revid = 'modified'
 
664
    _default_additional_error = 'Use --no-strict to force the push.\n'
 
665
    _default_additional_warning = 'Uncommitted changes will not be pushed.'
 
666
 
665
667
 
666
668
    def assertPushFails(self, args):
667
 
        self.run_bzr_error(self._default_errors, self._default_command + args,
668
 
                           working_dir=self._default_wd, retcode=3)
 
669
        out, err = self.run_bzr_error(self._default_errors,
 
670
                                      self._default_command + args,
 
671
                                      working_dir=self._default_wd, retcode=3)
 
672
        self.assertContainsRe(err, self._default_additional_error)
669
673
 
670
 
    def assertPushSucceeds(self, args, pushed_revid=None):
671
 
        self.run_bzr(self._default_command + args,
672
 
                     working_dir=self._default_wd)
673
 
        if pushed_revid is None:
674
 
            pushed_revid = self._default_pushed_revid
675
 
        tree_to = workingtree.WorkingTree.open('to')
676
 
        repo_to = tree_to.branch.repository
677
 
        self.assertTrue(repo_to.has_revision(pushed_revid))
678
 
        self.assertEqual(tree_to.branch.last_revision_info()[1], pushed_revid)
 
674
    def assertPushSucceeds(self, args, with_warning=False, revid_to_push=None):
 
675
        if with_warning:
 
676
            error_regexes = self._default_errors
 
677
        else:
 
678
            error_regexes = []
 
679
        out, err = self.run_bzr(self._default_command + args,
 
680
                                working_dir=self._default_wd,
 
681
                                error_regexes=error_regexes)
 
682
        if with_warning:
 
683
            self.assertContainsRe(err, self._default_additional_warning)
 
684
        else:
 
685
            self.assertNotContainsRe(err, self._default_additional_warning)
 
686
        branch_from = branch.Branch.open(self._default_wd)
 
687
        if revid_to_push is None:
 
688
            revid_to_push = branch_from.last_revision()
 
689
        branch_to = branch.Branch.open('to')
 
690
        repo_to = branch_to.repository
 
691
        self.assertTrue(repo_to.has_revision(revid_to_push))
 
692
        self.assertEqual(revid_to_push, branch_to.last_revision())
679
693
 
680
694
 
681
695
 
742
756
        self._default_wd = 'checkout'
743
757
        self._default_errors = ["Working tree is out of date, please run"
744
758
                                " 'bzr update'\.",]
745
 
        self._default_pushed_revid = 'modified-in-local'
746
759
 
747
760
    def test_push_default(self):
748
 
        self.assertPushFails([])
 
761
        self.assertPushSucceeds([], with_warning=True)
749
762
 
750
763
    def test_push_with_revision(self):
751
 
        self.assertPushSucceeds(['-r', 'revid:added'], pushed_revid='added')
 
764
        self.assertPushSucceeds(['-r', 'revid:added'], revid_to_push='added')
752
765
 
753
766
    def test_push_no_strict(self):
754
767
        self.assertPushSucceeds(['--no-strict'])
762
775
 
763
776
    def test_push_bogus_config_var_ignored(self):
764
777
        self.set_config_push_strict("I don't want you to be strict")
765
 
        self.assertPushFails([])
 
778
        self.assertPushSucceeds([], with_warning=True)
766
779
 
767
780
    def test_push_no_strict_command_line_override_config(self):
768
781
        self.set_config_push_strict('yES')
775
788
        self.assertPushSucceeds([])
776
789
 
777
790
 
778
 
class TestPushForeign(blackbox.ExternalBase):
 
791
class TestPushForeign(tests.TestCaseWithTransport):
779
792
 
780
793
    def setUp(self):
781
794
        super(TestPushForeign, self).setUp()