~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_branch/test_branch.py

  • Committer: Vincent Ladeuil
  • Date: 2012-01-18 14:09:19 UTC
  • mto: This revision was merged to the branch mainline in revision 6468.
  • Revision ID: v.ladeuil+lp@free.fr-20120118140919-rlvdrhpc0nq1lbwi
Change set/remove to require a lock for the branch config files.

This means that tests (or any plugin for that matter) do not requires an
explicit lock on the branch anymore to change a single option. This also
means the optimisation becomes "opt-in" and as such won't be as
spectacular as it may be and/or harder to get right (nothing fails
anymore).

This reduces the diff by ~300 lines.

Code/tests that were updating more than one config option is still taking
a lock to at least avoid some IOs and demonstrate the benefits through
the decreased number of hpss calls.

The duplication between BranchStack and BranchOnlyStack will be removed
once the same sharing is in place for local config files, at which point
the Stack class itself may be able to host the changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
205
205
    def test_public_branch(self):
206
206
        """public location can be queried and set"""
207
207
        branch = self.make_branch('branch')
208
 
        self.addCleanup(branch.lock_write().unlock)
209
208
        self.assertEqual(branch.get_public_branch(), None)
210
209
        branch.set_public_branch('sftp://example.com')
211
210
        self.assertEqual(branch.get_public_branch(), 'sftp://example.com')
349
348
 
350
349
    def test_get_set_append_revisions_only(self):
351
350
        branch = self.make_branch('.')
352
 
        self.addCleanup(branch.lock_write().unlock)
353
351
        if branch._format.supports_set_append_revisions_only():
354
352
            branch.set_append_revisions_only(True)
355
353
            self.assertTrue(branch.get_append_revisions_only())
640
638
 
641
639
    def test_set_push_location(self):
642
640
        branch = self.get_branch()
643
 
        self.addCleanup(branch.lock_write().unlock)
644
641
        branch.set_push_location('foo')
645
642
        self.assertEqual('foo', branch.get_push_location())
646
643
 
654
651
 
655
652
    def test_get_child_submit_format(self):
656
653
        branch = self.get_branch()
657
 
        self.addCleanup(branch.lock_write().unlock)
658
654
        branch.get_config_stack().set('child_submit_format', '10')
659
655
        branch = self.get_branch()
660
656
        self.assertEqual('10', branch.get_child_submit_format())
815
811
    def test_strict_history(self):
816
812
        tree1 = self.make_branch_and_tree('tree1')
817
813
        try:
818
 
            tree1.branch.lock_write()
819
 
            try:
820
 
                tree1.branch.set_append_revisions_only(True)
821
 
            finally:
822
 
                tree1.branch.unlock()
 
814
            tree1.branch.set_append_revisions_only(True)
823
815
        except errors.UpgradeRequired:
824
816
            raise tests.TestSkipped('Format does not support strict history')
825
817
        tree1.commit('empty commit')