~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_send.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:
230
230
    def test_format_child_option(self):
231
231
        br = branch.Branch.open('parent')
232
232
        conf = br.get_config_stack()
233
 
        br.lock_write()
234
 
        try:
235
 
            conf.set('child_submit_format', '4')
236
 
        finally:
237
 
            br.unlock()
 
233
        conf.set('child_submit_format', '4')
238
234
        md = self.get_MD([])
239
235
        self.assertIs(merge_directive.MergeDirective2, md.__class__)
240
236
 
241
 
        br.lock_write()
242
 
        try:
243
 
            conf.set('child_submit_format', '0.9')
244
 
        finally:
245
 
            br.unlock()
 
237
        conf.set('child_submit_format', '0.9')
246
238
        md = self.get_MD([])
247
239
        self.assertFormatIs('# Bazaar revision bundle v0.9', md)
248
240
 
250
242
        self.assertFormatIs('# Bazaar revision bundle v0.9', md)
251
243
        self.assertIs(merge_directive.MergeDirective, md.__class__)
252
244
 
253
 
        br.lock_write()
254
 
        try:
255
 
            conf.set('child_submit_format', '0.999')
256
 
        finally:
257
 
            br.unlock()
 
245
        conf.set('child_submit_format', '0.999')
258
246
        self.run_bzr_error(["No such send format '0.999'"],
259
247
                            'send -f branch -o-')[0]
260
248
 
305
293
 
306
294
    def set_config_send_strict(self, value):
307
295
        br = branch.Branch.open('local')
308
 
        br.lock_write()
309
 
        try:
310
 
            br.get_config_stack().set('send_strict', value)
311
 
        finally:
312
 
            br.unlock()
 
296
        br.get_config_stack().set('send_strict', value)
313
297
 
314
298
    def assertSendFails(self, args):
315
299
        out, err = self.run_send(args, rc=3, err_re=self._default_errors)