~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-02-17 17:11:16 UTC
  • mfrom: (4797.2.17 2.1)
  • mto: (4797.2.18 2.1)
  • mto: This revision was merged to the branch mainline in revision 5055.
  • Revision ID: john@arbash-meinel.com-20100217171116-h7t9223ystbnx5h8
merge bzr.2.1 in preparation for NEWS entry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
    tests,
27
27
    )
28
28
from bzrlib.bundle import serializer
29
 
from bzrlib.transport import memory
30
29
 
31
30
 
32
31
def load_tests(standard_tests, module, loader):
281
280
        self.assertEqual('rev3', md.revision_id)
282
281
 
283
282
    def test_nonexistant_branch(self):
284
 
        self.vfs_transport_factory = memory.MemoryServer
 
283
        self.vfs_transport_factory = tests.MemoryServer
285
284
        location = self.get_url('absentdir/')
286
285
        out, err = self.run_bzr(["send", "--from", location], retcode=3)
287
286
        self.assertEqual(out, '')
307
306
    _default_sent_revs = ['local']
308
307
    _default_errors = ['Working tree ".*/local/" has uncommitted '
309
308
                       '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.'
312
309
 
313
310
    def set_config_send_strict(self, value):
314
311
        # set config var (any of bazaar.conf, locations.conf, branch.conf
317
314
        conf.set_user_option('send_strict', value)
318
315
 
319
316
    def assertSendFails(self, args):
320
 
        out, err = self.run_send(args, rc=3, err_re=self._default_errors)
321
 
        self.assertContainsRe(err, self._default_additional_error)
 
317
        self.run_send(args, rc=3, err_re=self._default_errors)
322
318
 
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 = []
 
319
    def assertSendSucceeds(self, args, revs=None):
328
320
        if revs is None:
329
321
            revs = self._default_sent_revs
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)
 
322
        out, err = self.run_send(args)
 
323
        self.assertEquals(
 
324
            'Bundling %d revision(s).\n' % len(revs), err)
337
325
        md = merge_directive.MergeDirective.from_lines(StringIO(out))
338
326
        self.assertEqual('parent', md.base_revision_id)
339
327
        br = serializer.read_bundle(StringIO(md.get_raw_bundle()))
407
395
        self._default_sent_revs = ['modified-in-local', 'local']
408
396
 
409
397
    def test_send_default(self):
410
 
        self.assertSendSucceeds([], with_warning=True)
 
398
        self.assertSendFails([])
411
399
 
412
400
    def test_send_with_revision(self):
413
401
        self.assertSendSucceeds(['-r', 'revid:local'], revs=['local'])
423
411
        self.assertSendFails([])
424
412
        self.assertSendSucceeds(['--no-strict'])
425
413
 
 
414
 
426
415
    def test_send_bogus_config_var_ignored(self):
427
416
        self.set_config_send_strict("I'm unsure")
428
 
        self.assertSendSucceeds([], with_warning=True)
 
417
        self.assertSendFails([])
 
418
 
429
419
 
430
420
    def test_send_no_strict_command_line_override_config(self):
431
421
        self.set_config_send_strict('true')