~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Alexander Belchenko
  • Date: 2012-03-29 08:34:13 UTC
  • mto: (6015.44.14 2.4)
  • mto: This revision was merged to the branch mainline in revision 6513.
  • Revision ID: bialix@ukr.net-20120329083413-d4bqqdtfn2yrxp4f
change st_dev, st_ino, st_uid, st_gid from int members to properties.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2012 Canonical Ltd
 
1
# Copyright (C) 2006-2011 Canonical Ltd
2
2
# Authors: Aaron Bentley
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
16
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
 
18
18
 
 
19
import sys
19
20
from cStringIO import StringIO
20
21
 
21
22
from bzrlib import (
22
23
    branch,
 
24
    bzrdir,
23
25
    merge_directive,
24
26
    tests,
25
27
    )
26
 
from bzrlib.controldir import ControlDir
27
28
from bzrlib.bundle import serializer
28
29
from bzrlib.transport import memory
29
30
from bzrlib.tests import (
30
31
    scenarios,
 
32
    script,
31
33
    )
32
 
from bzrlib.tests.matchers import ContainsNoVfsCalls
33
34
 
34
35
 
35
36
load_tests = scenarios.load_tests_apply_scenarios
62
63
 
63
64
    def setUp(self):
64
65
        super(TestSend, self).setUp()
