~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_branch.py

  • Committer: Vincent Ladeuil
  • Date: 2012-03-13 16:28:30 UTC
  • mto: This revision was merged to the branch mainline in revision 6512.
  • Revision ID: v.ladeuil+lp@free.fr-20120313162830-83ekrd4ghqru0whh
Save branch config options only during the final unlock

Show diffs side-by-side

added added

removed removed

Lines of Context:
702
702
        finally:
703
703
            copy.unlock()
704
704
        self.assertFalse(self.branch.is_locked())
705
 
        result = self.branch.get_config_stack().get('foo')
706
 
        # Bug: https://bugs.launchpad.net/bzr/+bug/948339
707
 
        self.expectFailure('Unlocked branches cache their configs',
708
 
            self.assertEqual, 'bar', result)
 
705
        # Since the branch is locked, the option value won't be saved on disk
 
706
        # so trying to access the config of locked branch via another older
 
707
        # non-locked branch object pointing to the same branch is not supported
 
708
        self.assertEqual(None, self.branch.get_config_stack().get('foo'))
 
709
        # Using a newly created branch object works as expected
 
710
        fresh = _mod_branch.Branch.open(self.branch.base)
 
711
        self.assertEqual('bar', fresh.get_config_stack().get('foo'))
709
712
 
710
713
    def test_set_from_config_get_from_config_stack(self):
711
714
        self.branch.lock_write()
720
723
        self.branch.lock_write()
721
724
        self.addCleanup(self.branch.unlock)
722
725
        self.branch.get_config_stack().set('foo', 'bar')
723
 
        self.assertEqual('bar',
 
726
        # Since the branch is locked, the option value won't be saved on disk
 
727
        # so mixing get() and get_user_option() is broken by design.
 
728
        self.assertEqual(None,
724
729
                         self.branch.get_config().get_user_option('foo'))
725
730
 
726
 
    def test_set_delays_write(self):
 
731
    def test_set_delays_write_when_branch_is_locked(self):
727
732
        self.branch.lock_write()
728
733
        self.addCleanup(self.branch.unlock)
729
734
        self.branch.get_config_stack().set('foo', 'bar')
730
735
        copy = _mod_branch.Branch.open(self.branch.base)
731
736
        result = copy.get_config_stack().get('foo')
732
 
        # Bug: https://bugs.launchpad.net/bzr/+bug/948339
733
 
        self.expectFailure("Config writes are not cached.", self.assertIs,
734
 
                           None, result)
 
737
        # Accessing from a different branch object is like accessing from a
 
738
        # different process: the option has not been saved yet and the new
 
739
        # value cannot be seen.
 
740
        self.assertIs(None, result)
735
741
 
736
742
 
737
743
class TestPullResult(tests.TestCase):