1
# Copyright (C) 2006, 2007 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
# Author: Aaron Bentley <aaron.bentley@utoronto.ca>
19
"""Black-box tests for bzr merge.
37
class TestMerge(tests.TestCaseWithTransport):
39
def example_branch(self, path='.'):
40
tree = self.make_branch_and_tree(path)
41
self.build_tree_contents([
42
(osutils.pathjoin(path, 'hello'), 'foo'),
43
(osutils.pathjoin(path, 'goodbye'), 'baz')])
45
tree.commit(message='setup')
47
tree.commit(message='setup')
50
def create_conflicting_branches(self):
51
"""Create two branches which have overlapping modifications.
53
:return: (tree, other_branch) Where merging other_branch causes a file
56
builder = self.make_branch_builder('branch')
57
builder.build_snapshot('rev1', None,
58
[('add', ('', 'root-id', 'directory', None)),
59
('add', ('fname', 'f-id', 'file', 'a\nb\nc\n'))])
60
builder.build_snapshot('rev2other', ['rev1'],
61
[('modify', ('f-id', 'a\nB\nD\n'))])
62
other = builder.get_branch().bzrdir.sprout('other').open_branch()
63
builder.build_snapshot('rev2this', ['rev1'],
64
[('modify', ('f-id', 'a\nB\nC\n'))])
65
tree = builder.get_branch().create_checkout('tree', lightweight=True)
68
def test_merge_reprocess(self):
69
d = bzrdir.BzrDir.create_standalone_workingtree('.')
71
self.run_bzr('merge . --reprocess --merge-type weave')
74
a_tree = self.example_branch('a')
75
ancestor = a_tree.branch.revno()
76
b_tree = a_tree.bzrdir.sprout('b').open_workingtree()
77
self.build_tree_contents([('b/goodbye', 'quux')])
78
b_tree.commit(message="more u's are always good")
80
self.build_tree_contents([('a/hello', 'quuux')])
81
# We can't merge when there are in-tree changes
83
self.run_bzr('merge ../b', retcode=3)
84
a = workingtree.WorkingTree.open('.')
85
a_tip = a.commit("Like an epidemic of u's")
86
self.run_bzr('merge ../b -r last:1..last:1 --merge-type blooof',
88
self.run_bzr('merge ../b -r last:1..last:1 --merge-type merge3')
89
a_tree.revert(backups=False)
90
self.run_bzr('merge ../b -r last:1..last:1 --merge-type weave')
91
a_tree.revert(backups=False)
92
self.run_bzr('merge ../b -r last:1..last:1 --merge-type lca')
93
a_tree.revert(backups=False)
94
self.run_bzr_error(['Show-base is not supported for this merge type'],
95
'merge ../b -r last:1..last:1 --merge-type weave'
97
a_tree.revert(backups=False)
98
self.run_bzr('merge ../b -r last:1..last:1 --reprocess')
99
a_tree.revert(backups=False)
100
self.run_bzr('merge ../b -r last:1')
101
self.check_file_contents('goodbye', 'quux')
102
# Merging a branch pulls its revision into the tree
103
b = branch.Branch.open('../b')
104
b_tip = b.last_revision()
105
self.failUnless(a.branch.repository.has_revision(b_tip))
106
self.assertEqual([a_tip, b_tip], a.get_parent_ids())
107
a_tree.revert(backups=False)
108
out, err = self.run_bzr('merge -r revno:1:./hello', retcode=3)
109
self.assertTrue("Not a branch" in err)
110
self.run_bzr('merge -r revno:%d:./..revno:%d:../b'
111
%(ancestor,b.revno()))
112
self.assertEquals(a.get_parent_ids(),
113
[a.branch.last_revision(), b.last_revision()])
114
self.check_file_contents('goodbye', 'quux')
115
a_tree.revert(backups=False)
116
self.run_bzr('merge -r revno:%d:../b'%b.revno())
117
self.assertEquals(a.get_parent_ids(),
118
[a.branch.last_revision(), b.last_revision()])
119
a_tip = a.commit('merged')
120
self.run_bzr('merge ../b -r last:1')
121
self.assertEqual([a_tip], a.get_parent_ids())
123
def test_merge_defaults_to_reprocess(self):
124
tree, other = self.create_conflicting_branches()
125
# The default merge algorithm should enable 'reprocess' because
126
# 'show-base' is not set
127
self.run_bzr('merge ../other', working_dir='tree',
129
self.assertEqualDiff('a\n'
135
'>>>>>>> MERGE-SOURCE\n',
136
tree.get_file_text('f-id'))
138
def test_merge_explicit_reprocess_show_base(self):
139
tree, other = self.create_conflicting_branches()
140
# Explicitly setting --reprocess, and --show-base is an error
141
self.run_bzr_error(['Cannot do conflict reduction and show base'],
142
'merge ../other --reprocess --show-base',
145
def test_merge_override_reprocess(self):
146
tree, other = self.create_conflicting_branches()
147
# Explicitly disable reprocess
148
self.run_bzr('merge ../other --no-reprocess', working_dir='tree',
150
self.assertEqualDiff('a\n'
157
'>>>>>>> MERGE-SOURCE\n',
158
tree.get_file_text('f-id'))
160
def test_merge_override_show_base(self):
161
tree, other = self.create_conflicting_branches()
162
# Setting '--show-base' will auto-disable '--reprocess'
163
self.run_bzr('merge ../other --show-base', working_dir='tree',
165
self.assertEqualDiff('a\n'
169
'||||||| BASE-REVISION\n'
175
'>>>>>>> MERGE-SOURCE\n',
176
tree.get_file_text('f-id'))
178
def test_merge_with_missing_file(self):
179
"""Merge handles missing file conflicts"""
180
self.build_tree_contents([
183
('a/sub/a.txt', 'hello\n'),
184
('a/b.txt', 'hello\n'),
185
('a/sub/c.txt', 'hello\n')])
186
a_tree = self.make_branch_and_tree('a')
187
a_tree.add(['sub', 'b.txt', 'sub/c.txt', 'sub/a.txt'])
188
a_tree.commit(message='added a')
189
b_tree = a_tree.bzrdir.sprout('b').open_workingtree()
190
self.build_tree_contents([
191
('a/sub/a.txt', 'hello\nthere\n'),
192
('a/b.txt', 'hello\nthere\n'),
193
('a/sub/c.txt', 'hello\nthere\n')])
194
a_tree.commit(message='Added there')
195
os.remove('a/sub/a.txt')
196
os.remove('a/sub/c.txt')
199
a_tree.commit(message='Removed a.txt')
200
self.build_tree_contents([
201
('b/sub/a.txt', 'hello\nsomething\n'),
202
('b/b.txt', 'hello\nsomething\n'),
203
('b/sub/c.txt', 'hello\nsomething\n')])
204
b_tree.commit(message='Modified a.txt')
206
self.run_bzr('merge ../a/', retcode=1)
207
self.failUnlessExists('sub/a.txt.THIS')
208
self.failUnlessExists('sub/a.txt.BASE')
210
self.run_bzr('merge ../b/', retcode=1)
211
self.failUnlessExists('sub/a.txt.OTHER')
212
self.failUnlessExists('sub/a.txt.BASE')
214
def test_merge_remember(self):
215
"""Merge changes from one branch to another, test submit location."""
216
tree_a = self.make_branch_and_tree('branch_a')
217
branch_a = tree_a.branch
218
self.build_tree(['branch_a/a'])
220
tree_a.commit('commit a')
221
branch_b = branch_a.bzrdir.sprout('branch_b').open_branch()
222
tree_b = branch_b.bzrdir.open_workingtree()
223
branch_c = branch_a.bzrdir.sprout('branch_c').open_branch()
224
tree_c = branch_c.bzrdir.open_workingtree()
225
self.build_tree(['branch_a/b'])
227
tree_a.commit('commit b')
228
self.build_tree(['branch_c/c'])
230
tree_c.commit('commit c')
232
parent = branch_b.get_parent()
233
branch_b.set_parent(None)
234
self.assertEqual(None, branch_b.get_parent())
235
# test merge for failure without parent set
237
out = self.run_bzr('merge', retcode=3)
238
self.assertEquals(out,
239
('','bzr: ERROR: No location specified or remembered\n'))
241
# test uncommitted changes
242
self.build_tree(['d'])
244
self.run_bzr_error(['Working tree ".*" has uncommitted changes'],
247
# merge should now pass and implicitly remember merge location
248
tree_b.commit('commit d')
249
out, err = self.run_bzr('merge ../branch_a')
251
base = urlutils.local_path_from_url(branch_a.base)
252
self.assertEndsWith(err, '+N b\nAll changes applied successfully.\n')
253
self.assertEquals(osutils.abspath(branch_b.get_submit_branch()),
254
osutils.abspath(parent))
255
# test implicit --remember when committing new file
256
self.build_tree(['e'])
258
tree_b.commit('commit e')
259
out, err = self.run_bzr('merge')
260
self.assertStartsWith(err,
261
'Merging from remembered submit location %s\n' % (base,))
262
# re-open tree as external run_bzr modified it
263
tree_b = branch_b.bzrdir.open_workingtree()
264
tree_b.commit('merge branch_a')
265
# test explicit --remember
266
out, err = self.run_bzr('merge ../branch_c --remember')
267
self.assertEquals(out, '')
268
self.assertEquals(err, '+N c\nAll changes applied successfully.\n')
269
self.assertEquals(osutils.abspath(branch_b.get_submit_branch()),
270
osutils.abspath(branch_c.bzrdir.root_transport.base))
271
# re-open tree as external run_bzr modified it
272
tree_b = branch_b.bzrdir.open_workingtree()
273
tree_b.commit('merge branch_c')
275
def test_merge_bundle(self):
276
from bzrlib.testament import Testament
277
tree_a = self.make_branch_and_tree('branch_a')
278
self.build_tree_contents([('branch_a/a', 'hello')])
280
tree_a.commit('message')
282
tree_b = tree_a.bzrdir.sprout('branch_b').open_workingtree()
283
self.build_tree_contents([('branch_a/a', 'hey there')])
284
tree_a.commit('message')
286
self.build_tree_contents([('branch_b/a', 'goodbye')])
287
tree_b.commit('message')
289
self.run_bzr('bundle ../branch_a -o ../bundle')
290
os.chdir('../branch_a')
291
self.run_bzr('merge ../bundle', retcode=1)
292
testament_a = Testament.from_revision(tree_a.branch.repository,
293
tree_b.get_parent_ids()[0])
294
testament_b = Testament.from_revision(tree_b.branch.repository,
295
tree_b.get_parent_ids()[0])
296
self.assertEqualDiff(testament_a.as_text(),
297
testament_b.as_text())
298
tree_a.set_conflicts(conflicts.ConflictList())
299
tree_a.commit('message')
300
# it is legal to attempt to merge an already-merged bundle
301
output = self.run_bzr('merge ../bundle')[1]
302
# but it does nothing
303
self.assertFalse(tree_a.changes_from(tree_a.basis_tree()).has_changed())
304
self.assertEqual('Nothing to do.\n', output)
306
def test_merge_uncommitted(self):
307
"""Check that merge --uncommitted behaves properly"""
308
tree_a = self.make_branch_and_tree('a')
309
self.build_tree(['a/file_1', 'a/file_2'])
310
tree_a.add(['file_1', 'file_2'])
311
tree_a.commit('commit 1')
312
tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
313
self.failUnlessExists('b/file_1')
314
tree_a.rename_one('file_1', 'file_i')
315
tree_a.commit('commit 2')
316
tree_a.rename_one('file_2', 'file_ii')
318
self.run_bzr('merge a --uncommitted -d b')
319
self.failUnlessExists('b/file_1')
320
self.failUnlessExists('b/file_ii')
322
self.run_bzr_error(('Cannot use --uncommitted and --revision',),
323
'merge /a --uncommitted -r1 -d b')
325
def test_merge_uncommitted_file(self):
326
"""It should be possible to merge changes from a single file."""
327
tree_a = self.make_branch_and_tree('tree_a')
328
tree_a.commit('initial commit')
329
tree_a.bzrdir.sprout('tree_b')
330
self.build_tree(['tree_a/file1', 'tree_a/file2'])
331
tree_a.add(['file1', 'file2'])
333
self.run_bzr(['merge', '--uncommitted', '../tree_a/file1'])
334
self.failUnlessExists('file1')
335
self.failIfExists('file2')
337
def pullable_branch(self):
338
tree_a = self.make_branch_and_tree('a')
339
self.build_tree(['a/file'])
341
self.id1 = tree_a.commit('commit 1')
343
tree_b = self.make_branch_and_tree('b')
344
tree_b.pull(tree_a.branch)
345
file('b/file', 'wb').write('foo')
346
self.id2 = tree_b.commit('commit 2')
348
def test_merge_pull(self):
349
self.pullable_branch()
351
(out, err) = self.run_bzr('merge --pull ../b')
352
self.assertContainsRe(out, 'Now on revision 2\\.')
353
tree_a = workingtree.WorkingTree.open('.')
354
self.assertEqual([self.id2], tree_a.get_parent_ids())
356
def test_merge_kind_change(self):
357
tree_a = self.make_branch_and_tree('tree_a')
358
self.build_tree_contents([('tree_a/file', 'content_1')])
359
tree_a.add('file', 'file-id')
360
tree_a.commit('added file')
361
tree_b = tree_a.bzrdir.sprout('tree_b').open_workingtree()
362
os.unlink('tree_a/file')
363
self.build_tree(['tree_a/file/'])
364
tree_a.commit('changed file to directory')
366
self.run_bzr('merge ../tree_a')
367
self.assertEqual('directory', osutils.file_kind('file'))
369
self.assertEqual('file', osutils.file_kind('file'))
370
self.build_tree_contents([('file', 'content_2')])
371
tree_b.commit('content change')
372
self.run_bzr('merge ../tree_a', retcode=1)
373
self.assertEqual(tree_b.conflicts(),
374
[conflicts.ContentsConflict('file',
377
def test_directive_cherrypick(self):
378
source = self.make_branch_and_tree('source')
379
source.commit("nothing")
380
# see https://bugs.edge.launchpad.net/bzr/+bug/409688 - trying to
381
# cherrypick from one branch into another unrelated branch with a
382
# different root id will give shape conflicts. as a workaround we
383
# make sure they share the same root id.
384
target = source.bzrdir.sprout('target').open_workingtree()
385
self.build_tree(['source/a'])
387
source.commit('Added a', rev_id='rev1')
388
self.build_tree(['source/b'])
390
source.commit('Added b', rev_id='rev2')
391
target.commit('empty commit')
392
self.write_directive('directive', source.branch, 'target', 'rev2',
394
out, err = self.run_bzr('merge -d target directive')
395
self.failIfExists('target/a')
396
self.failUnlessExists('target/b')
397
self.assertContainsRe(err, 'Performing cherrypick')
399
def write_directive(self, filename, source, target, revision_id,
400
base_revision_id=None, mangle_patch=False):
401
md = merge_directive.MergeDirective2.from_objects(
402
source.repository, revision_id, 0, 0, target,
403
base_revision_id=base_revision_id)
406
self.build_tree_contents([(filename, ''.join(md.to_lines()))])
408
def test_directive_verify_warning(self):
409
source = self.make_branch_and_tree('source')
410
self.build_tree(['source/a'])
412
source.commit('Added a', rev_id='rev1')
413
target = self.make_branch_and_tree('target')
414
target.commit('empty commit')
415
self.write_directive('directive', source.branch, 'target', 'rev1')
416
err = self.run_bzr('merge -d target directive')[1]
417
self.assertNotContainsRe(err, 'Preview patch does not match changes')
419
self.write_directive('directive', source.branch, 'target', 'rev1',
421
err = self.run_bzr('merge -d target directive')[1]
422
self.assertContainsRe(err, 'Preview patch does not match changes')
424
def test_merge_arbitrary(self):
425
target = self.make_branch_and_tree('target')
426
target.commit('empty')
427
# We need a revision that has no integer revno
428
branch_a = target.bzrdir.sprout('branch_a').open_workingtree()
429
self.build_tree(['branch_a/file1'])
430
branch_a.add('file1')
431
branch_a.commit('added file1', rev_id='rev2a')
432
branch_b = target.bzrdir.sprout('branch_b').open_workingtree()
433
self.build_tree(['branch_b/file2'])
434
branch_b.add('file2')
435
branch_b.commit('added file2', rev_id='rev2b')
436
branch_b.merge_from_branch(branch_a.branch)
437
self.failUnlessExists('branch_b/file1')
438
branch_b.commit('merged branch_a', rev_id='rev3b')
440
# It works if the revid has an interger revno
441
self.run_bzr('merge -d target -r revid:rev2a branch_a')
442
self.failUnlessExists('target/file1')
443
self.failIfExists('target/file2')
446
# It should work if the revid has no integer revno
447
self.run_bzr('merge -d target -r revid:rev2a branch_b')
448
self.failUnlessExists('target/file1')
449
self.failIfExists('target/file2')
451
def assertDirectoryContent(self, directory, entries, message=''):
452
"""Assert whether entries (file or directories) exist in a directory.
454
It also checks that there are no extra entries.
456
ondisk = os.listdir(directory)
457
if set(ondisk) == set(entries):
461
raise AssertionError(
462
'%s"%s" directory content is different:\na = %s\nb = %s\n'
463
% (message, directory, sorted(entries), sorted(ondisk)))
465
def test_cherrypicking_merge(self):
467
source = self.make_branch_and_tree('source')
468
for f in ('a', 'b', 'c', 'd'):
469
self.build_tree(['source/'+f])
471
source.commit('added '+f, rev_id='rev_'+f)
473
target = source.bzrdir.sprout('target', 'rev_a').open_workingtree()
474
self.assertDirectoryContent('target', ['.bzr', 'a'])
476
self.run_bzr('merge -d target -r revid:rev_b..revid:rev_c source')
477
self.assertDirectoryContent('target', ['.bzr', 'a', 'c'])
480
self.run_bzr('merge -d target -r revid:rev_b..revid:rev_d source')
481
self.assertDirectoryContent('target', ['.bzr', 'a', 'c', 'd'])
483
# pick 1 revision with option --changes
484
self.run_bzr('merge -d target -c revid:rev_d source')
485
self.assertDirectoryContent('target', ['.bzr', 'a', 'd'])
487
def test_merge_criss_cross(self):
488
tree_a = self.make_branch_and_tree('a')
489
tree_a.commit('', rev_id='rev1')
490
tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
491
tree_a.commit('', rev_id='rev2a')
492
tree_b.commit('', rev_id='rev2b')
493
tree_a.merge_from_branch(tree_b.branch)
494
tree_b.merge_from_branch(tree_a.branch)
495
tree_a.commit('', rev_id='rev3a')
496
tree_b.commit('', rev_id='rev3b')
497
graph = tree_a.branch.repository.get_graph(tree_b.branch.repository)
498
out, err = self.run_bzr(['merge', '-d', 'a', 'b'])
499
self.assertContainsRe(err, 'Warning: criss-cross merge encountered.')
501
def test_merge_from_submit(self):
502
tree_a = self.make_branch_and_tree('a')
503
tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
504
tree_c = tree_a.bzrdir.sprout('c').open_workingtree()
505
out, err = self.run_bzr(['merge', '-d', 'c'])
506
self.assertContainsRe(err, 'Merging from remembered parent location .*a\/')
507
tree_c.branch.set_submit_branch(tree_b.bzrdir.root_transport.base)
508
out, err = self.run_bzr(['merge', '-d', 'c'])
509
self.assertContainsRe(err, 'Merging from remembered submit location .*b\/')
511
def test_remember_sets_submit(self):
512
tree_a = self.make_branch_and_tree('a')
513
tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
514
self.assertIs(tree_b.branch.get_submit_branch(), None)
516
# Remember should not happen if using default from parent
517
out, err = self.run_bzr(['merge', '-d', 'b'])
518
self.assertIs(tree_b.branch.get_submit_branch(), None)
520
# Remember should happen if user supplies location
521
out, err = self.run_bzr(['merge', '-d', 'b', 'a'])
522
self.assertEqual(tree_b.branch.get_submit_branch(),
523
tree_a.bzrdir.root_transport.base)
525
def test_weave_cherrypick(self):
526
this_tree = self.make_branch_and_tree('this')
527
self.build_tree_contents([('this/file', "a\n")])
528
this_tree.add('file')
529
this_tree.commit('rev1')
530
other_tree = this_tree.bzrdir.sprout('other').open_workingtree()
531
self.build_tree_contents([('other/file', "a\nb\n")])
532
other_tree.commit('rev2b')
533
self.build_tree_contents([('other/file', "c\na\nb\n")])
534
other_tree.commit('rev3b')
535
self.run_bzr('merge --weave -d this other -r -2..-1')
536
self.assertFileEqual('c\na\n', 'this/file')
538
def test_lca_merge_criss_cross(self):
539
tree_a = self.make_branch_and_tree('a')
540
self.build_tree_contents([('a/file', 'base-contents\n')])
542
tree_a.commit('', rev_id='rev1')
543
tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
544
self.build_tree_contents([('a/file',
545
'base-contents\nthis-contents\n')])
546
tree_a.commit('', rev_id='rev2a')
547
self.build_tree_contents([('b/file',
548
'base-contents\nother-contents\n')])
549
tree_b.commit('', rev_id='rev2b')
550
tree_a.merge_from_branch(tree_b.branch)
551
self.build_tree_contents([('a/file',
552
'base-contents\nthis-contents\n')])
553
tree_a.set_conflicts(conflicts.ConflictList())
554
tree_b.merge_from_branch(tree_a.branch)
555
self.build_tree_contents([('b/file',
556
'base-contents\nother-contents\n')])
557
tree_b.set_conflicts(conflicts.ConflictList())
558
tree_a.commit('', rev_id='rev3a')
559
tree_b.commit('', rev_id='rev3b')
560
out, err = self.run_bzr(['merge', '-d', 'a', 'b', '--lca'], retcode=1)
561
self.assertFileEqual('base-contents\n<<<<<<< TREE\nthis-contents\n'
562
'=======\nother-contents\n>>>>>>> MERGE-SOURCE\n',
565
def test_merge_preview(self):
566
this_tree = self.make_branch_and_tree('this')
567
this_tree.commit('rev1')
568
other_tree = this_tree.bzrdir.sprout('other').open_workingtree()
569
self.build_tree_contents([('other/file', 'new line')])
570
other_tree.add('file')
571
other_tree.commit('rev2a')
572
this_tree.commit('rev2b')
573
out, err = self.run_bzr(['merge', '-d', 'this', 'other', '--preview'])
574
self.assertContainsRe(out, '\+new line')
575
self.assertNotContainsRe(err, '\+N file\n')
576
this_tree.lock_read()
577
self.addCleanup(this_tree.unlock)
579
list(this_tree.iter_changes(this_tree.basis_tree())))
581
def test_merge_missing_second_revision_spec(self):
582
"""Merge uses branch basis when the second revision is unspecified."""
583
this = self.make_branch_and_tree('this')
585
other = self.make_branch_and_tree('other')
586
self.build_tree(['other/other_file'])
587
other.add('other_file')
588
other.commit('rev1b')
589
self.run_bzr('merge -d this other -r0..')
590
self.failUnlessExists('this/other_file')
592
def test_merge_interactive_unlocks_branch(self):
593
this = self.make_branch_and_tree('this')
594
other = self.make_branch_and_tree('other')
595
other.commit('empty commit')
596
self.run_bzr('merge -i -d this other')
600
def test_merge_reversed_revision_range(self):
601
tree = self.make_branch_and_tree(".")
605
tree.commit("added "+f)
606
for context in (".", "", "a"):
607
self.run_bzr("merge -r 1..0 " + context)
608
self.failIfExists("a")
610
self.failUnlessExists("a")
613
class TestMergeForce(tests.TestCaseWithTransport):
616
super(TestMergeForce, self).setUp()
617
self.tree_a = self.make_branch_and_tree('a')
618
self.build_tree(['a/foo'])
619
self.tree_a.add(['foo'])
620
self.tree_a.commit('add file')
621
self.tree_b = self.tree_a.bzrdir.sprout('b').open_workingtree()
622
self.build_tree_contents([('a/foo', 'change 1')])
623
self.tree_a.commit('change file')
624
self.tree_b.merge_from_branch(self.tree_a.branch)
626
def test_merge_force(self):
627
self.tree_a.commit('empty change to allow merge to run')
628
# Second merge on top of the uncommitted one
629
self.run_bzr(['merge', '../a', '--force'], working_dir='b')
632
def test_merge_with_uncommitted_changes(self):
633
self.run_bzr_error(['Working tree .* has uncommitted changes'],
634
['merge', '../a'], working_dir='b')
636
def test_merge_with_pending_merges(self):
637
# Revert the changes keeping the pending merge
638
self.run_bzr(['revert', 'b'])
639
self.run_bzr_error(['Working tree .* has uncommitted changes'],
640
['merge', '../a'], working_dir='b')