1
# Copyright (C) 2006-2010 Canonical Ltd
1
# Copyright (C) 2006, 2007, 2008, 2009 Canonical Ltd
2
2
# Authors: Aaron Bentley
4
4
# This program is free software; you can redistribute it and/or modify
281
280
self.assertEqual('rev3', md.revision_id)
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.'
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)
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)
323
def assertSendSucceeds(self, args, revs=None, with_warning=False):
325
err_re = self._default_errors
319
def assertSendSucceeds(self, args, revs=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)
333
self.assertContainsRe(err, self._default_additional_warning)
334
self.assertEndsWith(err, bundling_revs)
336
self.assertEquals(bundling_revs, err)
322
out, err = self.run_send(args)
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']
409
397
def test_send_default(self):
410
self.assertSendSucceeds([], with_warning=True)
398
self.assertSendFails([])
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'])
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([])
430
420
def test_send_no_strict_command_line_override_config(self):
431
421
self.set_config_send_strict('true')