18
18
"""Black-box tests for bzr dpush."""
23
from bzrlib.branch import (
26
from bzrlib.bzrdir import (
29
from bzrlib.foreign import (
33
from bzrlib.repository import (
36
from bzrlib.tests.blackbox import (
39
from bzrlib.tests.test_foreign import (
40
DummyForeignVcsDirFormat,
44
class TestDpush(ExternalBase):
25
from bzrlib.tests import (
29
from bzrlib.tests.blackbox import test_push
30
from bzrlib.tests.scenarios import (
31
load_tests_apply_scenarios,
35
load_tests = load_tests_apply_scenarios
38
class TestDpush(tests.TestCaseWithTransport):
47
BzrDirFormat.register_control_format(DummyForeignVcsDirFormat)
48
self.addCleanup(self.unregister_format)
49
41
super(TestDpush, self).setUp()
51
def unregister_format(self):
53
BzrDirFormat.unregister_control_format(DummyForeignVcsDirFormat)
42
test_foreign.register_dummy_foreign_for_test(self)
57
44
def make_dummy_builder(self, relpath):
58
builder = self.make_branch_builder(relpath,
59
format=DummyForeignVcsDirFormat())
60
builder.build_snapshot('revid', None,
45
builder = self.make_branch_builder(
46
relpath, format=test_foreign.DummyForeignVcsDirFormat())
47
builder.build_snapshot('revid', None,
61
48
[('add', ('', 'TREE_ROOT', 'directory', None)),
62
49
('add', ('foo', 'fooid', 'file', 'bar'))])
67
54
source_tree = self.make_branch_and_tree("dc")
68
55
output, error = self.run_bzr("dpush -d dc dp", retcode=3)
69
56
self.assertEquals("", output)
70
self.assertContainsRe(error, 'not a foreign branch, use regular push')
57
self.assertContainsRe(error,
58
'in the same VCS, lossy push not necessary. Please use regular '
72
61
def test_dpush(self):
73
62
branch = self.make_dummy_builder('d').get_branch()
76
65
self.build_tree(("dc/foo", "blaaaa"))
77
66
dc.open_workingtree().commit('msg')
79
self.check_output("", "dpush -d dc d")
80
self.check_output("", "status dc")
68
script.run_script(self, """
70
2>Doing on-the-fly conversion from DummyForeignVcsRepositoryFormat() to RepositoryFormat2a().
71
2>This may take some time. Upgrade the repositories to the same format for better performance.
72
2>Pushed up to revision 2.
82
76
def test_dpush_new(self):
83
branch = self.make_dummy_builder('d').get_branch()
77
b = self.make_dummy_builder('d').get_branch()
85
dc = branch.bzrdir.sprout('dc', force_new_repo=True)
79
dc = b.bzrdir.sprout('dc', force_new_repo=True)
86
80
self.build_tree_contents([("dc/foofile", "blaaaa")])
87
81
dc_tree = dc.open_workingtree()
88
82
dc_tree.add("foofile")
89
83
dc_tree.commit("msg")
91
self.check_output("", "dpush -d dc d")
92
self.check_output("2\n", "revno dc")
93
self.check_output("", "status dc")
85
script.run_script(self, '''
87
2>Doing on-the-fly conversion from DummyForeignVcsRepositoryFormat() to RepositoryFormat2a().
88
2>This may take some time. Upgrade the repositories to the same format for better performance.
89
2>Pushed up to revision 2.
95
95
def test_dpush_wt_diff(self):
96
branch = self.make_dummy_builder('d').get_branch()
96
b = self.make_dummy_builder('d').get_branch()
98
dc = branch.bzrdir.sprout('dc', force_new_repo=True)
98
dc = b.bzrdir.sprout('dc', force_new_repo=True)
99
99
self.build_tree_contents([("dc/foofile", "blaaaa")])
100
100
dc_tree = dc.open_workingtree()
101
101
dc_tree.add("foofile")
102
102
newrevid = dc_tree.commit('msg')
104
104
self.build_tree_contents([("dc/foofile", "blaaaal")])
105
self.check_output("", "dpush -d dc d")
105
script.run_script(self, '''
106
$ bzr dpush -d dc d --no-strict
107
2>Doing on-the-fly conversion from DummyForeignVcsRepositoryFormat() to RepositoryFormat2a().
108
2>This may take some time. Upgrade the repositories to the same format for better performance.
109
2>Pushed up to revision 2.
106
111
self.assertFileEqual("blaaaal", "dc/foofile")
107
self.check_output('modified:\n foofile\n', "status dc")
112
# if the dummy vcs wasn't that dummy we could uncomment the line below
113
# self.assertFileEqual("blaaaa", "d/foofile")
114
script.run_script(self, '''
109
120
def test_diverged(self):
110
121
builder = self.make_dummy_builder('d')
112
branch = builder.get_branch()
123
b = builder.get_branch()
114
dc = branch.bzrdir.sprout('dc', force_new_repo=True)
125
dc = b.bzrdir.sprout('dc', force_new_repo=True)
115
126
dc_tree = dc.open_workingtree()
117
128
self.build_tree_contents([("dc/foo", "bar")])
123
134
output, error = self.run_bzr("dpush -d dc d", retcode=3)
124
135
self.assertEquals(output, "")
125
136
self.assertContainsRe(error, "have diverged")
139
class TestDpushStrictMixin(object):
142
test_foreign.register_dummy_foreign_for_test(self)
143
# Create an empty branch where we will be able to push
144
self.foreign = self.make_branch(
145
'to', format=test_foreign.DummyForeignVcsDirFormat())
147
def set_config_push_strict(self, value):
148
br = branch.Branch.open('local')
149
br.get_config_stack().set('dpush_strict', value)
151
_default_command = ['dpush', '../to']
154
class TestDpushStrictWithoutChanges(TestDpushStrictMixin,
155
test_push.TestPushStrictWithoutChanges):
158
test_push.TestPushStrictWithoutChanges.setUp(self)
159
TestDpushStrictMixin.setUp(self)
162
class TestDpushStrictWithChanges(TestDpushStrictMixin,
163
test_push.TestPushStrictWithChanges):
165
scenarios = test_push.strict_push_change_scenarios
167
_changes_type = None # Set by load_tests
170
test_push.TestPushStrictWithChanges.setUp(self)
171
TestDpushStrictMixin.setUp(self)
173
def test_push_with_revision(self):
174
raise tests.TestNotApplicable('dpush does not handle --revision')