~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.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:
1273
1273
        self.reset_smart_call_log()
1274
1274
        verb = 'Branch.set_parent_location'
1275
1275
        self.disable_verb(verb)
1276
 
        branch.lock_write()
1277
 
        try:
1278
 
            branch.set_parent('http://foo/')
1279
 
        finally:
1280
 
            branch.unlock()
 
1276
        branch.set_parent('http://foo/')
1281
1277
        self.assertLength(14, self.hpss_calls)
1282
1278
 
1283
1279
 
1438
1434
 
1439
1435
    def test_backwards_compatible(self):
1440
1436
        br = self.make_branch_with_tags()
1441
 
        br.lock_write()
1442
 
        try:
1443
 
            br.get_config_stack().set('branch.fetch_tags', True)
1444
 
        finally:
1445
 
            br.unlock()
 
1437
        br.get_config_stack().set('branch.fetch_tags', True)
1446
1438
        self.addCleanup(br.lock_read().unlock)
1447
1439
        # Disable the heads_to_fetch verb
1448
1440
        verb = 'Branch.heads_to_fetch'
1456
1448
 
1457
1449
    def test_backwards_compatible_no_tags(self):
1458
1450
        br = self.make_branch_with_tags()
1459
 
        br.lock_write()
1460
 
        try:
1461
 
            br.get_config_stack().set('branch.fetch_tags', False)
1462
 
        finally:
1463
 
            br.unlock()
 
1451
        br.get_config_stack().set('branch.fetch_tags', False)
1464
1452
        self.addCleanup(br.lock_read().unlock)
1465
1453
        # Disable the heads_to_fetch verb
1466
1454
        verb = 'Branch.heads_to_fetch'
4151
4139
        self.bound_location = self.checkout.branch.get_bound_location()
4152
4140
 
4153
4141
    def assertUpdateSucceeds(self, new_location):
4154
 
        self.checkout.lock_write()
4155
 
        try:
4156
 
            self.checkout.branch.set_bound_location(new_location)
4157
 
            self.checkout.update()
4158
 
        finally:
4159
 
            self.checkout.unlock()
 
4142
        self.checkout.branch.set_bound_location(new_location)
 
4143
        self.checkout.update()
4160
4144
        self.assertEquals(self.last_revid, self.checkout.last_revision())
4161
4145
 
4162
4146
    def test_without_final_slash(self):