13
13
# You should have received a copy of the GNU General Public License
14
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
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
17
# Author: Aaron Bentley <aaron.bentley@utoronto.ca>
19
19
"""Black-box tests for bzr merge.
25
from testtools import matchers
37
from bzrlib.tests import (
43
load_tests = scenarios.load_tests_apply_scenarios
46
class TestMerge(tests.TestCaseWithTransport):
48
def example_branch(self, path='.'):
49
tree = self.make_branch_and_tree(path)
50
self.build_tree_contents([
51
(osutils.pathjoin(path, 'hello'), 'foo'),
52
(osutils.pathjoin(path, 'goodbye'), 'baz')])
54
tree.commit(message='setup')
56
tree.commit(message='setup')
59
def create_conflicting_branches(self):
60
"""Create two branches which have overlapping modifications.
62
:return: (tree, other_branch) Where merging other_branch causes a file
65
builder = self.make_branch_builder('branch')
66
builder.build_snapshot('rev1', None,
67
[('add', ('', 'root-id', 'directory', None)),
68
('add', ('fname', 'f-id', 'file', 'a\nb\nc\n'))])
69
builder.build_snapshot('rev2other', ['rev1'],
70
[('modify', ('f-id', 'a\nB\nD\n'))])
71
other = builder.get_branch().bzrdir.sprout('other').open_branch()
72
builder.build_snapshot('rev2this', ['rev1'],
73
[('modify', ('f-id', 'a\nB\nC\n'))])
74
tree = builder.get_branch().create_checkout('tree', lightweight=True)
24
from bzrlib import merge_directive
25
from bzrlib.branch import Branch
26
from bzrlib.bzrdir import BzrDir
27
from bzrlib.conflicts import ConflictList, ContentsConflict
28
from bzrlib.osutils import abspath, file_kind
29
from bzrlib.tests.blackbox import ExternalBase
30
import bzrlib.urlutils as urlutils
31
from bzrlib.workingtree import WorkingTree
34
class TestMerge(ExternalBase):
36
def example_branch(test):
38
file('hello', 'wt').write('foo')
39
test.run_bzr('add hello')
40
test.run_bzr('commit -m setup hello')
41
file('goodbye', 'wt').write('baz')
42
test.run_bzr('add goodbye')
43
test.run_bzr('commit -m setup goodbye')
77
45
def test_merge_reprocess(self):
78
d = bzrdir.BzrDir.create_standalone_workingtree('.')
46
d = BzrDir.create_standalone_workingtree('.')
80
48
self.run_bzr('merge . --reprocess --merge-type weave')
82
50
def test_merge(self):
83
a_tree = self.example_branch('a')
84
ancestor = a_tree.branch.revno()
85
b_tree = a_tree.bzrdir.sprout('b').open_workingtree()
86
self.build_tree_contents([('b/goodbye', 'quux')])
87
b_tree.commit(message="more u's are always good")
51
from bzrlib.branch import Branch
56
ancestor = Branch.open('.').revno()
58
self.run_bzr('branch a b')
60
file('goodbye', 'wt').write('quux')
61
self.run_bzr(['commit', '-m', "more u's are always good"])
89
self.build_tree_contents([('a/hello', 'quuux')])
64
file('hello', 'wt').write('quuux')
90
65
# We can't merge when there are in-tree changes
92
66
self.run_bzr('merge ../b', retcode=3)
93
a = workingtree.WorkingTree.open('.')
67
a = WorkingTree.open('.')
94
68
a_tip = a.commit("Like an epidemic of u's")
95
69
self.run_bzr('merge ../b -r last:1..last:1 --merge-type blooof',
97
71
self.run_bzr('merge ../b -r last:1..last:1 --merge-type merge3')
98
a_tree.revert(backups=False)
72
self.run_bzr('revert --no-backup')
99
73
self.run_bzr('merge ../b -r last:1..last:1 --merge-type weave')
100
a_tree.revert(backups=False)
101
self.run_bzr('merge ../b -r last:1..last:1 --merge-type lca')
102
a_tree.revert(backups=False)
74
self.run_bzr('revert --no-backup')
103
75
self.run_bzr_error(['Show-base is not supported for this merge type'],
104
76
'merge ../b -r last:1..last:1 --merge-type weave'
106
a_tree.revert(backups=False)
78
self.run_bzr('revert --no-backup')
107
79
self.run_bzr('merge ../b -r last:1..last:1 --reprocess')
108
a_tree.revert(backups=False)
80
self.run_bzr('revert --no-backup')
109
81
self.run_bzr('merge ../b -r last:1')
110
82
self.check_file_contents('goodbye', 'quux')
111
83
# Merging a branch pulls its revision into the tree
112
b = branch.Branch.open('../b')
84
b = Branch.open('../b')
113
85
b_tip = b.last_revision()
114
self.assertTrue(a.branch.repository.has_revision(b_tip))
86
self.failUnless(a.branch.repository.has_revision(b_tip))
115
87
self.assertEqual([a_tip, b_tip], a.get_parent_ids())
116
a_tree.revert(backups=False)
88
self.run_bzr('revert --no-backup')
117
89
out, err = self.run_bzr('merge -r revno:1:./hello', retcode=3)
118
90
self.assertTrue("Not a branch" in err)
119
91
self.run_bzr('merge -r revno:%d:./..revno:%d:../b'
120
92
%(ancestor,b.revno()))
121
self.assertEquals(a.get_parent_ids(),
93
self.assertEquals(a.get_parent_ids(),
122
94
[a.branch.last_revision(), b.last_revision()])
123
95
self.check_file_contents('goodbye', 'quux')
124
a_tree.revert(backups=False)
96
self.run_bzr('revert --no-backup')
125
97
self.run_bzr('merge -r revno:%d:../b'%b.revno())
126
98
self.assertEquals(a.get_parent_ids(),
127
99
[a.branch.last_revision(), b.last_revision()])
129
101
self.run_bzr('merge ../b -r last:1')
130
102
self.assertEqual([a_tip], a.get_parent_ids())
132
def test_merge_defaults_to_reprocess(self):
133
tree, other = self.create_conflicting_branches()
134
# The default merge algorithm should enable 'reprocess' because
135
# 'show-base' is not set
136
self.run_bzr('merge ../other', working_dir='tree',
138
self.assertEqualDiff('a\n'
144
'>>>>>>> MERGE-SOURCE\n',
145
tree.get_file_text('f-id'))
147
def test_merge_explicit_reprocess_show_base(self):
148
tree, other = self.create_conflicting_branches()
149
# Explicitly setting --reprocess, and --show-base is an error
150
self.run_bzr_error(['Cannot do conflict reduction and show base'],
151
'merge ../other --reprocess --show-base',
154
def test_merge_override_reprocess(self):
155
tree, other = self.create_conflicting_branches()
156
# Explicitly disable reprocess
157
self.run_bzr('merge ../other --no-reprocess', working_dir='tree',
159
self.assertEqualDiff('a\n'
166
'>>>>>>> MERGE-SOURCE\n',
167
tree.get_file_text('f-id'))
169
def test_merge_override_show_base(self):
170
tree, other = self.create_conflicting_branches()
171
# Setting '--show-base' will auto-disable '--reprocess'
172
self.run_bzr('merge ../other --show-base', working_dir='tree',
174
self.assertEqualDiff('a\n'
178
'||||||| BASE-REVISION\n'
184
'>>>>>>> MERGE-SOURCE\n',
185
tree.get_file_text('f-id'))
187
104
def test_merge_with_missing_file(self):
188
105
"""Merge handles missing file conflicts"""
189
self.build_tree_contents([
192
('a/sub/a.txt', 'hello\n'),
193
('a/b.txt', 'hello\n'),
194
('a/sub/c.txt', 'hello\n')])
195
a_tree = self.make_branch_and_tree('a')
196
a_tree.add(['sub', 'b.txt', 'sub/c.txt', 'sub/a.txt'])
197
a_tree.commit(message='added a')
198
b_tree = a_tree.bzrdir.sprout('b').open_workingtree()
199
self.build_tree_contents([
200
('a/sub/a.txt', 'hello\nthere\n'),
201
('a/b.txt', 'hello\nthere\n'),
202
('a/sub/c.txt', 'hello\nthere\n')])
203
a_tree.commit(message='Added there')
204
os.remove('a/sub/a.txt')
205
os.remove('a/sub/c.txt')
208
a_tree.commit(message='Removed a.txt')
209
self.build_tree_contents([
210
('b/sub/a.txt', 'hello\nsomething\n'),
211
('b/b.txt', 'hello\nsomething\n'),
212
('b/sub/c.txt', 'hello\nsomething\n')])
213
b_tree.commit(message='Modified a.txt')
109
print >> file('sub/a.txt', 'wb'), "hello"
110
print >> file('b.txt', 'wb'), "hello"
111
print >> file('sub/c.txt', 'wb'), "hello"
114
self.run_bzr(['commit', '-m', 'added a'])
115
self.run_bzr('branch . ../b')
116
print >> file('sub/a.txt', 'ab'), "there"
117
print >> file('b.txt', 'ab'), "there"
118
print >> file('sub/c.txt', 'ab'), "there"
119
self.run_bzr(['commit', '-m', 'Added there'])
120
os.unlink('sub/a.txt')
121
os.unlink('sub/c.txt')
124
self.run_bzr(['commit', '-m', 'Removed a.txt'])
126
print >> file('sub/a.txt', 'ab'), "something"
127
print >> file('b.txt', 'ab'), "something"
128
print >> file('sub/c.txt', 'ab'), "something"
129
self.run_bzr(['commit', '-m', 'Modified a.txt'])
215
130
self.run_bzr('merge ../a/', retcode=1)
216
self.assertPathExists('sub/a.txt.THIS')
217
self.assertPathExists('sub/a.txt.BASE')
131
self.assert_(os.path.exists('sub/a.txt.THIS'))
132
self.assert_(os.path.exists('sub/a.txt.BASE'))
219
134
self.run_bzr('merge ../b/', retcode=1)
220
self.assertPathExists('sub/a.txt.OTHER')
221
self.assertPathExists('sub/a.txt.BASE')
223
def test_conflict_leaves_base_this_other_files(self):
224
tree, other = self.create_conflicting_branches()
225
self.run_bzr('merge ../other', working_dir='tree',
227
self.assertFileEqual('a\nb\nc\n', 'tree/fname.BASE')
228
self.assertFileEqual('a\nB\nD\n', 'tree/fname.OTHER')
229
self.assertFileEqual('a\nB\nC\n', 'tree/fname.THIS')
231
def test_weave_conflict_leaves_base_this_other_files(self):
232
tree, other = self.create_conflicting_branches()
233
self.run_bzr('merge ../other --weave', working_dir='tree',
235
self.assertFileEqual('a\nb\nc\n', 'tree/fname.BASE')
236
self.assertFileEqual('a\nB\nD\n', 'tree/fname.OTHER')
237
self.assertFileEqual('a\nB\nC\n', 'tree/fname.THIS')
135
self.assert_(os.path.exists('sub/a.txt.OTHER'))
136
self.assert_(os.path.exists('sub/a.txt.BASE'))
239
138
def test_merge_remember(self):
240
"""Merge changes from one branch to another, test submit location."""
139
"""Merge changes from one branch to another and test parent location."""
241
140
tree_a = self.make_branch_and_tree('branch_a')
242
141
branch_a = tree_a.branch
243
142
self.build_tree(['branch_a/a'])
335
233
tree_a.add(['file_1', 'file_2'])
336
234
tree_a.commit('commit 1')
337
235
tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
338
self.assertPathExists('b/file_1')
236
self.failUnlessExists('b/file_1')
339
237
tree_a.rename_one('file_1', 'file_i')
340
238
tree_a.commit('commit 2')
341
239
tree_a.rename_one('file_2', 'file_ii')
343
241
self.run_bzr('merge a --uncommitted -d b')
344
self.assertPathExists('b/file_1')
345
self.assertPathExists('b/file_ii')
242
self.failUnlessExists('b/file_1')
243
self.failUnlessExists('b/file_ii')
347
245
self.run_bzr_error(('Cannot use --uncommitted and --revision',),
348
246
'merge /a --uncommitted -r1 -d b')
350
def test_merge_uncommitted_file(self):
351
"""It should be possible to merge changes from a single file."""
352
tree_a = self.make_branch_and_tree('tree_a')
353
tree_a.commit('initial commit')
354
tree_a.bzrdir.sprout('tree_b')
355
self.build_tree(['tree_a/file1', 'tree_a/file2'])
356
tree_a.add(['file1', 'file2'])
358
self.run_bzr(['merge', '--uncommitted', '../tree_a/file1'])
359
self.assertPathExists('file1')
360
self.assertPathDoesNotExist('file2')
362
def test_merge_nonexistent_file(self):
363
"""It should not be possible to merge changes from a file which
365
tree_a = self.make_branch_and_tree('tree_a')
366
self.build_tree_contents([('tree_a/file', 'bar\n')])
368
tree_a.commit('commit 1')
370
self.run_bzr_error(('Path\(s\) do not exist: non/existing',),
371
['merge', 'non/existing'])
248
def pullable_branch(self):
251
self.example_branch()
253
self.run_bzr('branch a b')
255
file('goodbye', 'wt').write('quux')
256
self.run_bzr(['commit', '-m', "mode u's are always good"])
373
259
def pullable_branch(self):
374
260
tree_a = self.make_branch_and_tree('a')
375
self.build_tree_contents([('a/file', 'bar\n')])
261
self.build_tree(['a/file'])
376
262
tree_a.add(['file'])
377
263
self.id1 = tree_a.commit('commit 1')
379
265
tree_b = self.make_branch_and_tree('b')
380
266
tree_b.pull(tree_a.branch)
381
self.build_tree_contents([('b/file', 'foo\n')])
267
file('b/file', 'wb').write('foo')
382
268
self.id2 = tree_b.commit('commit 2')
384
270
def test_merge_pull(self):
485
349
branch_b.add('file2')
486
350
branch_b.commit('added file2', rev_id='rev2b')
487
351
branch_b.merge_from_branch(branch_a.branch)
488
self.assertPathExists('branch_b/file1')
352
self.failUnlessExists('branch_b/file1')
489
353
branch_b.commit('merged branch_a', rev_id='rev3b')
491
355
# It works if the revid has an interger revno
492
356
self.run_bzr('merge -d target -r revid:rev2a branch_a')
493
self.assertPathExists('target/file1')
494
self.assertPathDoesNotExist('target/file2')
357
self.failUnlessExists('target/file1')
358
self.failIfExists('target/file2')
497
361
# It should work if the revid has no integer revno
498
362
self.run_bzr('merge -d target -r revid:rev2a branch_b')
499
self.assertPathExists('target/file1')
500
self.assertPathDoesNotExist('target/file2')
502
def assertDirectoryContent(self, directory, entries, message=''):
503
"""Assert whether entries (file or directories) exist in a directory.
505
It also checks that there are no extra entries.
507
ondisk = os.listdir(directory)
508
if set(ondisk) == set(entries):
512
raise AssertionError(
513
'%s"%s" directory content is different:\na = %s\nb = %s\n'
514
% (message, directory, sorted(entries), sorted(ondisk)))
516
def test_cherrypicking_merge(self):
518
source = self.make_branch_and_tree('source')
519
for f in ('a', 'b', 'c', 'd'):
520
self.build_tree(['source/'+f])
522
source.commit('added '+f, rev_id='rev_'+f)
524
target = source.bzrdir.sprout('target', 'rev_a').open_workingtree()
525
self.assertDirectoryContent('target', ['.bzr', 'a'])
527
self.run_bzr('merge -d target -r revid:rev_b..revid:rev_c source')
528
self.assertDirectoryContent('target', ['.bzr', 'a', 'c'])
531
self.run_bzr('merge -d target -r revid:rev_b..revid:rev_d source')
532
self.assertDirectoryContent('target', ['.bzr', 'a', 'c', 'd'])
534
# pick 1 revision with option --changes
535
self.run_bzr('merge -d target -c revid:rev_d source')
536
self.assertDirectoryContent('target', ['.bzr', 'a', 'd'])
538
def test_merge_criss_cross(self):
539
tree_a = self.make_branch_and_tree('a')
540
tree_a.commit('', rev_id='rev1')
541
tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
542
tree_a.commit('', rev_id='rev2a')
543
tree_b.commit('', rev_id='rev2b')
544
tree_a.merge_from_branch(tree_b.branch)
545
tree_b.merge_from_branch(tree_a.branch)
546
tree_a.commit('', rev_id='rev3a')
547
tree_b.commit('', rev_id='rev3b')
548
graph = tree_a.branch.repository.get_graph(tree_b.branch.repository)
549
out, err = self.run_bzr(['merge', '-d', 'a', 'b'])
550
self.assertContainsRe(err, 'Warning: criss-cross merge encountered.')
552
def test_merge_from_submit(self):
553
tree_a = self.make_branch_and_tree('a')
554
tree_a.commit('test')
555
tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
556
tree_c = tree_a.bzrdir.sprout('c').open_workingtree()
557
out, err = self.run_bzr(['merge', '-d', 'c'])
558
self.assertContainsRe(err, 'Merging from remembered parent location .*a\/')
559
tree_c.branch.set_submit_branch(tree_b.bzrdir.root_transport.base)
560
out, err = self.run_bzr(['merge', '-d', 'c'])
561
self.assertContainsRe(err, 'Merging from remembered submit location .*b\/')
563
def test_remember_sets_submit(self):
564
tree_a = self.make_branch_and_tree('a')
565
tree_a.commit('rev1')
566
tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
567
self.assertIs(tree_b.branch.get_submit_branch(), None)
569
# Remember should not happen if using default from parent
570
out, err = self.run_bzr(['merge', '-d', 'b'])
571
self.assertIs(tree_b.branch.get_submit_branch(), None)
573
# Remember should happen if user supplies location
574
out, err = self.run_bzr(['merge', '-d', 'b', 'a'])
575
self.assertEqual(tree_b.branch.get_submit_branch(),
576
tree_a.bzrdir.root_transport.base)
578
def test_no_remember_dont_set_submit(self):
579
tree_a = self.make_branch_and_tree('a')
580
self.build_tree_contents([('a/file', "a\n")])
582
tree_a.commit('rev1')
583
tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
584
self.assertIs(tree_b.branch.get_submit_branch(), None)
586
# Remember should not happen if using default from parent
587
out, err = self.run_bzr(['merge', '-d', 'b', '--no-remember'])
588
self.assertEquals(None, tree_b.branch.get_submit_branch())
590
# Remember should not happen if user supplies location but ask for not
592
out, err = self.run_bzr(['merge', '-d', 'b', '--no-remember', 'a'])
593
self.assertEqual(None, tree_b.branch.get_submit_branch())
595
def test_weave_cherrypick(self):
596
this_tree = self.make_branch_and_tree('this')
597
self.build_tree_contents([('this/file', "a\n")])
598
this_tree.add('file')
599
this_tree.commit('rev1')
600
other_tree = this_tree.bzrdir.sprout('other').open_workingtree()
601
self.build_tree_contents([('other/file', "a\nb\n")])
602
other_tree.commit('rev2b')
603
self.build_tree_contents([('other/file', "c\na\nb\n")])
604
other_tree.commit('rev3b')
605
self.run_bzr('merge --weave -d this other -r -2..-1')
606
self.assertFileEqual('c\na\n', 'this/file')
608
def test_lca_merge_criss_cross(self):
609
tree_a = self.make_branch_and_tree('a')
610
self.build_tree_contents([('a/file', 'base-contents\n')])
612
tree_a.commit('', rev_id='rev1')
613
tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
614
self.build_tree_contents([('a/file',
615
'base-contents\nthis-contents\n')])
616
tree_a.commit('', rev_id='rev2a')
617
self.build_tree_contents([('b/file',
618
'base-contents\nother-contents\n')])
619
tree_b.commit('', rev_id='rev2b')
620
tree_a.merge_from_branch(tree_b.branch)
621
self.build_tree_contents([('a/file',
622
'base-contents\nthis-contents\n')])
623
tree_a.set_conflicts(conflicts.ConflictList())
624
tree_b.merge_from_branch(tree_a.branch)
625
self.build_tree_contents([('b/file',
626
'base-contents\nother-contents\n')])
627
tree_b.set_conflicts(conflicts.ConflictList())
628
tree_a.commit('', rev_id='rev3a')
629
tree_b.commit('', rev_id='rev3b')
630
out, err = self.run_bzr(['merge', '-d', 'a', 'b', '--lca'], retcode=1)
631
self.assertFileEqual('base-contents\n<<<<<<< TREE\nthis-contents\n'
632
'=======\nother-contents\n>>>>>>> MERGE-SOURCE\n',
635
def test_merge_preview(self):
636
this_tree = self.make_branch_and_tree('this')
637
this_tree.commit('rev1')
638
other_tree = this_tree.bzrdir.sprout('other').open_workingtree()
639
self.build_tree_contents([('other/file', 'new line')])
640
other_tree.add('file')
641
other_tree.commit('rev2a')
642
this_tree.commit('rev2b')
643
out, err = self.run_bzr(['merge', '-d', 'this', 'other', '--preview'])
644
self.assertContainsRe(out, '\+new line')
645
self.assertNotContainsRe(err, '\+N file\n')
646
this_tree.lock_read()
647
self.addCleanup(this_tree.unlock)
649
list(this_tree.iter_changes(this_tree.basis_tree())))
651
def test_merge_missing_second_revision_spec(self):
652
"""Merge uses branch basis when the second revision is unspecified."""
653
this = self.make_branch_and_tree('this')
655
other = self.make_branch_and_tree('other')
656
self.build_tree(['other/other_file'])
657
other.add('other_file')
658
other.commit('rev1b')
659
self.run_bzr('merge -d this other -r0..')
660
self.assertPathExists('this/other_file')
662
def test_merge_interactive_unlocks_branch(self):
663
this = self.make_branch_and_tree('this')
664
this.commit('empty commit')
665
other = this.bzrdir.sprout('other').open_workingtree()
666
other.commit('empty commit 2')
667
self.run_bzr('merge -i -d this other')
671
def test_merge_fetches_tags(self):
672
"""Tags are updated by merge, and revisions named in those tags are
675
# Make a source, sprout a target off it
676
builder = self.make_branch_builder('source')
677
builder.build_commit(message="Rev 1", rev_id='rev-1')
678
source = builder.get_branch()
679
target_bzrdir = source.bzrdir.sprout('target')
680
# Add a non-ancestry tag to source
681
builder.build_commit(message="Rev 2a", rev_id='rev-2a')
682
source.tags.set_tag('tag-a', 'rev-2a')
683
source.set_last_revision_info(1, 'rev-1')
684
source.get_config().set_user_option('branch.fetch_tags', 'True')
685
builder.build_commit(message="Rev 2b", rev_id='rev-2b')
687
self.run_bzr('merge -d target source')
688
target = target_bzrdir.open_branch()
689
# The tag is present, and so is its revision.
690
self.assertEqual('rev-2a', target.tags.lookup_tag('tag-a'))
691
target.repository.get_revision('rev-2a')
694
class TestMergeRevisionRange(tests.TestCaseWithTransport):
696
scenarios = (('whole-tree', dict(context='.')),
697
('file-only', dict(context='a')))
700
super(TestMergeRevisionRange, self).setUp()
701
self.tree = self.make_branch_and_tree(".")
702
self.tree.commit('initial commit')
706
self.tree.commit("added " + f)
708
def test_merge_reversed_revision_range(self):
709
self.run_bzr("merge -r 2..1 " + self.context)
710
self.assertPathDoesNotExist("a")
711
self.assertPathExists("b")
714
class TestMergeScript(script.TestCaseWithTransportAndScript):
715
def test_merge_empty_branch(self):
716
source = self.make_branch_and_tree('source')
717
self.build_tree(['source/a'])
719
source.commit('Added a', rev_id='rev1')
720
target = self.make_branch_and_tree('target')
722
$ bzr merge -d target source
723
2>bzr: ERROR: Merging into empty branches not currently supported, https://bugs.launchpad.net/bzr/+bug/308562
726
class TestMergeForce(tests.TestCaseWithTransport):
729
super(TestMergeForce, self).setUp()
730
self.tree_a = self.make_branch_and_tree('a')
731
self.build_tree(['a/foo'])
732
self.tree_a.add(['foo'])
733
self.tree_a.commit('add file')
734
self.tree_b = self.tree_a.bzrdir.sprout('b').open_workingtree()
735
self.build_tree_contents([('a/foo', 'change 1')])
736
self.tree_a.commit('change file')
737
self.tree_b.merge_from_branch(self.tree_a.branch)
739
def test_merge_force(self):
740
self.tree_a.commit('empty change to allow merge to run')
741
# Second merge on top of the uncommitted one
742
self.run_bzr(['merge', '../a', '--force'], working_dir='b')
745
def test_merge_with_uncommitted_changes(self):
746
self.run_bzr_error(['Working tree .* has uncommitted changes'],
747
['merge', '../a'], working_dir='b')
749
def test_merge_with_pending_merges(self):
750
# Revert the changes keeping the pending merge
751
self.run_bzr(['revert', 'b'])
752
self.run_bzr_error(['Working tree .* has uncommitted changes'],
753
['merge', '../a'], working_dir='b')
363
self.failUnlessExists('target/file1')
364
self.failIfExists('target/file2')