30
from bzrlib.tests import (
35
from bzrlib.tests.blackbox import test_push
38
def load_tests(standard_tests, module, loader):
39
"""Multiply tests for the dpush command."""
40
result = loader.suiteClass()
42
# one for each king of change
43
changes_tests, remaining_tests = tests.split_suite_by_condition(
44
standard_tests, tests.condition_isinstance((
45
TestDpushStrictWithChanges,
49
dict(_changes_type= '_uncommitted_changes')),
51
dict(_changes_type= '_pending_merges')),
53
dict(_changes_type= '_out_of_sync_trees')),
55
tests.multiply_tests(changes_tests, changes_scenarios, result)
56
# No parametrization for the remaining tests
57
result.addTests(remaining_tests)
62
class TestDpush(tests.TestCaseWithTransport):
23
from bzrlib.branch import (
27
from bzrlib.bzrdir import (
30
from bzrlib.foreign import (
34
from bzrlib.repository import (
37
from bzrlib.tests.blackbox import (
40
from bzrlib.tests.test_foreign import (
41
DummyForeignVcsDirFormat,
42
InterToDummyVcsBranch,
46
class TestDpush(ExternalBase):
49
BzrDirFormat.register_control_format(DummyForeignVcsDirFormat)
50
InterBranch.register_optimiser(InterToDummyVcsBranch)
51
self.addCleanup(self.unregister_format)
65
52
super(TestDpush, self).setUp()
66
test_foreign.register_dummy_foreign_for_test(self)
54
def unregister_format(self):
56
BzrDirFormat.unregister_control_format(DummyForeignVcsDirFormat)
59
InterBranch.unregister_optimiser(InterToDummyVcsBranch)
68
61
def make_dummy_builder(self, relpath):
69
builder = self.make_branch_builder(
70
relpath, format=test_foreign.DummyForeignVcsDirFormat())
71
builder.build_snapshot('revid', None,
62
builder = self.make_branch_builder(relpath,
63
format=DummyForeignVcsDirFormat())
64
builder.build_snapshot('revid', None,
72
65
[('add', ('', 'TREE_ROOT', 'directory', None)),
73
66
('add', ('foo', 'fooid', 'file', 'bar'))])
87
80
self.build_tree(("dc/foo", "blaaaa"))
88
81
dc.open_workingtree().commit('msg')
90
script.run_script(self, """
92
2>Pushed up to revision 2.
83
output, error = self.run_bzr("dpush -d dc d")
84
self.assertEquals(error, "Pushed up to revision 2.\n")
85
self.check_output("", "status dc")
96
87
def test_dpush_new(self):
97
b = self.make_dummy_builder('d').get_branch()
88
branch = self.make_dummy_builder('d').get_branch()
99
dc = b.bzrdir.sprout('dc', force_new_repo=True)
90
dc = branch.bzrdir.sprout('dc', force_new_repo=True)
100
91
self.build_tree_contents([("dc/foofile", "blaaaa")])
101
92
dc_tree = dc.open_workingtree()
102
93
dc_tree.add("foofile")
103
94
dc_tree.commit("msg")
105
script.run_script(self, '''
96
self.check_output("", "dpush -d dc d")
97
self.check_output("2\n", "revno dc")
98
self.check_output("", "status dc")
112
100
def test_dpush_wt_diff(self):
113
b = self.make_dummy_builder('d').get_branch()
101
branch = self.make_dummy_builder('d').get_branch()
115
dc = b.bzrdir.sprout('dc', force_new_repo=True)
103
dc = branch.bzrdir.sprout('dc', force_new_repo=True)
116
104
self.build_tree_contents([("dc/foofile", "blaaaa")])
117
105
dc_tree = dc.open_workingtree()
118
106
dc_tree.add("foofile")
119
107
newrevid = dc_tree.commit('msg')
121
109
self.build_tree_contents([("dc/foofile", "blaaaal")])
122
script.run_script(self, '''
123
$ bzr dpush -d dc d --no-strict
110
self.check_output("", "dpush -d dc d")
125
111
self.assertFileEqual("blaaaal", "dc/foofile")
126
# if the dummy vcs wasn't that dummy we could uncomment the line below
127
# self.assertFileEqual("blaaaa", "d/foofile")
128
script.run_script(self, '''
112
self.check_output('modified:\n foofile\n', "status dc")
134
114
def test_diverged(self):
135
115
builder = self.make_dummy_builder('d')
137
b = builder.get_branch()
117
branch = builder.get_branch()
139
dc = b.bzrdir.sprout('dc', force_new_repo=True)
119
dc = branch.bzrdir.sprout('dc', force_new_repo=True)
140
120
dc_tree = dc.open_workingtree()
142
122
self.build_tree_contents([("dc/foo", "bar")])
148
128
output, error = self.run_bzr("dpush -d dc d", retcode=3)
149
129
self.assertEquals(output, "")
150
130
self.assertContainsRe(error, "have diverged")
153
class TestDpushStrictMixin(object):
156
test_foreign.register_dummy_foreign_for_test(self)
157
# Create an empty branch where we will be able to push
158
self.foreign = self.make_branch(
159
'to', format=test_foreign.DummyForeignVcsDirFormat())
161
def set_config_push_strict(self, value):
162
# set config var (any of bazaar.conf, locations.conf, branch.conf
164
conf = self.tree.branch.get_config()
165
conf.set_user_option('dpush_strict', value)
167
_default_command = ['dpush', '../to']
170
class TestDpushStrictWithoutChanges(TestDpushStrictMixin,
171
test_push.TestPushStrictWithoutChanges):
174
test_push.TestPushStrictWithoutChanges.setUp(self)
175
TestDpushStrictMixin.setUp(self)
178
class TestDpushStrictWithChanges(TestDpushStrictMixin,
179
test_push.TestPushStrictWithChanges):
181
_changes_type = None # Set by load_tests
184
test_push.TestPushStrictWithChanges.setUp(self)
185
TestDpushStrictMixin.setUp(self)
187
def test_push_with_revision(self):
188
raise tests.TestNotApplicable('dpush does not handle --revision')