~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-06-30 20:35:16 UTC
  • mto: This revision was merged to the branch mainline in revision 1846.
  • Revision ID: john@arbash-meinel.com-20060630203516-15636a2648ee156b
Branch should lock Repository before it locks self, and unlock self before Repository

Show diffs side-by-side

added added

removed removed

Lines of Context:
602
602
        self.assertFalse(b.is_locked())
603
603
        self.assertFalse(b.repository.is_locked())
604
604
 
605
 
        self.assertEqual([('b', 'lr', True), ('bc', 'lr', True),
606
 
                          ('r', 'lr', True), ('rc', 'lr', True),
607
 
                          ('b', 'ul', True), ('r', 'ul', True),
608
 
                          ('rc', 'ul', True), ('bc', 'ul', True),
 
605
        self.assertEqual([('b', 'lr', True),
 
606
                          ('r', 'lr', True),
 
607
                          ('rc', 'lr', True),
 
608
                          ('bc', 'lr', True),
 
609
                          ('b', 'ul', True),
 
610
                          ('bc', 'ul', True),
 
611
                          ('r', 'ul', True),
 
612
                          ('rc', 'ul', True),
609
613
                         ], self.locks)
610
614
 
611
615
    def test_02_lock_write(self):
623
627
        self.assertFalse(b.is_locked())
624
628
        self.assertFalse(b.repository.is_locked())
625
629
 
626
 
        self.assertEqual([('b', 'lw', True), ('bc', 'lw', True),
627
 
                          ('r', 'lw', True), ('rc', 'lw', True),
628
 
                          ('b', 'ul', True), ('r', 'ul', True),
629
 
                          ('rc', 'ul', True), ('bc', 'ul', True),
 
630
        self.assertEqual([('b', 'lw', True),
 
631
                          ('r', 'lw', True),
 
632
                          ('rc', 'lw', True),
 
633
                          ('bc', 'lw', True),
 
634
                          ('b', 'ul', True),
 
635
                          ('bc', 'ul', True),
 
636
                          ('r', 'ul', True),
 
637
                          ('rc', 'ul', True),
630
638
                         ], self.locks)
631
639
 
632
640
    def test_03_lock_fail_unlock_repo(self):
650
658
 
651
659
            # We unlock the branch control files, even if 
652
660
            # we fail to unlock the repository
653
 
            self.assertEqual([('b', 'lw', True), ('bc', 'lw', True),
654
 
                              ('r', 'lw', True), ('rc', 'lw', True),
655
 
                              ('b', 'ul', True), ('r', 'ul', False), 
 
661
            self.assertEqual([('b', 'lw', True),
 
662
                              ('r', 'lw', True),
 
663
                              ('rc', 'lw', True),
 
664
                              ('bc', 'lw', True),
 
665
                              ('b', 'ul', True),
656
666
                              ('bc', 'ul', True),
 
667
                              ('r', 'ul', False), 
657
668
                             ], self.locks)
658
669
 
659
670
        finally:
661
672
            b.repository._other.unlock()
662
673
 
663
674
    def test_04_lock_read_fail_repo(self):
664
 
        # Test that the branch is unlocked if it cannot lock the repository
 
675
        # Test that the branch is not locked if it cannot lock the repository
665
676
        b = self.get_instrumented_branch()
666
677
        b.repository.disable_lock_read()
667
678
 
669
680
        self.assertFalse(b.is_locked())
670
681
        self.assertFalse(b.repository.is_locked())
671
682
 
672
 
        self.assertEqual([('b', 'lr', True), ('bc', 'lr', True),
 
683
        self.assertEqual([('b', 'lr', True),
673
684
                          ('r', 'lr', False), 
674
 
                          ('bc', 'ul', True),
675
685
                         ], self.locks)
676
686
 
677
687
    def test_05_lock_write_fail_repo(self):
678
 
        # Test that the branch is unlocked if it cannot lock the repository
 
688
        # Test that the branch is not locked if it cannot lock the repository
679
689
        b = self.get_instrumented_branch()
680
690
        b.repository.disable_lock_write()
681
691
 
683
693
        self.assertFalse(b.is_locked())
684
694
        self.assertFalse(b.repository.is_locked())
685
695
 
686
 
        self.assertEqual([('b', 'lw', True), ('bc', 'lw', True),
 
696
        self.assertEqual([('b', 'lw', True),
687
697
                          ('r', 'lw', False), 
688
 
                          ('bc', 'ul', True),
689
698
                         ], self.locks)
690
699
 
691
700
    def test_06_lock_read_fail_control(self):
692
 
        # We shouldn't try to lock the repo if we can't lock the branch
 
701
        # Test the repository is unlocked if we can't lock self
693
702
        b = self.get_instrumented_branch()
694
703
        b.control_files.disable_lock_read()
695
704
 
697
706
        self.assertFalse(b.is_locked())
698
707
        self.assertFalse(b.repository.is_locked())
699
708
 
700
 
        self.assertEqual([('b', 'lr', True), ('bc', 'lr', False),
 
709
        self.assertEqual([('b', 'lr', True),
 
710
                          ('r', 'lr', True),
 
711
                          ('rc', 'lr', True),
 
712
                          ('bc', 'lr', False),
 
713
                          ('r', 'ul', True),
 
714
                          ('rc', 'ul', True),
701
715
                         ], self.locks)
702
716
 
703
717
    def test_07_lock_write_fail_control(self):
704
 
        # We shouldn't try to lock the repo if we can't lock the branch
 
718
        # Test the repository is unlocked if we can't lock self
705
719
        b = self.get_instrumented_branch()
706
720
        b.control_files.disable_lock_write()
707
721
 
709
723
        self.assertFalse(b.is_locked())
710
724
        self.assertFalse(b.repository.is_locked())
711
725
 
712
 
        self.assertEqual([('b', 'lw', True), ('bc', 'lw', False),
 
726
        self.assertEqual([('b', 'lw', True),
 
727
                          ('r', 'lw', True),
 
728
                          ('rc', 'lw', True),
 
729
                          ('bc', 'lw', False),
 
730
                          ('r', 'ul', True),
 
731
                          ('rc', 'ul', True),
713
732
                         ], self.locks)
714
733
 
715
 
 
716