514
514
def test_merge_revert(self):
515
515
from bzrlib.merge import merge_inner
516
self.thisFailsStrictLockCheck()
517
516
this = self.make_branch_and_tree('b1')
518
open('b1/a', 'wb').write('a test\n')
520
open('b1/b', 'wb').write('b test\n')
517
self.build_tree_contents([('b1/a', 'a test\n'), ('b1/b', 'b test\n')])
522
519
this.commit(message='')
523
520
base = this.bzrdir.clone('b2').open_workingtree()
524
open('b2/a', 'wb').write('b test\n')
521
self.build_tree_contents([('b2/a', 'b test\n')])
525
522
other = this.bzrdir.clone('b3').open_workingtree()
526
open('b3/a', 'wb').write('c test\n')
527
open('b3/c', 'wb').write('c test\n')
523
self.build_tree_contents([('b3/a', 'c test\n'), ('b3/c', 'c test\n')])
530
open('b1/b', 'wb').write('q test\n')
531
open('b1/d', 'wb').write('d test\n')
526
self.build_tree_contents([('b1/b', 'q test\n'), ('b1/d', 'd test\n')])
527
# Note: If we don't lock this before calling merge_inner, then we get a
528
# lock-contention failure. This probably indicates something
529
# weird going on inside merge_inner. Probably something about
530
# calling bt = this_tree.basis_tree() in one lock, and then
531
# locking both this_tree and bt separately, causing a dirstate
534
self.addCleanup(this.unlock)
532
535
merge_inner(this.branch, other, base, this_tree=this)
533
self.assertNotEqual(open('b1/a', 'rb').read(), 'a test\n')
536
a = open('b1/a', 'rb')
538
self.assertNotEqual(a.read(), 'a test\n')
535
self.assertEqual(open('b1/a', 'rb').read(), 'a test\n')
536
self.assertIs(os.path.exists('b1/b.~1~'), True)
537
self.assertIs(os.path.exists('b1/c'), False)
538
self.assertIs(os.path.exists('b1/a.~1~'), False)
539
self.assertIs(os.path.exists('b1/d'), True)
542
self.assertFileEqual('a test\n', 'b1/a')
543
self.failUnlessExists('b1/b.~1~')
544
self.failIfExists('b1/c')
545
self.failIfExists('b1/a.~1~')
546
self.failUnlessExists('b1/d')
541
548
def test_update_updates_bound_branch_no_local_commits(self):
542
549
# doing an update in a tree updates the branch its bound to too.