/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2012, 2016 Canonical Ltd
 
1
# Copyright (C) 2006-2012 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
 
from ... import (
 
19
from cStringIO import StringIO
 
20
 
 
21
from bzrlib import (
20
22
    branch,
21
23
    merge_directive,
22
24
    tests,
23
25
    )
24
 
from ...controldir import ControlDir
25
 
from ...bundle import serializer
26
 
from ...sixish import (
27
 
    BytesIO,
28
 
    )
29
 
from ...transport import memory
30
 
from .. import (
 
26
from bzrlib.controldir import ControlDir
 
27
from bzrlib.bundle import serializer
 
28
from bzrlib.transport import memory
 
29
from bzrlib.tests import (
31
30
    scenarios,
32
31
    )
33
 
from ..matchers import ContainsNoVfsCalls
 
32
from bzrlib.tests.matchers import ContainsNoVfsCalls
34
33
 
35
34
 
36
35
load_tests = scenarios.load_tests_apply_scenarios
50
49
                            error_regexes=err_re)
51
50
 
52
51
    def get_MD(self, args, cmd=None, wd='branch'):
53
 
        out = BytesIO(self.run_send(args, cmd=cmd, wd=wd)[0])
 
52
        out = StringIO(self.run_send(args, cmd=cmd, wd=wd)[0])
54
53
        return merge_directive.MergeDirective.from_lines(out)
55
54
 
56
55
    def assertBundleContains(self, revs, args, cmd=None, wd='branch'):
57
56
        md = self.get_MD(args, cmd=cmd, wd=wd)
58
 
        br = serializer.read_bundle(BytesIO(md.get_raw_bundle()))
 
57
        br = serializer.read_bundle(StringIO(md.get_raw_bundle()))
59
58
        self.assertEqual(set(revs), set(r.revision_id for r in br.revisions))
60
59
 
61
60
 
65
64
        super(TestSend, self).setUp()
66
65
        grandparent_tree = ControlDir.create_standalone_workingtree(
67
66
            'grandparent')
68
 
        self.build_tree_contents([('grandparent/file1', b'grandparent')])
 
67
        self.build_tree_contents([('grandparent/file1', 'grandparent')])
69
68
        grandparent_tree.add('file1')
70
 
        grandparent_tree.commit('initial commit', rev_id=b'rev1')
 
69
        grandparent_tree.commit('initial commit', rev_id='rev1')
71
70
 
72
 
        parent_bzrdir = grandparent_tree.controldir.sprout('parent')
 
71
        parent_bzrdir = grandparent_tree.bzrdir.sprout('parent')
73
72
        parent_tree = parent_bzrdir.open_workingtree()
74
 
        parent_tree.commit('next commit', rev_id=b'rev2')
 
73
        parent_tree.commit('next commit', rev_id='rev2')
75
74
 
76
 
        branch_tree = parent_tree.controldir.sprout('branch').open_workingtree()
77
 
        self.build_tree_contents([('branch/file1', b'branch')])
78
 
        branch_tree.commit('last commit', rev_id=b'rev3')
 
75
        branch_tree = parent_tree.bzrdir.sprout('branch').open_workingtree()
 
76
        self.build_tree_contents([('branch/file1', 'branch')])
 
77
        branch_tree.commit('last commit', rev_id='rev3')
79
78
 
80
79
    def assertFormatIs(self, fmt_string, md):
81
80
        self.assertEqual(fmt_string, md.get_raw_bundle().splitlines()[0])
268
267
        location = self.get_url('absentdir/')
269
268
        out, err = self.run_bzr(["send", "--from", location], retcode=3)
270
269
        self.assertEqual(out, '')
271
 
        self.assertEqual(err, 'brz: ERROR: Not a branch: "%s".\n' % location)
 
270
        self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
272
271
 
273
272
 
274
273
class TestSendStrictMixin(TestSendMixin):
276
275
    def make_parent_and_local_branches(self):
277
276
        # Create a 'parent' branch as the base
278
277
        self.parent_tree = ControlDir.create_standalone_workingtree('parent')
279
 
        self.build_tree_contents([('parent/file', b'parent')])
 
278
        self.build_tree_contents([('parent/file', 'parent')])
280
279
        self.parent_tree.add('file')
281
 
        self.parent_tree.commit('first commit', rev_id=b'parent')
 
280
        self.parent_tree.commit('first commit', rev_id='parent')
282
281
        # Branch 'local' from parent and do a change
283
 
        local_bzrdir = self.parent_tree.controldir.sprout('local')
 
282
        local_bzrdir = self.parent_tree.bzrdir.sprout('local')
284
283
        self.local_tree = local_bzrdir.open_workingtree()
285
 
        self.build_tree_contents([('local/file', b'local')])
286
 
        self.local_tree.commit('second commit', rev_id=b'local')
 
284
        self.build_tree_contents([('local/file', 'local')])
 
285
        self.local_tree.commit('second commit', rev_id='local')
287
286
 
288
287
    _default_command = ['send', '-o-', '../parent']
289
288
    _default_wd = 'local'
290
289
    _default_sent_revs = ['local']
291
290
    _default_errors = ['Working tree ".*/local/" has uncommitted '
292
 
                       'changes \(See brz status\)\.',]
 
291
                       'changes \(See bzr status\)\.',]
