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
668
def assertPushFails(self, args):
667
ret = self.run_bzr_error(self._default_errors,
668
self._default_command + args,
669
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)
671
def assertPushSucceeds(self, args, pushed_revid=None, with_warning=False):
674
def assertPushSucceeds(self, args, with_warning=False, revid_to_push=None):
673
676
error_regexes = self._default_errors
675
678
error_regexes = []
676
ret = self.run_bzr(self._default_command + args,
677
working_dir=self._default_wd,
678
error_regexes=error_regexes)
679
if pushed_revid is None:
680
pushed_revid = self._default_pushed_revid
681
tree_to = workingtree.WorkingTree.open('to')
682
repo_to = tree_to.branch.repository
683
self.assertTrue(repo_to.has_revision(pushed_revid))
684
self.assertEqual(tree_to.branch.last_revision_info()[1], pushed_revid)
679
out, err = self.run_bzr(self._default_command + args,
680
working_dir=self._default_wd,
681
error_regexes=error_regexes)
683
self.assertContainsRe(err, self._default_additional_warning)
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())
748
756
self._default_wd = 'checkout'
749
757
self._default_errors = ["Working tree is out of date, please run"
750
758
" 'bzr update'\.",]
751
self._default_pushed_revid = 'modified-in-local'
753
760
def test_push_default(self):
754
761
self.assertPushSucceeds([], with_warning=True)
756
763
def test_push_with_revision(self):
757
self.assertPushSucceeds(['-r', 'revid:added'], pushed_revid='added')
764
self.assertPushSucceeds(['-r', 'revid:added'], revid_to_push='added')
759
766
def test_push_no_strict(self):
760
767
self.assertPushSucceeds(['--no-strict'])