305
305
self.assertEqual('2', target.open_workingtree().last_revision())
306
306
self.assertTrue(target.open_branch().repository.has_revision('2'))
308
def test_merge(self):
309
from bzrlib.branch import Branch
313
self.example_branch()
315
self.runbzr('branch a b')
317
file('goodbye', 'wt').write('quux')
318
self.runbzr(['commit', '-m', "more u's are always good"])
321
file('hello', 'wt').write('quuux')
322
# We can't merge when there are in-tree changes
323
self.runbzr('merge ../b', retcode=3)
324
self.runbzr(['commit', '-m', "Like an epidemic of u's"])
325
self.runbzr('merge ../b -r last:1..last:1 --merge-type blooof',
327
self.runbzr('merge ../b -r last:1..last:1 --merge-type merge3')
328
self.runbzr('revert --no-backup')
329
self.runbzr('merge ../b -r last:1..last:1 --merge-type weave')
330
self.runbzr('revert --no-backup')
331
self.runbzr('merge ../b -r last:1..last:1 --reprocess')
332
self.runbzr('revert --no-backup')
333
self.runbzr('merge ../b -r last:1')
334
self.check_file_contents('goodbye', 'quux')
335
# Merging a branch pulls its revision into the tree
336
a = WorkingTree.open('.')
337
b = Branch.open('../b')
338
a.branch.repository.get_revision_xml(b.last_revision())
339
self.log('pending merges: %s', a.pending_merges())
340
self.assertEquals(a.pending_merges(),
342
self.runbzr('commit -m merged')
343
self.runbzr('merge ../b -r last:1')
344
self.assertEqual(a.pending_merges(), [])
346
def test_merge_with_missing_file(self):
347
"""Merge handles missing file conflicts"""
351
print >> file('sub/a.txt', 'wb'), "hello"
352
print >> file('b.txt', 'wb'), "hello"
353
print >> file('sub/c.txt', 'wb'), "hello"
356
self.runbzr(('commit', '-m', 'added a'))
357
self.runbzr('branch . ../b')
358
print >> file('sub/a.txt', 'ab'), "there"
359
print >> file('b.txt', 'ab'), "there"
360
print >> file('sub/c.txt', 'ab'), "there"
361
self.runbzr(('commit', '-m', 'Added there'))
362
os.unlink('sub/a.txt')
363
os.unlink('sub/c.txt')
366
self.runbzr(('commit', '-m', 'Removed a.txt'))
368
print >> file('sub/a.txt', 'ab'), "something"
369
print >> file('b.txt', 'ab'), "something"
370
print >> file('sub/c.txt', 'ab'), "something"
371
self.runbzr(('commit', '-m', 'Modified a.txt'))
372
self.runbzr('merge ../a/', retcode=1)
373
self.assert_(os.path.exists('sub/a.txt.THIS'))
374
self.assert_(os.path.exists('sub/a.txt.BASE'))
376
self.runbzr('merge ../b/', retcode=1)
377
self.assert_(os.path.exists('sub/a.txt.OTHER'))
378
self.assert_(os.path.exists('sub/a.txt.BASE'))
380
308
def test_inventory(self):
381
309
bzr = self.runbzr
382
310
def output_equals(value, *args):
721
649
assert '|||||||' not in conflict_text
722
650
assert 'hi world' not in conflict_text
723
651
self.runbzr('remerge . --merge-type weave --show-base', retcode=3)
724
self.runbzr('remerge . --merge-type weave --reprocess', retcode=3)
725
652
self.runbzr('remerge . --show-base --reprocess', retcode=3)
653
self.runbzr('remerge . --merge-type weave --reprocess', retcode=1)
726
654
self.runbzr('remerge hello --show-base', retcode=1)
727
655
self.runbzr('remerge hello --reprocess', retcode=1)
728
656
self.runbzr('resolve --all')