65
 
        grandparent_tree = ControlDir.create_standalone_workingtree(
 
66
        grandparent_tree = bzrdir.BzrDir.create_standalone_workingtree(
66
67
            'grandparent')
67
68
        self.build_tree_contents([('grandparent/file1', 'grandparent')])
68
69
        grandparent_tree.add('file1')
188
189
 
189
190
    def test_note_revisions(self):
190
191
        stderr = self.run_send([])[1]
191
 
        self.assertEndsWith(stderr, '\nBundling 1 revision.\n')
 
192
        self.assertEndsWith(stderr, '\nBundling 1 revision(s).\n')
192
193
 
193
194
    def test_mailto_option(self):
194
195
        b = branch.Branch.open('branch')
195
 
        b.get_config_stack().set('mail_client', 'editor')
 
196
        b.get_config().set_user_option('mail_client', 'editor')
196
197
        self.run_bzr_error(
197
198
            ('No mail-to address \\(--mail-to\\) or output \\(-o\\) specified',
198
199
            ), 'send -f branch')
199
 
        b.get_config_stack().set('mail_client', 'bogus')
 
200
        b.get_config().set_user_option('mail_client', 'bogus')
200
201
        self.run_send([])
201
 
        self.run_bzr_error(('Bad value "bogus" for option "mail_client"',),
 
202
        self.run_bzr_error(('Unknown mail client: bogus',),
202
203
                           'send -f branch --mail-to jrandom@example.org')
203
 
        b.get_config_stack().set('submit_to', 'jrandom@example.org')
204
 
        self.run_bzr_error(('Bad value "bogus" for option "mail_client"',),
 
204
        b.get_config().set_user_option('submit_to', 'jrandom@example.org')
 
205
        self.run_bzr_error(('Unknown mail client: bogus',),
205
206
                           'send -f branch')
206
207
 
207
208
    def test_mailto_child_option(self):
208
209
        """Make sure that child_submit_to is used."""
209
210
        b = branch.Branch.open('branch')
210
 
        b.get_config_stack().set('mail_client', 'bogus')
 
211
        b.get_config().set_user_option('mail_client', 'bogus')
211
212
        parent = branch.Branch.open('parent')
212
 
        parent.get_config_stack().set('child_submit_to', 'somebody@example.org')
213
 
        self.run_bzr_error(('Bad value "bogus" for option "mail_client"',),
214
 
                'send -f branch')
 
213
        parent.get_config().set_user_option('child_submit_to',
 
214
                           'somebody@example.org')
 
215
        self.run_bzr_error(('Unknown mail client: bogus',),
 
216
                           'send -f branch')
215
217
 
216
218
    def test_format(self):
217
219
        md = self.get_MD(['--format=4'])
229
231
                            'send -f branch -o- --format=0.999')[0]
230
232
 
231
233
    def test_format_child_option(self):
232
 
        br = branch.Branch.open('parent')
233
 
        conf = br.get_config_stack()
234
 
        conf.set('child_submit_format', '4')
 
234
        parent_config = branch.Branch.open('parent').get_config()
 
235
        parent_config.set_user_option('child_submit_format', '4')
235
236
        md = self.get_MD([])
236
237
        self.assertIs(merge_directive.MergeDirective2, md.__class__)
237
238
 
238
 
        conf.set('child_submit_format', '0.9')
 
239
        parent_config.set_user_option('child_submit_format', '0.9')
239
240
        md = self.get_MD([])
240
241
        self.assertFormatIs('# Bazaar revision bundle v0.9', md)
241
242
 
243
244
        self.assertFormatIs('# Bazaar revision bundle v0.9', md)
244
245
        self.assertIs(merge_directive.MergeDirective, md.__class__)
245
246
 
246
 
        conf.set('child_submit_format', '0.999')
 
247
        parent_config.set_user_option('child_submit_format', '0.999')
247
248
        self.run_bzr_error(["No such send format '0.999'"],
248
249
                            'send -f branch -o-')[0]
249
250
 
274
275
 
275
276
    def make_parent_and_local_branches(self):
276
277
        # Create a 'parent' branch as the base
277
 
        self.parent_tree = ControlDir.create_standalone_workingtree('parent')
 
278
        self.parent_tree = bzrdir.BzrDir.create_standalone_workingtree('parent')
278
279
        self.build_tree_contents([('parent/file', 'parent')])
279
280
        self.parent_tree.add('file')
280
281
        self.parent_tree.commit('first commit', rev_id='parent')
293
294
    _default_additional_warning = 'Uncommitted changes will not be sent.'
294
295
 
295
296
    def set_config_send_strict(self, value):
296
 
        br = branch.Branch.open('local')
297
 
        br.get_config_stack().set('send_strict', value)
 
297
        # set config var (any of bazaar.conf, locations.conf, branch.conf
 
298
        # should do)
 
299
        conf = self.local_tree.branch.get_config()
 
300
        conf.set_user_option('send_strict', value)
298
301
 
299
302
    def assertSendFails(self, args):
300
303
        out, err = self.run_send(args, rc=3, err_re=self._default_errors)
308
311
        if revs is None:
309
312
            revs = self._default_sent_revs
310
313
        out, err = self.run_send(args, err_re=err_re)
311
 
        if len(revs) == 1:
312
 
            bundling_revs = 'Bundling %d revision.\n'% len(revs)
313
 
        else:
314
 
            bundling_revs = 'Bundling %d revisions.\n' % len(revs)
 
314
        bundling_revs = 'Bundling %d revision(s).\n' % len(revs)
315
315
        if with_warning:
316
316
            self.assertContainsRe(err, self._default_additional_warning)
317
317
            self.assertEndsWith(err, bundling_revs)
330
330
        super(TestSendStrictWithoutChanges, self).setUp()
331
331
        self.make_parent_and_local_branches()
332
332
 
333
 
    def test_send_without_workingtree(self):
334
 
        ControlDir.open("local").destroy_workingtree()
335
 
        self.assertSendSucceeds([])
336
 
 
337
333
    def test_send_default(self):
338
334
        self.assertSendSucceeds([])
339
335
 
440
436
class TestBundleStrictWithoutChanges(TestSendStrictWithoutChanges):
441
437
 
442
438
    _default_command = ['bundle-revisions', '../parent']
443
 
 
444
 
 
445
 
class TestSmartServerSend(tests.TestCaseWithTransport):
446
 
 
447
 
    def test_send(self):
448
 
        self.setup_smart_server_with_call_log()
449
 
        t = self.make_branch_and_tree('branch')
450
 
        self.build_tree_contents([('branch/foo', 'thecontents')])
451
 
        t.add("foo")
452
 
        t.commit("message")
453
 
        local = t.bzrdir.sprout('local-branch').open_workingtree()
454
 
        self.build_tree_contents([('branch/foo', 'thenewcontents')])
455
 
        local.commit("anothermessage")
456
 
        self.reset_smart_call_log()
457
 
        out, err = self.run_bzr(
458
 
            ['send', '-o', 'x.diff', self.get_url('branch')], working_dir='local-branch')
459
 
        # This figure represent the amount of work to perform this use case. It
460
 
        # is entirely ok to reduce this number if a test fails due to rpc_count
461
 
        # being too low. If rpc_count increases, more network roundtrips have
462
 
        # become necessary for this use case. Please do not adjust this number
463
 
        # upwards without agreement from bzr's network support maintainers.
464
 
        self.assertLength(7, self.hpss_calls)
465
 
        self.assertLength(1, self.hpss_connections)
466
 
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)