/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: 2017-07-23 22:06:41 UTC
  • mfrom: (6738 trunk)
  • mto: This revision was merged to the branch mainline in revision 6739.
  • Revision ID: jelmer@jelmer.uk-20170723220641-69eczax9bmv8d6kk
Merge trunk, address review comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
from breezy import (
19
19
    controldir,
20
20
    )
 
21
from breezy.bzr import (
 
22
    branch as _mod_bzrbranch,
 
23
    )
21
24
from breezy.tests import TestCaseWithTransport
22
25
 
23
26
 
24
27
class TestReference(TestCaseWithTransport):
25
28
 
26
29
    def get_default_format(self):
27
 
        return controldir.format_registry.make_controldir('development-subtree')
 
30
        format = controldir.format_registry.make_controldir('1.9')
 
31
        format.set_branch_format(_mod_bzrbranch.BzrBranchFormat8())
 
32
        return format
28
33
 
29
34
    def test_no_args_lists(self):
30
 
        tree = self.make_branch_and_tree('branch')
31
 
        branch = tree.branch
32
 
        tree.add_reference(self.make_branch_and_tree('branch/path'))
33
 
        tree.add_reference(self.make_branch_and_tree('branch/lath'))
34
 
        tree.set_reference_info('path', 'http://example.org')
35
 
        tree.set_reference_info('lath', 'http://example.org/2')
 
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')
36
38
        out, err = self.run_bzr('reference', working_dir='branch')
37
39
        lines = out.splitlines()
38
40
        self.assertEqual('lath http://example.org/2', lines[0])
40
42
 
41
43
    def make_tree_with_reference(self):
42
44
        tree = self.make_branch_and_tree('tree')
43
 
        subtree = self.make_branch_and_tree('tree/newpath')
44
 
        tree.add_reference(subtree)
45
 
        tree.set_reference_info('newpath', 'http://example.org')
46
 
        tree.commit('add reference')
 
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')
47
50
        return tree
48
51
 
49
52
    def test_uses_working_tree_location(self):
53
56
 
54
57
    def test_uses_basis_tree_location(self):
55
58
        tree = self.make_tree_with_reference()
 
59
        tree.commit('add newpath')
56
60
        tree.controldir.destroy_workingtree()
57
61
        out, err = self.run_bzr('reference', working_dir='tree')
58
62
        self.assertContainsRe(out, 'newpath http://example.org\n')
64
68
 
65
69
    def test_one_arg_uses_containing_tree(self):
66
70
        tree = self.make_tree_with_reference()
67
 
        out, err = self.run_bzr('reference -d tree newpath')
 
71
        out, err = self.run_bzr('reference tree/newpath')
68
72
        self.assertEqual('newpath http://example.org\n', out)
69
73
 
70
74
    def test_two_args_sets(self):
71
75
        tree = self.make_branch_and_tree('tree')
72
76
        self.build_tree(['tree/file'])
73
 
        tree.add('file')
74
 
        out, err = self.run_bzr('reference -d tree file http://example.org')
75
 
        location = tree.get_reference_info('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
80
        self.assertEqual('http://example.org', location)
 
81
        self.assertEqual('file', path)
77
82
        self.assertEqual('', out)
78
83
        self.assertEqual('', err)
79
84
 
82
87
        out, err = self.run_bzr('reference file http://example.org',
83
88
                                working_dir='tree', retcode=3)
84
89
        self.assertEqual('brz: ERROR: file is not versioned.\n', err)
85
 
 
86
 
    def test_missing_file_forced(self):
87
 
        tree = self.make_branch_and_tree('tree')
88
 
        tree.add_reference(self.make_branch_and_tree('tree/file'))
89
 
        out, err = self.run_bzr(
90
 
            'reference --force-unversioned file http://example.org',
91
 
            working_dir='tree')
92
 
        location = tree.get_reference_info('file')
93
 
        self.assertEqual('http://example.org', location)
94
 
        self.assertEqual('', out)
95
 
        self.assertEqual('', err)