~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_branch.py

(jelmer) Deprecate {lazy_,}register_filter_stack_map. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
340
340
        self.assertPathDoesNotExist('a/.bzr/branch/bound')
341
341
        self.assertEqual('ftp://example.com', branch.get_bound_location())
342
342
 
343
 
    def test_set_revision_history(self):
344
 
        builder = self.make_branch_builder('.', format=self.get_format_name())
345
 
        builder.build_snapshot('foo', None,
346
 
            [('add', ('', None, 'directory', None))],
347
 
            message='foo')
348
 
        builder.build_snapshot('bar', None, [], message='bar')
349
 
        branch = builder.get_branch()
350
 
        branch.lock_write()
351
 
        self.addCleanup(branch.unlock)
352
 
        self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
353
 
            branch.set_revision_history, ['foo', 'bar'])
354
 
        self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
355
 
                branch.set_revision_history, ['foo'])
356
 
        self.assertRaises(errors.NotLefthandHistory,
357
 
            self.applyDeprecated, symbol_versioning.deprecated_in((2, 4, 0)),
358
 
            branch.set_revision_history, ['bar'])
359
 
 
360
343
    def do_checkout_test(self, lightweight=False):
361
344
        tree = self.make_branch_and_tree('source',
362
345
            format=self.get_format_name_subtree())
569
552
    def test_constructor(self):
570
553
        """Check that creating a BranchHooks instance has the right defaults."""
571
554
        hooks = _mod_branch.BranchHooks()
572
 
        self.assertTrue("set_rh" in hooks, "set_rh not in %s" % hooks)
573
555
        self.assertTrue("post_push" in hooks, "post_push not in %s" % hooks)
574
556
        self.assertTrue("post_commit" in hooks, "post_commit not in %s" % hooks)
575
557
        self.assertTrue("pre_commit" in hooks, "pre_commit not in %s" % hooks)
679
661
        finally:
680
662
            copy.unlock()
681
663
        self.assertFalse(self.branch.is_locked())
682
 
        result = self.branch.get_config_stack().get('foo')
683
 
        # Bug: https://bugs.launchpad.net/bzr/+bug/948339
684
 
        self.expectFailure('Unlocked branches cache their configs',
685
 
            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'))
686
671
 
687
672
    def test_set_from_config_get_from_config_stack(self):
688
673
        self.branch.lock_write()
697
682
        self.branch.lock_write()
698
683
        self.addCleanup(self.branch.unlock)
699
684
        self.branch.get_config_stack().set('foo', 'bar')
700
 
        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,
701
688
                         self.branch.get_config().get_user_option('foo'))
702
689
 
703
 
    def test_set_delays_write(self):
 
690
    def test_set_delays_write_when_branch_is_locked(self):
704
691
        self.branch.lock_write()
705
692
        self.addCleanup(self.branch.unlock)
706
693
        self.branch.get_config_stack().set('foo', 'bar')
707
694
        copy = _mod_branch.Branch.open(self.branch.base)
708
695
        result = copy.get_config_stack().get('foo')
709
 
        # Bug: https://bugs.launchpad.net/bzr/+bug/948339
710
 
        self.expectFailure("Config writes are not cached.", self.assertIs,
711
 
                           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)
712
700
 
713
701
 
714
702
class TestPullResult(tests.TestCase):