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
69
68
def get_MD(self, args, cmd=None, wd='branch'):
70
69
out = StringIO(self.run_send(args, cmd=cmd, wd=wd)[0])
71
return merge_directive.MergeDirective.from_lines(out)
70
return merge_directive.MergeDirective.from_lines(out.readlines())
73
72
def assertBundleContains(self, revs, args, cmd=None, wd='branch'):
74
73
md = self.get_MD(args, cmd=cmd, wd=wd)
281
280
self.assertEqual('rev3', md.revision_id)
283
282
def test_nonexistant_branch(self):
284
self.vfs_transport_factory = memory.MemoryServer
285
location = self.get_url('absentdir/')
283
if sys.platform == "win32":
284
location = "C:/i/do/not/exist/"
286
location = "/i/do/not/exist/"
286
287
out, err = self.run_bzr(["send", "--from", location], retcode=3)
287
288
self.assertEqual(out, '')
288
289
self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
307
308
_default_sent_revs = ['local']
308
309
_default_errors = ['Working tree ".*/local/" has uncommitted '
309
310
'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
312
def set_config_send_strict(self, value):
314
313
# set config var (any of bazaar.conf, locations.conf, branch.conf
317
316
conf.set_user_option('send_strict', value)
319
318
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)
319
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
321
def assertSendSucceeds(self, args, revs=None):
329
323
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)
337
md = merge_directive.MergeDirective.from_lines(StringIO(out))
324
out, err = self.run_send(args)
326
'Bundling %d revision(s).\n' % len(revs), err)
327
md = merge_directive.MergeDirective.from_lines(
328
StringIO(out).readlines())
338
329
self.assertEqual('parent', md.base_revision_id)
339
330
br = serializer.read_bundle(StringIO(md.get_raw_bundle()))
340
331
self.assertEqual(set(revs), set(r.revision_id for r in br.revisions))
407
398
self._default_sent_revs = ['modified-in-local', 'local']
409
400
def test_send_default(self):
410
self.assertSendSucceeds([], with_warning=True)
401
self.assertSendFails([])
412
403
def test_send_with_revision(self):
413
404
self.assertSendSucceeds(['-r', 'revid:local'], revs=['local'])
423
414
self.assertSendFails([])
424
415
self.assertSendSucceeds(['--no-strict'])
426
418
def test_send_bogus_config_var_ignored(self):
427
419
self.set_config_send_strict("I'm unsure")
428
self.assertSendSucceeds([], with_warning=True)
420
self.assertSendFails([])
430
423
def test_send_no_strict_command_line_override_config(self):
431
424
self.set_config_send_strict('true')
432
425
self.assertSendFails([])
433
426
self.assertSendSucceeds(['--no-strict'])
435
def test_send_strict_command_line_override_config(self):
428
def test_push_strict_command_line_override_config(self):
436
429
self.set_config_send_strict('false')
437
430
self.assertSendSucceeds([])
438
431
self.assertSendFails(['--strict'])