~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-01-23 19:08:05 UTC
  • mfrom: (6437.3.20 2.5)
  • mto: This revision was merged to the branch mainline in revision 6450.
  • Revision ID: jelmer@samba.org-20120123190805-hlcuihkt2dep44cw
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 (
29
28
from bzrlib.transport import memory
30
29
from bzrlib.tests import (
31
30
    scenarios,
32
 
    script,
33
31
    )
 
32
from bzrlib.tests.matchers import ContainsNoVfsCalls
34
33
 
35
34
 
36
35
load_tests = scenarios.load_tests_apply_scenarios
201
200
        self.run_send([])
202
201
        self.run_bzr_error(('Unknown mail client: bogus',),
203
202
                           'send -f branch --mail-to jrandom@example.org')
204
 
        b.get_config().set_user_option('submit_to', 'jrandom@example.org')
 
203
        b.get_config_stack().set('submit_to', 'jrandom@example.org')
205
204
        self.run_bzr_error(('Unknown mail client: bogus',),
206
205
                           'send -f branch')
207
206
 
210
209
        b = branch.Branch.open('branch')
211
210
        b.get_config().set_user_option('mail_client', 'bogus')
212
211
        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')
 
212
        parent.get_config_stack().set('child_submit_to', 'somebody@example.org')
 
213
        self.run_bzr_error(('Unknown mail client: bogus',), 'send -f branch')
217
214
 
218
215
    def test_format(self):
219
216
        md = self.get_MD(['--format=4'])
231
228
                            'send -f branch -o- --format=0.999')[0]
232
229
 
233
230
    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')
 
231
        parent_config = branch.Branch.open('parent').get_config_stack()
 
232
        parent_config.set('child_submit_format', '4')
236
233
        md = self.get_MD([])
237
234
        self.assertIs(merge_directive.MergeDirective2, md.__class__)
238
235
 
239
 
        parent_config.set_user_option('child_submit_format', '0.9')
 
236
        parent_config.set('child_submit_format', '0.9')
240
237
        md = self.get_MD([])
241
238
        self.assertFormatIs('# Bazaar revision bundle v0.9', md)
242
239
 
244
241
        self.assertFormatIs('# Bazaar revision bundle v0.9', md)
245
242
        self.assertIs(merge_directive.MergeDirective, md.__class__)
246
243
 
247
 
        parent_config.set_user_option('child_submit_format', '0.999')
 
244
        parent_config.set('child_submit_format', '0.999')
248
245
        self.run_bzr_error(["No such send format '0.999'"],
249
246
                            'send -f branch -o-')[0]
250
247
 
439
436
class TestBundleStrictWithoutChanges(TestSendStrictWithoutChanges):
440
437
 
441
438
    _default_command = ['bundle-revisions', '../parent']
 
439
 
 
440
 
 
441
class TestSmartServerSend(tests.TestCaseWithTransport):
 
442
 
 
443
    def test_send(self):
 
444
        self.setup_smart_server_with_call_log()
 
445
        t = self.make_branch_and_tree('branch')
 
446
        self.build_tree_contents([('branch/foo', 'thecontents')])
 
447
        t.add("foo")
 
448
        t.commit("message")
 
449
        local = t.bzrdir.sprout('local-branch').open_workingtree()
 
450
        self.build_tree_contents([('branch/foo', 'thenewcontents')])
 
451
        local.commit("anothermessage")
 
452
        self.reset_smart_call_log()
 
453
        out, err = self.run_bzr(
 
454
            ['send', '-o', 'x.diff', self.get_url('branch')], working_dir='local-branch')
 
455
        # This figure represent the amount of work to perform this use case. It
 
456
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
457
        # being too low. If rpc_count increases, more network roundtrips have
 
458
        # become necessary for this use case. Please do not adjust this number
 
459
        # upwards without agreement from bzr's network support maintainers.
 
460
        self.assertLength(9, self.hpss_calls)
 
461
        self.assertLength(1, self.hpss_connections)
 
462
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)