~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/branch_implementations/test_branch.py

  • Committer: John Arbash Meinel
  • Date: 2006-07-01 16:28:08 UTC
  • mto: This revision was merged to the branch mainline in revision 1846.
  • Revision ID: john@arbash-meinel.com-20060701162808-769ff8f2520a65d6
Test that other is unlocked even if self fails

Show diffs side-by-side

added added

removed removed

Lines of Context:
671
671
            # For cleanup purposes, make sure we are unlocked
672
672
            b.repository._other.unlock()
673
673
 
674
 
    def test_04_lock_read_fail_repo(self):
 
674
    def test_04_lock_fail_unlock_control(self):
 
675
        # Make sure repository.unlock() is called, if we fail to unlock self
 
676
        b = self.get_instrumented_branch()
 
677
        b.control_files.disable_unlock()
 
678
 
 
679
        self.assertFalse(b.is_locked())
 
680
        self.assertFalse(b.repository.is_locked())
 
681
        b.lock_write()
 
682
        try:
 
683
            self.assertTrue(b.is_locked())
 
684
            self.assertTrue(b.repository.is_locked())
 
685
            self.assertRaises(TestPreventLocking, b.unlock)
 
686
            self.assertTrue(b.is_locked())
 
687
            if self.combined_control:
 
688
                self.assertTrue(b.repository.is_locked())
 
689
            else:
 
690
                self.assertFalse(b.repository.is_locked())
 
691
 
 
692
            # We unlock the repository even if 
 
693
            # we fail to unlock the control files
 
694
            self.assertEqual([('b', 'lw', True),
 
695
                              ('r', 'lw', True),
 
696
                              ('rc', 'lw', True),
 
697
                              ('bc', 'lw', True),
 
698
                              ('b', 'ul', True),
 
699
                              ('bc', 'ul', False),
 
700
                              ('r', 'ul', True), 
 
701
                              ('rc', 'ul', True), 
 
702
                             ], self.locks)
 
703
 
 
704
        finally:
 
705
            # For cleanup purposes, make sure we are unlocked
 
706
            b.control_files._other.unlock()
 
707
 
 
708
    def test_05_lock_read_fail_repo(self):
675
709
        # Test that the branch is not locked if it cannot lock the repository
676
710
        b = self.get_instrumented_branch()
677
711
        b.repository.disable_lock_read()
684
718
                          ('r', 'lr', False), 
685
719
                         ], self.locks)
686
720
 
687
 
    def test_05_lock_write_fail_repo(self):
 
721
    def test_06_lock_write_fail_repo(self):
688
722
        # Test that the branch is not locked if it cannot lock the repository
689
723
        b = self.get_instrumented_branch()
690
724
        b.repository.disable_lock_write()
697
731
                          ('r', 'lw', False), 
698
732
                         ], self.locks)
699
733
 
700
 
    def test_06_lock_read_fail_control(self):
 
734
    def test_07_lock_read_fail_control(self):
701
735
        # Test the repository is unlocked if we can't lock self
702
736
        b = self.get_instrumented_branch()
703
737
        b.control_files.disable_lock_read()
714
748
                          ('rc', 'ul', True),
715
749
                         ], self.locks)
716
750
 
717
 
    def test_07_lock_write_fail_control(self):
 
751
    def test_08_lock_write_fail_control(self):
718
752
        # Test the repository is unlocked if we can't lock self
719
753
        b = self.get_instrumented_branch()
720
754
        b.control_files.disable_lock_write()