/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_reference.py

  • Committer: Robert Collins
  • Date: 2010-05-11 08:36:16 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100511083616-b8fjb19zomwupid0
Make all lock methods return Result objects, rather than lock_read returning self, as per John's review.

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 breezy import (
19
 
    controldir,
 
18
from bzrlib import (
 
19
    branch as _mod_branch,
 
20
    bzrdir,
20
21
    )
21
 
from breezy.tests import TestCaseWithTransport
 
22
from bzrlib.tests import TestCaseWithTransport
22
23
 
23
24
 
24
25
class TestReference(TestCaseWithTransport):
25
26
 
26
 
    def get_default_format(self):
27
 
        return controldir.format_registry.make_controldir('development-subtree')
 
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)
28
32
 
29
33
    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')
 
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')
36
37
        out, err = self.run_bzr('reference', working_dir='branch')
37
38
        lines = out.splitlines()
38
39
        self.assertEqual('lath http://example.org/2', lines[0])
40
41
 
41
42
    def make_tree_with_reference(self):
42
43
        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')
 
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')
47
49
        return tree
48
50
 
49
51
    def test_uses_working_tree_location(self):
53
55
 
54
56
    def test_uses_basis_tree_location(self):
55
57
        tree = self.make_tree_with_reference()
56
 
        tree.controldir.destroy_workingtree()
 
58
        tree.commit('add newpath')
 
59
        tree.bzrdir.destroy_workingtree()
57
60
        out, err = self.run_bzr('reference', working_dir='tree')
58
61
        self.assertContainsRe(out, 'newpath http://example.org\n')
59
62
 
64
67
 
65
68
    def test_one_arg_uses_containing_tree(self):
66
69
        tree = self.make_tree_with_reference()
67
 
        out, err = self.run_bzr('reference -d tree newpath')
 
70
        out, err = self.run_bzr('reference tree/newpath')
68
71
        self.assertEqual('newpath http://example.org\n', out)
69
72
 
70
73
    def test_two_args_sets(self):
71
74
        tree = self.make_branch_and_tree('tree')
72
75
        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')
 
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
79
        self.assertEqual('http://example.org', location)
 
80
        self.assertEqual('file', path)
77
81
        self.assertEqual('', out)
78
82
        self.assertEqual('', err)
79
83
 
81
85
        tree = self.make_branch_and_tree('tree')
82
86
        out, err = self.run_bzr('reference file http://example.org',
83
87
                                working_dir='tree', retcode=3)
84
 
        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)
 
88
        self.assertEqual('bzr: ERROR: file is not versioned.\n', err)