/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 brzlib/tests/blackbox/test_checkout.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-21 12:41:27 UTC
  • mto: This revision was merged to the branch mainline in revision 6623.
  • Revision ID: jelmer@jelmer.uk-20170521124127-iv8etg0vwymyai6y
s/bzr/brz/ in apport config.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
import os
20
20
 
21
 
from breezy import (
 
21
from brzlib import (
22
22
    branch as _mod_branch,
 
23
    bzrdir,
23
24
    controldir,
24
25
    errors,
25
26
    workingtree,
26
27
    )
27
 
from breezy.bzr import (
28
 
    bzrdir,
29
 
    )
30
 
from breezy.tests import (
 
28
from brzlib.tests import (
31
29
    TestCaseWithTransport,
32
30
    )
33
 
from breezy.tests.matchers import ContainsNoVfsCalls
34
 
from breezy.tests.features import (
 
31
from brzlib.tests.matchers import ContainsNoVfsCalls
 
32
from brzlib.tests.features import (
35
33
    HardlinkFeature,
36
34
    )
37
35
 
41
39
    def setUp(self):
42
40
        super(TestCheckout, self).setUp()
43
41
        tree = controldir.ControlDir.create_standalone_workingtree('branch')
44
 
        tree.commit('1', rev_id=b'1', allow_pointless=True)
 
42
        tree.commit('1', rev_id='1', allow_pointless=True)
45
43
        self.build_tree(['branch/added_in_2'])
46
44
        tree.add('added_in_2')
47
 
        tree.commit('2', rev_id=b'2')
 
45
        tree.commit('2', rev_id='2')
48
46
 
49
47
    def test_checkout_makes_bound_branch(self):
50
48
        self.run_bzr('checkout branch checkout')
51
49
        # if we have a checkout, the branch base should be 'branch'
52
50
        source = controldir.ControlDir.open('branch')
53
51
        result = controldir.ControlDir.open('checkout')
54
 
        self.assertEqual(source.open_branch().controldir.root_transport.base,
 
52
        self.assertEqual(source.open_branch().bzrdir.root_transport.base,
55
53
                         result.open_branch().get_bound_location())
56
54
 
57
55
    def test_checkout_light_makes_checkout(self):
59
57
        # if we have a checkout, the branch base should be 'branch'
60
58
        source = controldir.ControlDir.open('branch')
61
59
        result = controldir.ControlDir.open('checkout')
62
 
        self.assertEqual(source.open_branch().controldir.root_transport.base,
63
 
                         result.open_branch().controldir.root_transport.base)
 
60
        self.assertEqual(source.open_branch().bzrdir.root_transport.base,
 
61
                         result.open_branch().bzrdir.root_transport.base)
64
62
 
65
63
    def test_checkout_dash_r(self):
66
64
        out, err = self.run_bzr(['checkout', '-r', '-2', 'branch', 'checkout'])
67
65
        # the working tree should now be at revision '1' with the content
68
66
        # from 1.
69
67
        result = controldir.ControlDir.open('checkout')
70
 
        self.assertEqual([b'1'], result.open_workingtree().get_parent_ids())
 
68
        self.assertEqual(['1'], result.open_workingtree().get_parent_ids())
71
69
        self.assertPathDoesNotExist('checkout/added_in_2')
72
70
 
73
71
    def test_checkout_light_dash_r(self):
74
 
        out, err = self.run_bzr(['checkout', '--lightweight', '-r', '-2',
75
 
                                 'branch', 'checkout'])
 
72
        out, err = self.run_bzr(['checkout','--lightweight', '-r', '-2',
 
73
            'branch', 'checkout'])
76
74
        # the working tree should now be at revision '1' with the content
77
75
        # from 1.
78
76
        result = controldir.ControlDir.open('checkout')
79
 
        self.assertEqual([b'1'], result.open_workingtree().get_parent_ids())
 
77
        self.assertEqual(['1'], result.open_workingtree().get_parent_ids())
80
78
        self.assertPathDoesNotExist('checkout/added_in_2')
81
79
 
82
80
    def test_checkout_into_empty_dir(self):
83
 
        self.make_controldir('checkout')
 
81
        self.make_bzrdir('checkout')
84
82
        out, err = self.run_bzr(['checkout', 'branch', 'checkout'])
85
83
        result = controldir.ControlDir.open('checkout')
86
84
        tree = result.open_workingtree()
87
85
        branch = result.open_branch()
88
86
 
89
87
    def test_checkout_reconstitutes_working_trees(self):
90
 
        # doing a 'brz checkout' in the directory of a branch with no tree
91
 
        # or a 'brz checkout path' with path the name of a directory with
 
88
        # doing a 'bzr checkout' in the directory of a branch with no tree
 
89
        # or a 'bzr checkout path' with path the name of a directory with
92
90
        # a branch with no tree will reconsistute the tree.
93
91
        os.mkdir('treeless-branch')
94
92
        branch = controldir.ControlDir.create_branch_convenience(
96
94
            force_new_tree=False,
97
95
            format=bzrdir.BzrDirMetaFormat1())
98
96
        # check no tree was created
99
 
        self.assertRaises(errors.NoWorkingTree,
100
 
                          branch.controldir.open_workingtree)
 
97
        self.assertRaises(errors.NoWorkingTree, branch.bzrdir.open_workingtree)
101
98
        out, err = self.run_bzr('checkout treeless-branch')
102
99
        # we should have a tree now
103
 
        branch.controldir.open_workingtree()
 
100
        branch.bzrdir.open_workingtree()
104
101
        # with no diff
105
102
        out, err = self.run_bzr('diff treeless-branch')
106
103
 
110
107
            force_new_tree=False,
111
108
            format=bzrdir.BzrDirMetaFormat1())
112
109
        # check no tree was created
113
 
        self.assertRaises(errors.NoWorkingTree,
114
 
                          branch.controldir.open_workingtree)
 
110
        self.assertRaises(errors.NoWorkingTree, branch.bzrdir.open_workingtree)
115
111
        out, err = self.run_bzr('checkout')
116
112
        # we should have a tree now
117
 
        branch.controldir.open_workingtree()
 
113
        branch.bzrdir.open_workingtree()
118
114
        # with no diff
119
115
        out, err = self.run_bzr('diff')
120
116
 
121
117
    def _test_checkout_existing_dir(self, lightweight):
122
118
        source = self.make_branch_and_tree('source')
123
 
        self.build_tree_contents([('source/file1', b'content1'),
124
 
                                  ('source/file2', b'content2'), ])
 
119
        self.build_tree_contents([('source/file1', 'content1'),
 
120
                                  ('source/file2', 'content2'),])
125
121
        source.add(['file1', 'file2'])
126
122
        source.commit('added files')
127
 
        self.build_tree_contents([('target/', b''),
128
 
                                  ('target/file1', b'content1'),
129
 
                                  ('target/file2', b'content3'), ])
 
123
        self.build_tree_contents([('target/', ''),
 
124
                                  ('target/file1', 'content1'),
 
125
                                  ('target/file2', 'content3'),])
130
126
        cmd = ['checkout', 'source', 'target']
131
127
        if lightweight:
132
128
            cmd.append('--lightweight')
144
140
 
145
141
    def test_checkout_in_branch_with_r(self):
146
142
        branch = _mod_branch.Branch.open('branch')
147
 
        branch.controldir.destroy_workingtree()
 
143
        branch.bzrdir.destroy_workingtree()
148
144
        self.run_bzr('checkout -r 1', working_dir='branch')
149
145
        tree = workingtree.WorkingTree.open('branch')
150
 
        self.assertEqual(b'1', tree.last_revision())
151
 
        branch.controldir.destroy_workingtree()
 
146
        self.assertEqual('1', tree.last_revision())
 
147
        branch.bzrdir.destroy_workingtree()
152
148
        self.run_bzr('checkout -r 0', working_dir='branch')
153
 
        self.assertEqual(b'null:', tree.last_revision())
 
149
        self.assertEqual('null:', tree.last_revision())
154
150
 
155
151
    def test_checkout_files_from(self):
156
152
        branch = _mod_branch.Branch.open('branch')
174
170
        self.build_tree(['source/file1'])
175
171
        source.add('file1')
176
172
        source.commit('added file')
177
 
        source.controldir.sprout('second')
 
173
        source.bzrdir.sprout('second')
178
174
        out, err = self.run_bzr('checkout source target --hardlink'
179
175
                                ' --files-from second')
180
176
        second_stat = os.stat('second/file1')
186
182
        self.build_tree(['source/file1'])
187
183
        source.add('file1')
188
184
        source.commit('added file')
189
 
        target = source.controldir.sprout('file:second,branch=somebranch',
190
 
                                          create_tree_if_local=False)
 
185
        target = source.bzrdir.sprout('file:second,branch=somebranch',
 
186
            create_tree_if_local=False)
191
187
        out, err = self.run_bzr('checkout file:,branch=somebranch .',
192
 
                                working_dir='second')
 
188
            working_dir='second')
193
189
        # We should always be creating a lighweight checkout for colocated
194
190
        # branches.
195
191
        self.assertEqual(
196
 
            target.open_branch(name='somebranch').user_url,
 
192
            target.open_branch(name='somebranch').base,
197
193
            target.get_branch_reference(name=""))
198
194
 
199
195
 
211
207
        # being too low. If rpc_count increases, more network roundtrips have
212
208
        # become necessary for this use case. Please do not adjust this number
213
209
        # upwards without agreement from bzr's network support maintainers.
214
 
        self.assertLength(11, self.hpss_calls)
 
210
        self.assertLength(10, self.hpss_calls)
215
211
        self.assertLength(1, self.hpss_connections)
216
212
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
217
213
 
222
218
            t.commit(message='commit %d' % count)
223
219
        self.reset_smart_call_log()
224
220
        out, err = self.run_bzr(['checkout', '--lightweight', self.get_url('from'),
225
 
                                 'target'])
 
221
            'target'])
226
222
        # This figure represent the amount of work to perform this use case. It
227
223
        # is entirely ok to reduce this number if a test fails due to rpc_count
228
224
        # being too low. If rpc_count increases, more network roundtrips have