/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_workingtree/test_workingtree.py

Merge cleanup into shell-like-tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
513
513
 
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')
519
 
        this.add('a')
520
 
        open('b1/b', 'wb').write('b test\n')
521
 
        this.add('b')
 
517
        self.build_tree_contents([('b1/a', 'a test\n'), ('b1/b', 'b test\n')])
 
518
        this.add(['a', 'b'])
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')])
528
524
        other.add('c')
529
525
 
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
 
532
        #       locking race.
 
533
        this.lock_write()
 
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')
 
537
        try:
 
538
            self.assertNotEqual(a.read(), 'a test\n')
 
539
        finally:
 
540
            a.close()
534
541
        this.revert()
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')
540
547
 
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.