~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_reconfigure.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:
147
147
        reconfiguration = reconfigure.Reconfigure(branch.bzrdir)
148
148
        self.assertRaises(errors.NoBindLocation,
149
149
                          reconfiguration._select_bind_location)
150
 
        branch.lock_write()
151
 
        try:
152
 
            branch.set_parent('http://parent')
153
 
        finally:
154
 
            branch.unlock()
 
150
        branch.set_parent('http://parent')
155
151
        reconfiguration = reconfigure.Reconfigure(branch.bzrdir)
156
152
        self.assertEqual('http://parent',
157
153
                         reconfiguration._select_bind_location())
158
 
        branch.lock_write()
159
 
        try:
160
 
            branch.set_push_location('sftp://push')
161
 
        finally:
162
 
            branch.unlock()
 
154
        branch.set_push_location('sftp://push')
163
155
        reconfiguration = reconfigure.Reconfigure(branch.bzrdir)
164
156
        self.assertEqual('sftp://push',
165
157
                         reconfiguration._select_bind_location())
172
164
        reconfiguration = reconfigure.Reconfigure(branch.bzrdir)
173
165
        self.assertEqual('bzr://foo/old-bound',
174
166
                         reconfiguration._select_bind_location())
175
 
        branch.lock_write()
176
 
        try:
177
 
            branch.set_bound_location('bzr://foo/cur-bound')
178
 
        finally:
179
 
            branch.unlock()
 
167
        branch.set_bound_location('bzr://foo/cur-bound')
180
168
        reconfiguration = reconfigure.Reconfigure(branch.bzrdir)
181
169
        self.assertEqual('bzr://foo/cur-bound',
182
170
                         reconfiguration._select_bind_location())
200
188
        reconfiguration = reconfigure.Reconfigure.to_checkout(tree.bzrdir)
201
189
        self.assertRaises(errors.NoBindLocation, reconfiguration.apply)
202
190
        # setting a parent allows it to become a checkout
203
 
        tree.branch.lock_write()
204
 
        try:
205
 
            tree.branch.set_parent(parent.base)
206
 
        finally:
207
 
            tree.branch.unlock()
 
191
        tree.branch.set_parent(parent.base)
208
192
        reconfiguration = reconfigure.Reconfigure.to_checkout(tree.bzrdir)
209
193
        reconfiguration.apply()
210
194
        # supplying a location allows it to become a checkout
223
207
            tree.bzrdir)
224
208
        self.assertRaises(errors.NoBindLocation, reconfiguration.apply)
225
209
        # setting a parent allows it to become a checkout
226
 
        tree.branch.lock_write()
227
 
        try:
228
 
            tree.branch.set_parent(parent.base)
229
 
        finally:
230
 
            tree.branch.unlock()
 
210
        tree.branch.set_parent(parent.base)
231
211
        reconfiguration = reconfigure.Reconfigure.to_lightweight_checkout(
232
212
            tree.bzrdir)
233
213
        reconfiguration.apply()