/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 breezy/tests/blackbox/test_reference.py

  • Committer: Jelmer Vernooij
  • Date: 2018-07-08 14:45:27 UTC
  • mto: This revision was merged to the branch mainline in revision 7036.
  • Revision ID: jelmer@jelmer.uk-20180708144527-codhlvdcdg9y0nji
Fix a bunch of merge tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
 
from bzrlib import (
19
 
    branch as _mod_branch,
20
 
    bzrdir,
21
 
    )
22
 
from bzrlib.tests import TestCaseWithTransport
 
18
from breezy import (
 
19
    controldir,
 
20
    )
 
21
from breezy.bzr import (
 
22
    branch as _mod_bzrbranch,
 
23
    )
 
24
from breezy.tests import TestCaseWithTransport
23
25
 
24
26
 
25
27
class TestReference(TestCaseWithTransport):
26
28
 
27
 
    def make_branch(self, location, format=None):
28
 
        if format is None:
29
 
            format = bzrdir.format_registry.make_bzrdir('1.9')
30
 
            format.set_branch_format(_mod_branch.BzrBranchFormat8())
31
 
        return TestCaseWithTransport.make_branch(self, location, format=format)
 
29
    def get_default_format(self):
 
30
        format = controldir.format_registry.make_controldir('1.9')
 
31
        format.set_branch_format(_mod_bzrbranch.BzrBranchFormat8())
 
32
        return format
32
33
 
33
34
    def test_no_args_lists(self):
34
35
        branch = self.make_branch('branch')
35
 
        branch.set_reference_info('file-id', 'path', 'http://example.org')
36
 
        branch.set_reference_info('file-id2', 'lath', 'http://example.org/2')
 
36
        branch.set_reference_info('path', 'http://example.org', b'file-id')
 
37
        branch.set_reference_info('lath', 'http://example.org/2', b'file-id2')
37
38
        out, err = self.run_bzr('reference', working_dir='branch')
38
39
        lines = out.splitlines()
39
40
        self.assertEqual('lath http://example.org/2', lines[0])
42
43
    def make_tree_with_reference(self):
43
44
        tree = self.make_branch_and_tree('tree')
44
45
        self.build_tree(['tree/newpath'])
45
 
        tree.add('newpath', 'file-id')
46
 
        tree.branch.set_reference_info('file-id', 'path', 'http://example.org')
47
 
        tree.branch.set_reference_info('file-id2', 'lath',
48
 
                                       'http://example.org/2')
 
46
        tree.add('newpath', b'file-id')
 
47
        tree.branch.set_reference_info('newpath', 'http://example.org', b'file-id')
 
48
        tree.branch.set_reference_info('lath', 'http://example.org/2',
 
49
                b'file-id2')
49
50
        return tree
50
51
 
51
52
    def test_uses_working_tree_location(self):
56
57
    def test_uses_basis_tree_location(self):
57
58
        tree = self.make_tree_with_reference()
58
59
        tree.commit('add newpath')
59
 
        tree.bzrdir.destroy_workingtree()
 
60
        tree.controldir.destroy_workingtree()
60
61
        out, err = self.run_bzr('reference', working_dir='tree')
61
62
        self.assertContainsRe(out, 'newpath http://example.org\n')
62
63
 
63
64
    def test_one_arg_displays(self):
64
65
        tree = self.make_tree_with_reference()
65
66
        out, err = self.run_bzr('reference newpath', working_dir='tree')
66
 
        self.assertEqual('newpath http://example.org\n', out)
 
67
        self.assertEqual(b'newpath http://example.org\n', out)
67
68
 
68
69
    def test_one_arg_uses_containing_tree(self):
69
70
        tree = self.make_tree_with_reference()
70
71
        out, err = self.run_bzr('reference tree/newpath')
71
 
        self.assertEqual('newpath http://example.org\n', out)
 
72
        self.assertEqual(b'newpath http://example.org\n', out)
72
73
 
73
74
    def test_two_args_sets(self):
74
75
        tree = self.make_branch_and_tree('tree')
75
76
        self.build_tree(['tree/file'])
76
 
        tree.add('file', 'file-id')
 
77
        tree.add('file', b'file-id')
77
78
        out, err = self.run_bzr('reference tree/file http://example.org')
78
 
        path, location = tree.branch.get_reference_info('file-id')
 
79
        location, file_id = tree.branch.get_reference_info('file')
79
80
        self.assertEqual('http://example.org', location)
80
 
        self.assertEqual('file', path)
81
 
        self.assertEqual('', out)
82
 
        self.assertEqual('', err)
 
81
        self.assertEqual(b'file-id', file_id)
 
82
        self.assertEqual(b'', out)
 
83
        self.assertEqual(b'', err)
83
84
 
84
85
    def test_missing_file(self):
85
86
        tree = self.make_branch_and_tree('tree')
86
87
        out, err = self.run_bzr('reference file http://example.org',
87
88
                                working_dir='tree', retcode=3)
88
 
        self.assertEqual('bzr: ERROR: file is not versioned.\n', err)
 
89
        self.assertEqual(b'brz: ERROR: file is not versioned.\n', err)