~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_send.py

  • Committer: John Arbash Meinel
  • Date: 2010-08-04 04:33:24 UTC
  • mto: This revision was merged to the branch mainline in revision 5390.
  • Revision ID: john@arbash-meinel.com-20100804043324-1ldc2v2w1kza7ox4
get into the nitty gritty for the _key_to_sha1 function.

It doesn't seem to help to op-out of the actual unhexlify call, so at least
that doesn't seem to be the performance overhead.
We get down to around 19.9us for _key_to_sha1 across 120 keys, which is
0.166us per key.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2008, 2009 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
# Authors: Aaron Bentley
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
307
307
    _default_sent_revs = ['local']
308
308
    _default_errors = ['Working tree ".*/local/" has uncommitted '
309
309
                       'changes \(See bzr status\)\.',]
 
310
    _default_additional_error = 'Use --no-strict to force the send.\n'
 
311
    _default_additional_warning = 'Uncommitted changes will not be sent.'
310
312
 
311
313
    def set_config_send_strict(self, value):
312
314
        # set config var (any of bazaar.conf, locations.conf, branch.conf
315
317
        conf.set_user_option('send_strict', value)
316
318
 
317
319
    def assertSendFails(self, args):
318
 
        self.run_send(args, rc=3, err_re=self._default_errors)
 
320
        out, err = self.run_send(args, rc=3, err_re=self._default_errors)
 
321
        self.assertContainsRe(err, self._default_additional_error)
319
322
 
320
 
    def assertSendSucceeds(self, args, revs=None):
 
323
    def assertSendSucceeds(self, args, revs=None, with_warning=False):
 
324
        if with_warning:
 
325
            err_re = self._default_errors
 
326
        else:
 
327
            err_re = []
321
328
        if revs is None:
322
329
            revs = self._default_sent_revs
323
 
        out, err = self.run_send(args)
324
 
        self.assertEquals(
325
 
            'Bundling %d revision(s).\n' % len(revs), err)
 
330
        out, err = self.run_send(args, err_re=err_re)
 
331
        bundling_revs = 'Bundling %d revision(s).\n' % len(revs)
 
332
        if with_warning:
 
333
            self.assertContainsRe(err, self._default_additional_warning)
 
334
            self.assertEndsWith(err, bundling_revs)
 
335
        else:
 
336
            self.assertEquals(bundling_revs, err)
326
337
        md = merge_directive.MergeDirective.from_lines(StringIO(out))
327
338
        self.assertEqual('parent', md.base_revision_id)
328
339
        br = serializer.read_bundle(StringIO(md.get_raw_bundle()))
396
407
        self._default_sent_revs = ['modified-in-local', 'local']
397
408
 
398
409
    def test_send_default(self):
399
 
        self.assertSendFails([])
 
410
        self.assertSendSucceeds([], with_warning=True)
400
411
 
401
412
    def test_send_with_revision(self):
402
413
        self.assertSendSucceeds(['-r', 'revid:local'], revs=['local'])
412
423
        self.assertSendFails([])
413
424
        self.assertSendSucceeds(['--no-strict'])
414
425
 
415
 
 
416
426
    def test_send_bogus_config_var_ignored(self):
417
427
        self.set_config_send_strict("I'm unsure")
418
 
        self.assertSendFails([])
419
 
 
 
428
        self.assertSendSucceeds([], with_warning=True)
420
429
 
421
430
    def test_send_no_strict_command_line_override_config(self):
422
431
        self.set_config_send_strict('true')