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)
61
class TestDpush(blackbox.ExternalBase):
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)
64
52
super(TestDpush, self).setUp()
65
test_foreign.register_dummy_foreign_for_test(self)
54
def unregister_format(self):
56
BzrDirFormat.unregister_control_format(DummyForeignVcsDirFormat)
59
InterBranch.unregister_optimiser(InterToDummyVcsBranch)
67
61
def make_dummy_builder(self, relpath):
68
builder = self.make_branch_builder(
69
relpath, format=test_foreign.DummyForeignVcsDirFormat())
70
builder.build_snapshot('revid', None,
62
builder = self.make_branch_builder(relpath,
63
format=DummyForeignVcsDirFormat())
64
builder.build_snapshot('revid', None,
71
65
[('add', ('', 'TREE_ROOT', 'directory', None)),
72
66
('add', ('foo', 'fooid', 'file', 'bar'))])
77
71
source_tree = self.make_branch_and_tree("dc")
78
72
output, error = self.run_bzr("dpush -d dc dp", retcode=3)
79
73
self.assertEquals("", output)
80
self.assertContainsRe(error, 'in the same VCS, lossy push not necessary. Please use regular push.')
74
self.assertContainsRe(error, 'not a foreign branch, use regular push')
82
76
def test_dpush(self):
83
77
branch = self.make_dummy_builder('d').get_branch()
86
80
self.build_tree(("dc/foo", "blaaaa"))
87
81
dc.open_workingtree().commit('msg')
89
output, error = self.run_bzr("dpush -d dc d")
90
self.assertEquals(error, "Pushed up to revision 2.\n")
83
self.check_output("", "dpush -d dc d")
91
84
self.check_output("", "status dc")
93
86
def test_dpush_new(self):
94
b = self.make_dummy_builder('d').get_branch()
87
branch = self.make_dummy_builder('d').get_branch()
96
dc = b.bzrdir.sprout('dc', force_new_repo=True)
89
dc = branch.bzrdir.sprout('dc', force_new_repo=True)
97
90
self.build_tree_contents([("dc/foofile", "blaaaa")])
98
91
dc_tree = dc.open_workingtree()
99
92
dc_tree.add("foofile")
104
97
self.check_output("", "status dc")
106
99
def test_dpush_wt_diff(self):
107
b = self.make_dummy_builder('d').get_branch()
100
branch = self.make_dummy_builder('d').get_branch()
109
dc = b.bzrdir.sprout('dc', force_new_repo=True)
102
dc = branch.bzrdir.sprout('dc', force_new_repo=True)
110
103
self.build_tree_contents([("dc/foofile", "blaaaa")])
111
104
dc_tree = dc.open_workingtree()
112
105
dc_tree.add("foofile")
113
106
newrevid = dc_tree.commit('msg')
115
108
self.build_tree_contents([("dc/foofile", "blaaaal")])
116
self.check_output("", "dpush -d dc d --no-strict")
109
self.check_output("", "dpush -d dc d")
117
110
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")
120
111
self.check_output('modified:\n foofile\n', "status dc")
122
113
def test_diverged(self):
123
114
builder = self.make_dummy_builder('d')
125
b = builder.get_branch()
116
branch = builder.get_branch()
127
dc = b.bzrdir.sprout('dc', force_new_repo=True)
118
dc = branch.bzrdir.sprout('dc', force_new_repo=True)
128
119
dc_tree = dc.open_workingtree()
130
121
self.build_tree_contents([("dc/foo", "bar")])
136
127
output, error = self.run_bzr("dpush -d dc d", retcode=3)
137
128
self.assertEquals(output, "")
138
129
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']
158
class TestDpushStrictWithoutChanges(TestDpushStrictMixin,
159
test_push.TestPushStrictWithoutChanges):
162
test_push.TestPushStrictWithoutChanges.setUp(self)
163
TestDpushStrictMixin.setUp(self)
166
class TestDpushStrictWithChanges(TestDpushStrictMixin,
167
test_push.TestPushStrictWithChanges):
169
_changes_type = None # Set by load_tests
172
test_push.TestPushStrictWithChanges.setUp(self)
173
TestDpushStrictMixin.setUp(self)
175
def test_push_with_revision(self):
176
raise tests.TestNotApplicable('dpush does not handle --revision')