/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-03-22 01:35:14 UTC
  • mfrom: (7490.7.6 work)
  • mto: This revision was merged to the branch mainline in revision 7499.
  • Revision ID: jelmer@jelmer.uk-20200322013514-7vw1ntwho04rcuj3
merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
class TestReference(TestCaseWithTransport):
28
28
 
29
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
 
30
        return controldir.format_registry.make_controldir('development-subtree')
33
31
 
34
32
    def test_no_args_lists(self):
35
 
        branch = self.make_branch('branch')
36
 
        branch.set_reference_info('file-id', 'path', 'http://example.org')
37
 
        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')
38
39
        out, err = self.run_bzr('reference', working_dir='branch')
39
40
        lines = out.splitlines()
40
41
        self.assertEqual('lath http://example.org/2', lines[0])
42
43
 
43
44
    def make_tree_with_reference(self):
44
45
        tree = self.make_branch_and_tree('tree')
45
 
        self.build_tree(['tree/newpath'])
46
 
        tree.add('newpath', 'file-id')
47
 
        tree.branch.set_reference_info('file-id', 'path', 'http://example.org')
48
 
        tree.branch.set_reference_info('file-id2', 'lath',
49
 
                                       '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')
50
50
        return tree
51
51
 
52
52
    def test_uses_working_tree_location(self):
56
56
 
57
57
    def test_uses_basis_tree_location(self):
58
58
        tree = self.make_tree_with_reference()
59
 
        tree.commit('add newpath')
60
59
        tree.controldir.destroy_workingtree()
61
60
        out, err = self.run_bzr('reference', working_dir='tree')
62
61
        self.assertContainsRe(out, 'newpath http://example.org\n')
68
67
 
69
68
    def test_one_arg_uses_containing_tree(self):
70
69
        tree = self.make_tree_with_reference()
71
 
        out, err = self.run_bzr('reference tree/newpath')
 
70
        out, err = self.run_bzr('reference -d tree newpath')
72
71
        self.assertEqual('newpath http://example.org\n', out)
73
72
 
74
73
    def test_two_args_sets(self):
75
74
        tree = self.make_branch_and_tree('tree')
76
75
        self.build_tree(['tree/file'])
77
 
        tree.add('file', 'file-id')
78
 
        out, err = self.run_bzr('reference tree/file http://example.org')
79
 
        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')
80
79
        self.assertEqual('http://example.org', location)
81
 
        self.assertEqual('file', path)
82
80
        self.assertEqual('', out)
83
81
        self.assertEqual('', err)
84
82
 
87
85
        out, err = self.run_bzr('reference file http://example.org',
88
86
                                working_dir='tree', retcode=3)
89
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)