36
40
class TestMergeDirective(tests.TestCaseWithTransport):
38
42
def prepare_merge_directive(self):
39
tree1 = self.make_branch_and_tree('tree1')
43
self.tree1 = self.make_branch_and_tree('tree1')
40
44
self.build_tree_contents([('tree1/file', 'a\nb\nc\nd\n')])
41
tree1.branch.get_config().set_user_option('email',
45
self.tree1.branch.get_config().set_user_option('email',
42
46
'J. Random Hacker <jrandom@example.com>')
45
tree2=tree1.bzrdir.sprout('tree2').open_workingtree()
47
self.tree1.add('file')
48
self.tree1.commit('foo')
49
self.tree2 = self.tree1.bzrdir.sprout('tree2').open_workingtree()
46
50
self.build_tree_contents([('tree1/file', 'a\nb\nc\nd\ne\n')])
51
self.tree1.commit('bar', rev_id='bar-id')
53
return self.tree1, self.tree2
51
55
def test_merge_directive(self):
52
56
self.prepare_merge_directive()
132
136
'pqm@example.com'), call[1:3])
133
137
self.assertContainsRe(call[3], EMAIL1)
139
def test_pull_raw(self):
140
self.prepare_merge_directive()
141
self.tree1.commit('baz', rev_id='baz-id')
142
md_text = self.run_bzr('merge-directive', self.tree2.basedir,
143
'-r', '2', self.tree1.basedir, '--plain')[0]
144
self.build_tree_contents([('../directive', md_text)])
146
self.run_bzr('pull', '../directive')
147
wt = workingtree.WorkingTree.open('.')
148
self.assertEqual('bar-id', wt.last_revision())
150
def test_pull_user_r(self):
151
"""If the user supplies -r, an error is emitted"""
152
self.prepare_merge_directive()
153
self.tree1.commit('baz', rev_id='baz-id')
154
md_text = self.run_bzr('merge-directive', self.tree2.basedir,
155
self.tree1.basedir, '--plain')[0]
156
self.build_tree_contents([('../directive', md_text)])
159
('Cannot use -r with merge directives or bundles',),
160
'pull', '-r', '2', '../directive')
162
def test_pull_bundle(self):
163
self.prepare_merge_directive()
164
self.tree1.commit('baz', rev_id='baz-id')
165
md_text = self.run_bzr('merge-directive', self.tree2.basedir,
166
'-r', '2', '/dev/null', '--bundle')[0]
167
self.build_tree_contents([('../directive', md_text)])
169
self.run_bzr('pull', '../directive')
170
wt = workingtree.WorkingTree.open('.')
171
self.assertEqual('bar-id', wt.last_revision())
173
def test_merge_raw(self):
174
self.prepare_merge_directive()
175
self.tree1.commit('baz', rev_id='baz-id')
176
md_text = self.run_bzr('merge-directive', self.tree2.basedir,
177
'-r', '2', self.tree1.basedir, '--plain')[0]
178
self.build_tree_contents([('../directive', md_text)])
180
self.run_bzr('merge', '../directive')
181
wt = workingtree.WorkingTree.open('.')
182
self.assertEqual('bar-id', wt.get_parent_ids()[1])
184
def test_merge_user_r(self):
185
"""If the user supplies -r, an error is emitted"""
186
self.prepare_merge_directive()
187
self.tree1.commit('baz', rev_id='baz-id')
188
md_text = self.run_bzr('merge-directive', self.tree2.basedir,
189
self.tree1.basedir, '--plain')[0]
190
self.build_tree_contents([('../directive', md_text)])
193
('Cannot use -r with merge directives or bundles',),
194
'merge', '-r', '2', '../directive')
196
def test_merge_bundle(self):
197
self.prepare_merge_directive()
198
self.tree1.commit('baz', rev_id='baz-id')
199
md_text = self.run_bzr('merge-directive', self.tree2.basedir,
200
'-r', '2', '/dev/null', '--bundle')[0]
201
self.build_tree_contents([('../directive', md_text)])
203
self.run_bzr('merge', '../directive')
204
wt = workingtree.WorkingTree.open('.')
205
self.assertEqual('bar-id', wt.get_parent_ids()[1])
135
207
def test_mail_uses_config(self):
136
208
tree1, tree2 = self.prepare_merge_directive()
137
209
tree1.branch.get_config().set_user_option('smtp_server', 'bogushost')