~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_branch.py

  • Committer: Patch Queue Manager
  • Date: 2012-03-28 16:13:49 UTC
  • mfrom: (6499.2.3 948339-config-caching)
  • Revision ID: pqm@pqm.ubuntu.com-20120328161349-2gsc0g11fcu43hlc
(vila) Properly share mutable config sections and save the branch config
 only during the final unlock (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
661
661
        finally:
662
662
            copy.unlock()
663
663
        self.assertFalse(self.branch.is_locked())
664
 
        result = self.branch.get_config_stack().get('foo')
665
 
        # Bug: https://bugs.launchpad.net/bzr/+bug/948339
666
 
        self.expectFailure('Unlocked branches cache their configs',
667
 
            self.assertEqual, 'bar', result)
 
664
        # Since the branch is locked, the option value won't be saved on disk
 
665
        # so trying to access the config of locked branch via another older
 
666
        # non-locked branch object pointing to the same branch is not supported
 
667
        self.assertEqual(None, self.branch.get_config_stack().get('foo'))
 
668
        # Using a newly created branch object works as expected
 
669
        fresh = _mod_branch.Branch.open(self.branch.base)
 
670
        self.assertEqual('bar', fresh.get_config_stack().get('foo'))
668
671
 
669
672
    def test_set_from_config_get_from_config_stack(self):
670
673
        self.branch.lock_write()
679
682
        self.branch.lock_write()
680
683
        self.addCleanup(self.branch.unlock)
681
684
        self.branch.get_config_stack().set('foo', 'bar')
682
 
        self.assertEqual('bar',
 
685
        # Since the branch is locked, the option value won't be saved on disk
 
686
        # so mixing get() and get_user_option() is broken by design.
 
687
        self.assertEqual(None,
683
688
                         self.branch.get_config().get_user_option('foo'))
684
689
 
685
 
    def test_set_delays_write(self):
 
690
    def test_set_delays_write_when_branch_is_locked(self):
686
691
        self.branch.lock_write()
687
692
        self.addCleanup(self.branch.unlock)
688
693
        self.branch.get_config_stack().set('foo', 'bar')
689
694
        copy = _mod_branch.Branch.open(self.branch.base)
690
695
        result = copy.get_config_stack().get('foo')
691
 
        # Bug: https://bugs.launchpad.net/bzr/+bug/948339
692
 
        self.expectFailure("Config writes are not cached.", self.assertIs,
693
 
                           None, result)
 
696
        # Accessing from a different branch object is like accessing from a
 
697
        # different process: the option has not been saved yet and the new
 
698
        # value cannot be seen.
 
699
        self.assertIs(None, result)
694
700
 
695
701
 
696
702
class TestPullResult(tests.TestCase):