234
233
tree_a.commit('commit 2')
235
234
tree_a.rename_one('file_2', 'file_ii')
237
self.run_bzr('merge a --uncommitted -d b')
236
self.run_bzr('merge', 'a', '--uncommitted', '-d', 'b')
238
237
self.failUnlessExists('b/file_1')
239
238
self.failUnlessExists('b/file_ii')
240
239
tree_b.revert([])
241
240
self.run_bzr_error(('Cannot use --uncommitted and --revision',),
242
'merge /a --uncommitted -r1 -d b')
241
'merge', '/a', '--uncommitted', '-r1',
244
244
def pullable_branch(self):
266
266
def test_merge_pull(self):
267
267
self.pullable_branch()
269
(out, err) = self.run_bzr('merge --pull ../b')
269
(out, err) = self.run_bzr('merge', '--pull', '../b')
270
270
self.assertContainsRe(err, 'Now on revision 2\\.')
271
271
tree_a = WorkingTree.open('.')
272
272
self.assertEqual([self.id2], tree_a.get_parent_ids())
281
281
self.build_tree(['tree_a/file/'])
282
282
tree_a.commit('changed file to directory')
283
283
os.chdir('tree_b')
284
self.run_bzr('merge ../tree_a')
284
self.run_bzr('merge', '../tree_a')
285
285
self.assertEqual('directory', file_kind('file'))
286
286
tree_b.revert([])
287
287
self.assertEqual('file', file_kind('file'))
288
288
self.build_tree_contents([('file', 'content_2')])
289
289
tree_b.commit('content change')
290
self.run_bzr('merge ../tree_a', retcode=1)
290
self.run_bzr('merge', '../tree_a', retcode=1)
291
291
self.assertEqual(tree_b.conflicts(),
292
292
[ContentsConflict('file', file_id='file-id')])
294
def test_directive_cherrypick(self):
295
source = self.make_branch_and_tree('source')
296
self.build_tree(['source/a'])
298
source.commit('Added a', rev_id='rev1')
299
self.build_tree(['source/b'])
301
source.commit('Added b', rev_id='rev2')
302
target = self.make_branch_and_tree('target')
303
target.commit('empty commit')
304
self.write_directive('directive', source.branch, 'target', 'rev2',
306
self.run_bzr('merge -d target directive')
307
self.failIfExists('target/a')
308
self.failUnlessExists('target/b')
310
def write_directive(self, filename, source, target, revision_id,
311
base_revision_id=None, mangle_patch=False):
312
md = merge_directive.MergeDirective2.from_objects(
313
source.repository, revision_id, 0, 0, target,
314
base_revision_id=base_revision_id)
317
self.build_tree_contents([(filename, ''.join(md.to_lines()))])
319
def test_directive_verify_warning(self):
320
source = self.make_branch_and_tree('source')
321
self.build_tree(['source/a'])
323
source.commit('Added a', rev_id='rev1')
324
target = self.make_branch_and_tree('target')
325
target.commit('empty commit')
326
self.write_directive('directive', source.branch, 'target', 'rev1')
327
err = self.run_bzr('merge -d target directive')[1]
328
self.assertNotContainsRe(err, 'Preview patch does not match changes')
330
self.write_directive('directive', source.branch, 'target', 'rev1',
332
err = self.run_bzr('merge -d target directive')[1]
333
self.assertContainsRe(err, 'Preview patch does not match changes')