/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: 2020-04-05 19:11:34 UTC
  • mto: (7490.7.16 work)
  • mto: This revision was merged to the branch mainline in revision 7501.
  • Revision ID: jelmer@jelmer.uk-20200405191134-0aebh8ikiwygxma5
Populate the .gitignore file.

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
        return controldir.format_registry.make_controldir('development-subtree')
32
31
 
33
32
    def test_no_args_lists(self):
34
 
        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')
 
33
        tree = self.make_branch_and_tree('branch')
 
34
        branch = tree.branch
 
35
        tree.add_reference(self.make_branch_and_tree('branch/path'))
 
36
        tree.add_reference(self.make_branch_and_tree('branch/lath'))
 
37
        tree.set_reference_info('path', 'http://example.org')
 
38
        tree.set_reference_info('lath', 'http://example.org/2')
37
39
        out, err = self.run_bzr('reference', working_dir='branch')
38
40
        lines = out.splitlines()
39
41
        self.assertEqual('lath http://example.org/2', lines[0])
41
43
 
42
44
    def make_tree_with_reference(self):
43
45
        tree = self.make_branch_and_tree('tree')
44
 
        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
        subtree = self.make_branch_and_tree('tree/newpath')
 
47
        tree.add_reference(subtree)
 
48
        tree.set_reference_info('newpath', 'http://example.org')
 
49
        tree.commit('add reference')
49
50
        return tree
50
51
 
51
52
    def test_uses_working_tree_location(self):
55
56
 
56
57
    def test_uses_basis_tree_location(self):
57
58
        tree = self.make_tree_with_reference()
58
 
        tree.commit('add newpath')
59
 
        tree.bzrdir.destroy_workingtree()
 
59
        tree.controldir.destroy_workingtree()
60
60
        out, err = self.run_bzr('reference', working_dir='tree')
61
61
        self.assertContainsRe(out, 'newpath http://example.org\n')
62
62
 
67
67
 
68
68
    def test_one_arg_uses_containing_tree(self):
69
69
        tree = self.make_tree_with_reference()
70
 
        out, err = self.run_bzr('reference tree/newpath')
 
70
        out, err = self.run_bzr('reference -d tree newpath')
71
71
        self.assertEqual('newpath http://example.org\n', out)
72
72
 
73
73
    def test_two_args_sets(self):
74
74
        tree = self.make_branch_and_tree('tree')
75
75
        self.build_tree(['tree/file'])
76
 
        tree.add('file', 'file-id')
77
 
        out, err = self.run_bzr('reference tree/file http://example.org')
78
 
        path, location = tree.branch.get_reference_info('file-id')
 
76
        tree.add('file')
 
77
        out, err = self.run_bzr('reference -d tree file http://example.org')
 
78
        location = tree.get_reference_info('file')
79
79
        self.assertEqual('http://example.org', location)
80
 
        self.assertEqual('file', path)
81
80
        self.assertEqual('', out)
82
81
        self.assertEqual('', err)
83
82
 
85
84
        tree = self.make_branch_and_tree('tree')
86
85
        out, err = self.run_bzr('reference file http://example.org',
87
86
                                working_dir='tree', retcode=3)
88
 
        self.assertEqual('bzr: ERROR: file is not versioned.\n', err)
 
87
        self.assertEqual('brz: ERROR: file is not versioned.\n', err)
 
88
 
 
89
    def test_missing_file_forced(self):
 
90
        tree = self.make_branch_and_tree('tree')
 
91
        tree.add_reference(self.make_branch_and_tree('tree/file'))
 
92
        out, err = self.run_bzr(
 
93
            'reference --force-unversioned file http://example.org',
 
94
            working_dir='tree')
 
95
        location = tree.get_reference_info('file')
 
96
        self.assertEqual('http://example.org', location)
 
97
        self.assertEqual('', out)
 
98
        self.assertEqual('', err)