~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2009-07-10 06:46:10 UTC
  • mto: (4525.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4526.
  • Revision ID: mbp@sourcefrog.net-20090710064610-sqviksbqp5i34sw2
Rename to per_interrepository

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2008, 2009 Canonical Ltd
2
2
# Authors: Aaron Bentley
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
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):
68
67
 
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())
72
71
 
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)
282
281
 
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/"
 
285
        else:
 
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.'
312
311
 
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)
318
317
 
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)
322
320
 
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
    def assertSendSucceeds(self, args, revs=None):
328
322
        if revs is 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)
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)
337
 
        md = merge_directive.MergeDirective.from_lines(StringIO(out))
 
324
        out, err = self.run_send(args)
 
325
        self.assertEquals(
 
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']
408
399
 
409
400
    def test_send_default(self):
410
 
        self.assertSendSucceeds([], with_warning=True)
 
401
        self.assertSendFails([])
411
402
 
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'])
425
416
 
 
417
 
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([])
 
421
 
429
422
 
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'])
434
427
 
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'])