29
from bzrlib.tests.test_foreign import (
30
DummyForeignVcsDirFormat,
31
InterToDummyVcsBranch,
33
30
from bzrlib.tests import (
34
from bzrlib.tests.blackbox import test_push
37
def load_tests(standard_tests, module, loader):
38
"""Multiply tests for the dpush command."""
39
result = loader.suiteClass()
41
# one for each king of change
42
changes_tests, remaining_tests = tests.split_suite_by_condition(
43
standard_tests, tests.condition_isinstance((
44
TestDpushStrictWithChanges,
48
dict(_changes_type= '_uncommitted_changes')),
50
dict(_changes_type= '_pending_merges')),
52
dict(_changes_type= '_out_of_sync_trees')),
54
tests.multiply_tests(changes_tests, changes_scenarios, result)
55
# No parametrization for the remaining tests
56
result.addTests(remaining_tests)
38
61
class TestDpush(blackbox.ExternalBase):
41
bzrdir.BzrDirFormat.register_control_format(
42
test_foreign.DummyForeignVcsDirFormat)
43
branch.InterBranch.register_optimiser(
44
test_foreign.InterToDummyVcsBranch)
45
self.addCleanup(self.unregister_format)
46
64
super(TestDpush, self).setUp()
48
def unregister_format(self):
50
bzrdir.BzrDirFormat.unregister_control_format(
51
test_foreign.DummyForeignVcsDirFormat)
54
branch.InterBranch.unregister_optimiser(
55
test_foreign.InterToDummyVcsBranch)
65
test_foreign.register_dummy_foreign_for_test(self)
57
67
def make_dummy_builder(self, relpath):
58
68
builder = self.make_branch_builder(
103
113
newrevid = dc_tree.commit('msg')
105
115
self.build_tree_contents([("dc/foofile", "blaaaal")])
106
self.check_output("", "dpush -d dc d")
116
self.check_output("", "dpush -d dc d --no-strict")
107
117
self.assertFileEqual("blaaaal", "dc/foofile")
118
# if the dummy vcs wasn't that dummy we could uncomment the line below
119
# self.assertFileEqual("blaaaa", "d/foofile")
108
120
self.check_output('modified:\n foofile\n', "status dc")
110
122
def test_diverged(self):
124
136
output, error = self.run_bzr("dpush -d dc d", retcode=3)
125
137
self.assertEquals(output, "")
126
138
self.assertContainsRe(error, "have diverged")
141
class TestDpushStrictMixin(object):
144
test_foreign.register_dummy_foreign_for_test(self)
145
# Create an empty branch where we will be able to push
146
self.foreign = self.make_branch(
147
'to', format=test_foreign.DummyForeignVcsDirFormat())
149
def set_config_push_strict(self, value):
150
# set config var (any of bazaar.conf, locations.conf, branch.conf
152
conf = self.tree.branch.get_config()
153
conf.set_user_option('dpush_strict', value)
155
_default_command = ['dpush', '../to']
156
_default_pushed_revid = False # Doesn't aplly for dpush
158
def assertPushSucceeds(self, args, pushed_revid=None):
159
self.run_bzr(self._default_command + args,
160
working_dir=self._default_wd)
161
if pushed_revid is None:
162
# dpush change the revids, so we need to get back to it
163
branch_from = branch.Branch.open(self._default_wd)
164
pushed_revid = branch_from.last_revision()
165
branch_to = branch.Branch.open('to')
166
repo_to = branch_to.repository
167
self.assertTrue(repo_to.has_revision(pushed_revid))
168
self.assertEqual(branch_to.last_revision(), pushed_revid)
172
class TestDpushStrictWithoutChanges(TestDpushStrictMixin,
173
test_push.TestPushStrictWithoutChanges):
176
test_push.TestPushStrictWithoutChanges.setUp(self)
177
TestDpushStrictMixin.setUp(self)
180
class TestDpushStrictWithChanges(TestDpushStrictMixin,
181
test_push.TestPushStrictWithChanges):
183
_changes_type = None # Set by load_tests
186
test_push.TestPushStrictWithChanges.setUp(self)
187
TestDpushStrictMixin.setUp(self)
189
def test_push_with_revision(self):
190
raise tests.TestNotApplicable('dpush does not handle --revision')