~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-08 18:30:33 UTC
  • mfrom: (6487 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6488.
  • Revision ID: v.ladeuil+lp@free.fr-20120308183033-bccqnbr1tpozs711
Merge bzr.dev resolving conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    branch as _mod_branch,
29
29
    bzrdir,
30
30
    config,
 
31
    controldir,
31
32
    errors,
32
33
    symbol_versioning,
33
34
    tests,
244
245
        # but open_downlevel will work
245
246
        self.assertEqual(
246
247
            format.open(dir),
247
 
            bzrdir.BzrDir.open(self.get_url()).open_branch(unsupported=True))
 
248
            controldir.ControlDir.open(self.get_url()).open_branch(unsupported=True))
248
249
        # unregister the format
249
250
        self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
250
251
            _mod_branch.BranchFormat.unregister_format, format)
488
489
 
489
490
    def make_branch(self, location, format=None):
490
491
        if format is None:
491
 
            format = bzrdir.format_registry.make_bzrdir('1.9')
 
492
            format = controldir.format_registry.make_bzrdir('1.9')
492
493
            format.set_branch_format(_mod_branch.BzrBranchFormat8())
493
494
        return tests.TestCaseWithTransport.make_branch(
494
495
            self, location, format=format)
693
694
            'Value "not-a-bool" is not valid for "append_revisions_only"',
694
695
            self.warnings[0])
695
696
 
 
697
    def test_use_fresh_values(self):
 
698
        copy = _mod_branch.Branch.open(self.branch.base)
 
699
        copy.lock_write()
 
700
        try:
 
701
            copy.get_config_stack().set('foo', 'bar')
 
702
        finally:
 
703
            copy.unlock()
 
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)
 
709
 
 
710
    def test_set_from_config_get_from_config_stack(self):
 
711
        self.branch.lock_write()
 
712
        self.addCleanup(self.branch.unlock)
 
713
        self.branch.get_config().set_user_option('foo', 'bar')
 
714
        result = self.branch.get_config_stack().get('foo')
 
715
        # https://bugs.launchpad.net/bzr/+bug/948344
 
716
        self.expectFailure('BranchStack uses cache after set_user_option',
 
717
                           self.assertEqual, 'bar', result)
 
718
 
 
719
    def test_set_from_config_stack_get_from_config(self):
 
720
        self.branch.lock_write()
 
721
        self.addCleanup(self.branch.unlock)
 
722
        self.branch.get_config_stack().set('foo', 'bar')
 
723
        self.assertEqual('bar',
 
724
                         self.branch.get_config().get_user_option('foo'))
 
725
 
 
726
    def test_set_delays_write(self):
 
727
        self.branch.lock_write()
 
728
        self.addCleanup(self.branch.unlock)
 
729
        self.branch.get_config_stack().set('foo', 'bar')
 
730
        copy = _mod_branch.Branch.open(self.branch.base)
 
731
        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)
 
735
 
696
736
 
697
737
class TestPullResult(tests.TestCase):
698
738