~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2010-04-21 11:27:04 UTC
  • mto: This revision was merged to the branch mainline in revision 5189.
  • Revision ID: mbp@canonical.com-20100421112704-zijso22b6pdevrxy
Simplify various code to use user_url

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_additional_error = 'Use --no-strict to force the push.\n'
665
 
    _default_additional_warning = 'Uncommitted changes will not be pushed.'
666
 
 
 
664
    _default_pushed_revid = 'modified'
667
665
 
668
666
    def assertPushFails(self, args):
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)
 
667
        ret = self.run_bzr_error(self._default_errors,
 
668
                                 self._default_command + args,
 
669
                                 working_dir=self._default_wd, retcode=3)
673
670
 
674
 
    def assertPushSucceeds(self, args, with_warning=False, revid_to_push=None):
 
671
    def assertPushSucceeds(self, args, pushed_revid=None, with_warning=False):
675
672
        if with_warning:
676
673
            error_regexes = self._default_errors
677
674
        else:
678
675
            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())
 
676
        self.run_bzr(self._default_command + args,
 
677
                     working_dir=self._default_wd, error_regexes=error_regexes)
 
678
        if pushed_revid is None:
 
679
            pushed_revid = self._default_pushed_revid
 
680
        tree_to = workingtree.WorkingTree.open('to')
 
681
        repo_to = tree_to.branch.repository
 
682
        self.assertTrue(repo_to.has_revision(pushed_revid))
 
683
        self.assertEqual(tree_to.branch.last_revision_info()[1], pushed_revid)
693
684
 
694
685
 
695
686
 
756
747
        self._default_wd = 'checkout'
757
748
        self._default_errors = ["Working tree is out of date, please run"
758
749
                                " 'bzr update'\.",]
 
750
        self._default_pushed_revid = 'modified-in-local'
759
751
 
760
752
    def test_push_default(self):
761
753
        self.assertPushSucceeds([], with_warning=True)
762
754
 
763
755
    def test_push_with_revision(self):
764
 
        self.assertPushSucceeds(['-r', 'revid:added'], revid_to_push='added')
 
756
        self.assertPushSucceeds(['-r', 'revid:added'], pushed_revid='added')
765
757
 
766
758
    def test_push_no_strict(self):
767
759
        self.assertPushSucceeds(['--no-strict'])
788
780
        self.assertPushSucceeds([])
789
781
 
790
782
 
791
 
class TestPushForeign(tests.TestCaseWithTransport):
 
783
class TestPushForeign(blackbox.ExternalBase):
792
784
 
793
785
    def setUp(self):
794
786
        super(TestPushForeign, self).setUp()