~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2012-02-20 12:19:29 UTC
  • mfrom: (6437.23.11 2.5)
  • mto: (6581.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6582.
  • Revision ID: jelmer@samba.org-20120220121929-7ni2psvjoatm1yp4
Merge bzr/2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
 
18
18
 
19
 
import sys
20
19
from cStringIO import StringIO
21
20
 
22
21
from bzrlib import (
25
24
    merge_directive,
26
25
    tests,
27
26
    )
 
27
from bzrlib.controldir import ControlDir
28
28
from bzrlib.bundle import serializer
29
29
from bzrlib.transport import memory
30
30
from bzrlib.tests import (
31
31
    scenarios,
32
 
    script,
33
32
    )
 
33
from bzrlib.tests.matchers import ContainsNoVfsCalls
34
34
 
35
35
 
36
36
load_tests = scenarios.load_tests_apply_scenarios
189
189
 
190
190
    def test_note_revisions(self):
191
191
        stderr = self.run_send([])[1]
192
 
        self.assertEndsWith(stderr, '\nBundling 1 revision(s).\n')
 
192
        self.assertEndsWith(stderr, '\nBundling 1 revision.\n')
193
193
 
194
194
    def test_mailto_option(self):
195
195
        b = branch.Branch.open('branch')
201
201
        self.run_send([])
202
202
        self.run_bzr_error(('Unknown mail client: bogus',),
203
203
                           'send -f branch --mail-to jrandom@example.org')
204
 
        b.get_config().set_user_option('submit_to', 'jrandom@example.org')
 
204
        b.get_config_stack().set('submit_to', 'jrandom@example.org')
205
205
        self.run_bzr_error(('Unknown mail client: bogus',),
206
206
                           'send -f branch')
207
207
 
210
210
        b = branch.Branch.open('branch')
211
211
        b.get_config().set_user_option('mail_client', 'bogus')
212
212
        parent = branch.Branch.open('parent')
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')
 
213
        parent.get_config_stack().set('child_submit_to', 'somebody@example.org')
 
214
        self.run_bzr_error(('Unknown mail client: bogus',), 'send -f branch')
217
215
 
218
216
    def test_format(self):
219
217
        md = self.get_MD(['--format=4'])
231
229
                            'send -f branch -o- --format=0.999')[0]
232
230
 
233
231
    def test_format_child_option(self):
234
 
        parent_config = branch.Branch.open('parent').get_config()
235
 
        parent_config.set_user_option('child_submit_format', '4')
 
232
        parent_config = branch.Branch.open('parent').get_config_stack()
 
233
        parent_config.set('child_submit_format', '4')
236
234
        md = self.get_MD([])
237
235
        self.assertIs(merge_directive.MergeDirective2, md.__class__)
238
236
 
239
 
        parent_config.set_user_option('child_submit_format', '0.9')
 
237
        parent_config.set('child_submit_format', '0.9')
240
238
        md = self.get_MD([])
241
239
        self.assertFormatIs('# Bazaar revision bundle v0.9', md)
242
240
 
244
242
        self.assertFormatIs('# Bazaar revision bundle v0.9', md)
245
243
        self.assertIs(merge_directive.MergeDirective, md.__class__)
246
244
 
247
 
        parent_config.set_user_option('child_submit_format', '0.999')
 
245
        parent_config.set('child_submit_format', '0.999')
248
246
        self.run_bzr_error(["No such send format '0.999'"],
249
247
                            'send -f branch -o-')[0]
250
248
 
296
294
    def set_config_send_strict(self, value):
297
295
        # set config var (any of bazaar.conf, locations.conf, branch.conf
298
296
        # should do)
299
 
        conf = self.local_tree.branch.get_config()
300
 
        conf.set_user_option('send_strict', value)
 
297
        conf = self.local_tree.branch.get_config_stack()
 
298
        conf.set('send_strict', value)
301
299
 
302
300
    def assertSendFails(self, args):
303
301
        out, err = self.run_send(args, rc=3, err_re=self._default_errors)
311
309
        if revs is None:
312
310
            revs = self._default_sent_revs
313
311
        out, err = self.run_send(args, err_re=err_re)
314
 
        bundling_revs = 'Bundling %d revision(s).\n' % len(revs)
 
312
        if len(revs) == 1:
 
313
            bundling_revs = 'Bundling %d revision.\n'% len(revs)
 
314
        else:
 
315
            bundling_revs = 'Bundling %d revisions.\n' % len(revs)
315
316
        if with_warning:
316
317
            self.assertContainsRe(err, self._default_additional_warning)
317
318
            self.assertEndsWith(err, bundling_revs)
330
331
        super(TestSendStrictWithoutChanges, self).setUp()
331
332
        self.make_parent_and_local_branches()
332
333
 
 
334
    def test_send_without_workingtree(self):
 
335
        ControlDir.open("local").destroy_workingtree()
 
336
        self.assertSendSucceeds([])
 
337
 
333
338
    def test_send_default(self):
334
339
        self.assertSendSucceeds([])
335
340
 
436
441
class TestBundleStrictWithoutChanges(TestSendStrictWithoutChanges):
437
442
 
438
443
    _default_command = ['bundle-revisions', '../parent']
 
444
 
 
445
 
 
446
class TestSmartServerSend(tests.TestCaseWithTransport):
 
447
 
 
448
    def test_send(self):
 
449
        self.setup_smart_server_with_call_log()
 
450
        t = self.make_branch_and_tree('branch')
 
451
        self.build_tree_contents([('branch/foo', 'thecontents')])
 
452
        t.add("foo")
 
453
        t.commit("message")
 
454
        local = t.bzrdir.sprout('local-branch').open_workingtree()
 
455
        self.build_tree_contents([('branch/foo', 'thenewcontents')])
 
456
        local.commit("anothermessage")
 
457
        self.reset_smart_call_log()
 
458
        out, err = self.run_bzr(
 
459
            ['send', '-o', 'x.diff', self.get_url('branch')], working_dir='local-branch')
 
460
        # This figure represent the amount of work to perform this use case. It
 
461
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
462
        # being too low. If rpc_count increases, more network roundtrips have
 
463
        # become necessary for this use case. Please do not adjust this number
 
464
        # upwards without agreement from bzr's network support maintainers.
 
465
        self.assertLength(9, self.hpss_calls)
 
466
        self.assertLength(1, self.hpss_connections)
 
467
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)