293
292
    _default_additional_error = 'Use --no-strict to force the send.\n'
294
293
    _default_additional_warning = 'Uncommitted changes will not be sent.'
295
294
 
317
316
            self.assertContainsRe(err, self._default_additional_warning)
318
317
            self.assertEndsWith(err, bundling_revs)
319
318
        else:
320
 
            self.assertEqual(bundling_revs, err)
321
 
        md = merge_directive.MergeDirective.from_lines(BytesIO(out))
 
319
            self.assertEquals(bundling_revs, err)
 
320
        md = merge_directive.MergeDirective.from_lines(StringIO(out))
322
321
        self.assertEqual('parent', md.base_revision_id)
323
 
        br = serializer.read_bundle(BytesIO(md.get_raw_bundle()))
 
322
        br = serializer.read_bundle(StringIO(md.get_raw_bundle()))
324
323
        self.assertEqual(set(revs), set(r.revision_id for r in br.revisions))
325
324
 
326
325
 
380
379
    def _uncommitted_changes(self):
381
380
        self.make_parent_and_local_branches()
382
381
        # Make a change without committing it
383
 
        self.build_tree_contents([('local/file', b'modified')])
 
382
        self.build_tree_contents([('local/file', 'modified')])
384
383
 
385
384
    def _pending_merges(self):
386
385
        self.make_parent_and_local_branches()
387
386
        # Create 'other' branch containing a new file
388
 
        other_bzrdir = self.parent_tree.controldir.sprout('other')
 
387
        other_bzrdir = self.parent_tree.bzrdir.sprout('other')
389
388
        other_tree = other_bzrdir.open_workingtree()
390
 
        self.build_tree_contents([('other/other-file', b'other')])
 
389
        self.build_tree_contents([('other/other-file', 'other')])
391
390
        other_tree.add('other-file')
392
 
        other_tree.commit('other commit', rev_id=b'other')
 
391
        other_tree.commit('other commit', rev_id='other')
393
392
        # Merge and revert, leaving a pending merge
394
393
        self.local_tree.merge_from_branch(other_tree.branch)
395
394
        self.local_tree.revert(filenames=['other-file'], backups=False)
398
397
        self.make_parent_and_local_branches()
399
398
        self.run_bzr(['checkout', '--lightweight', 'local', 'checkout'])
400
399
        # Make a change and commit it
401
 
        self.build_tree_contents([('local/file', b'modified in local')])
402
 
        self.local_tree.commit('modify file', rev_id=b'modified-in-local')
 
400
        self.build_tree_contents([('local/file', 'modified in local')])
 
401
        self.local_tree.commit('modify file', rev_id='modified-in-local')
403
402
        # Exercise commands from the checkout directory
404
403
        self._default_wd = 'checkout'
405
404
        self._default_errors = ["Working tree is out of date, please run"
406
 
                                " 'brz update'\.",]
 
405
                                " 'bzr update'\.",]
407
406
        self._default_sent_revs = ['modified-in-local', 'local']
408
407
 
409
408
    def test_send_default(self):
448
447
    def test_send(self):
449
448
        self.setup_smart_server_with_call_log()
450
449
        t = self.make_branch_and_tree('branch')
451
 
        self.build_tree_contents([('branch/foo', b'thecontents')])
 
450
        self.build_tree_contents([('branch/foo', 'thecontents')])
452
451
        t.add("foo")
453
452
        t.commit("message")
454
 
        local = t.controldir.sprout('local-branch').open_workingtree()
455
 
        self.build_tree_contents([('branch/foo', b'thenewcontents')])
 
453
        local = t.bzrdir.sprout('local-branch').open_workingtree()
 
454
        self.build_tree_contents([('branch/foo', 'thenewcontents')])
456
455
        local.commit("anothermessage")
457
456
        self.reset_smart_call_log()
458
457
        out, err = self.run_bzr(