~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Patch Queue Manager
  • Date: 2016-04-21 04:10:52 UTC
  • mfrom: (6616.1.1 fix-en-user-guide)
  • Revision ID: pqm@pqm.ubuntu.com-20160421041052-clcye7ns1qcl2n7w
(richard-wilbur) Ensure build of English use guide always uses English text
 even when user's locale specifies a different language. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2011 Canonical Ltd
 
1
# Copyright (C) 2006-2012, 2016 Canonical Ltd
2
2
# Authors: Aaron Bentley
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
20
20
 
21
21
from bzrlib import (
22
22
    branch,
23
 
    bzrdir,
24
23
    merge_directive,
25
24
    tests,
26
25
    )
63
62
 
64
63
    def setUp(self):
65
64
        super(TestSend, self).setUp()
66
 
        grandparent_tree = bzrdir.BzrDir.create_standalone_workingtree(
 
65
        grandparent_tree = ControlDir.create_standalone_workingtree(
67
66
            'grandparent')
68
67
        self.build_tree_contents([('grandparent/file1', 'grandparent')])
69
68
        grandparent_tree.add('file1')
193
192
 
194
193
    def test_mailto_option(self):
195
194
        b = branch.Branch.open('branch')
196
 
        b.get_config().set_user_option('mail_client', 'editor')
 
195
        b.get_config_stack().set('mail_client', 'editor')
197
196
        self.run_bzr_error(
198
197
            ('No mail-to address \\(--mail-to\\) or output \\(-o\\) specified',
199
198
            ), 'send -f branch')
200
 
        b.get_config().set_user_option('mail_client', 'bogus')
 
199
        b.get_config_stack().set('mail_client', 'bogus')
201
200
        self.run_send([])
202
 
        self.run_bzr_error(('Unknown mail client: bogus',),
 
201
        self.run_bzr_error(('Bad value "bogus" for option "mail_client"',),
203
202
                           'send -f branch --mail-to jrandom@example.org')
204
203
        b.get_config_stack().set('submit_to', 'jrandom@example.org')
205
 
        self.run_bzr_error(('Unknown mail client: bogus',),
 
204
        self.run_bzr_error(('Bad value "bogus" for option "mail_client"',),
206
205
                           'send -f branch')
207
206
 
208
207
    def test_mailto_child_option(self):
209
208
        """Make sure that child_submit_to is used."""
210
209
        b = branch.Branch.open('branch')
211
 
        b.get_config().set_user_option('mail_client', 'bogus')
 
210
        b.get_config_stack().set('mail_client', 'bogus')
212
211
        parent = branch.Branch.open('parent')
213
212
        parent.get_config_stack().set('child_submit_to', 'somebody@example.org')
214
 
        self.run_bzr_error(('Unknown mail client: bogus',), 'send -f branch')
 
213
        self.run_bzr_error(('Bad value "bogus" for option "mail_client"',),
 
214
                'send -f branch')
215
215
 
216
216
    def test_format(self):
217
217
        md = self.get_MD(['--format=4'])
229
229
                            'send -f branch -o- --format=0.999')[0]
230
230
 
231
231
    def test_format_child_option(self):
232
 
        parent_config = branch.Branch.open('parent').get_config_stack()
233
 
        parent_config.set('child_submit_format', '4')
 
232
        br = branch.Branch.open('parent')
 
233
        conf = br.get_config_stack()
 
234
        conf.set('child_submit_format', '4')
234
235
        md = self.get_MD([])
235
236
        self.assertIs(merge_directive.MergeDirective2, md.__class__)
236
237
 
237
 
        parent_config.set('child_submit_format', '0.9')
 
238
        conf.set('child_submit_format', '0.9')
238
239
        md = self.get_MD([])
239
240
        self.assertFormatIs('# Bazaar revision bundle v0.9', md)
240
241
 
242
243
        self.assertFormatIs('# Bazaar revision bundle v0.9', md)
243
244
        self.assertIs(merge_directive.MergeDirective, md.__class__)
244
245
 
245
 
        parent_config.set('child_submit_format', '0.999')
 
246
        conf.set('child_submit_format', '0.999')
246
247
        self.run_bzr_error(["No such send format '0.999'"],
247
248
                            'send -f branch -o-')[0]
248
249
 
273
274
 
274
275
    def make_parent_and_local_branches(self):
275
276
        # Create a 'parent' branch as the base
276
 
        self.parent_tree = bzrdir.BzrDir.create_standalone_workingtree('parent')
 
277
        self.parent_tree = ControlDir.create_standalone_workingtree('parent')
277
278
        self.build_tree_contents([('parent/file', 'parent')])
278
279
        self.parent_tree.add('file')
279
280
        self.parent_tree.commit('first commit', rev_id='parent')
292
293
    _default_additional_warning = 'Uncommitted changes will not be sent.'
293
294
 
294
295
    def set_config_send_strict(self, value):
295
 
        # set config var (any of bazaar.conf, locations.conf, branch.conf
296
 
        # should do)
297
 
        conf = self.local_tree.branch.get_config_stack()
298
 
        conf.set('send_strict', value)
 
296
        br = branch.Branch.open('local')
 
297
        br.get_config_stack().set('send_strict', value)
299
298
 
300
299
    def assertSendFails(self, args):
301
300
        out, err = self.run_send(args, rc=3, err_re=self._default_errors)
317
316
            self.assertContainsRe(err, self._default_additional_warning)
318
317
            self.assertEndsWith(err, bundling_revs)
319
318
        else:
320
 
            self.assertEquals(bundling_revs, err)
 
319
            self.assertEqual(bundling_revs, err)
321
320
        md = merge_directive.MergeDirective.from_lines(StringIO(out))
322
321
        self.assertEqual('parent', md.base_revision_id)
323
322
        br = serializer.read_bundle(StringIO(md.get_raw_bundle()))
462
461
        # being too low. If rpc_count increases, more network roundtrips have
463
462
        # become necessary for this use case. Please do not adjust this number
464
463
        # upwards without agreement from bzr's network support maintainers.
465
 
        self.assertLength(9, self.hpss_calls)
 
464
        self.assertLength(7, self.hpss_calls)
466
465
        self.assertLength(1, self.hpss_connections)
467
466
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)