/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_checkout.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:
30
30
from breezy.tests import (
31
31
    TestCaseWithTransport,
32
32
    )
 
33
from breezy.tests.matchers import ContainsNoVfsCalls
33
34
from breezy.tests.features import (
34
35
    HardlinkFeature,
35
36
    )
40
41
    def setUp(self):
41
42
        super(TestCheckout, self).setUp()
42
43
        tree = controldir.ControlDir.create_standalone_workingtree('branch')
43
 
        tree.commit('1', rev_id=b'1', allow_pointless=True)
 
44
        tree.commit('1', rev_id='1', allow_pointless=True)
44
45
        self.build_tree(['branch/added_in_2'])
45
46
        tree.add('added_in_2')
46
 
        tree.commit('2', rev_id=b'2')
 
47
        tree.commit('2', rev_id='2')
47
48
 
48
49
    def test_checkout_makes_bound_branch(self):
49
50
        self.run_bzr('checkout branch checkout')
66
67
        # the working tree should now be at revision '1' with the content
67
68
        # from 1.
68
69
        result = controldir.ControlDir.open('checkout')
69
 
        self.assertEqual([b'1'], result.open_workingtree().get_parent_ids())
 
70
        self.assertEqual(['1'], result.open_workingtree().get_parent_ids())
70
71
        self.assertPathDoesNotExist('checkout/added_in_2')
71
72
 
72
73
    def test_checkout_light_dash_r(self):
73
 
        out, err = self.run_bzr(['checkout', '--lightweight', '-r', '-2',
74
 
                                 'branch', 'checkout'])
 
74
        out, err = self.run_bzr(['checkout','--lightweight', '-r', '-2',
 
75
            'branch', 'checkout'])
75
76
        # the working tree should now be at revision '1' with the content
76
77
        # from 1.
77
78
        result = controldir.ControlDir.open('checkout')
78
 
        self.assertEqual([b'1'], result.open_workingtree().get_parent_ids())
 
79
        self.assertEqual(['1'], result.open_workingtree().get_parent_ids())
79
80
        self.assertPathDoesNotExist('checkout/added_in_2')
80
81
 
81
82
    def test_checkout_into_empty_dir(self):
95
96
            force_new_tree=False,
96
97
            format=bzrdir.BzrDirMetaFormat1())
97
98
        # check no tree was created
98
 
        self.assertRaises(errors.NoWorkingTree,
99
 
                          branch.controldir.open_workingtree)
 
99
        self.assertRaises(errors.NoWorkingTree, branch.controldir.open_workingtree)
100
100
        out, err = self.run_bzr('checkout treeless-branch')
101
101
        # we should have a tree now
102
102
        branch.controldir.open_workingtree()
109
109
            force_new_tree=False,
110
110
            format=bzrdir.BzrDirMetaFormat1())
111
111
        # check no tree was created
112
 
        self.assertRaises(errors.NoWorkingTree,
113
 
                          branch.controldir.open_workingtree)
 
112
        self.assertRaises(errors.NoWorkingTree, branch.controldir.open_workingtree)
114
113
        out, err = self.run_bzr('checkout')
115
114
        # we should have a tree now
116
115
        branch.controldir.open_workingtree()
119
118
 
120
119
    def _test_checkout_existing_dir(self, lightweight):
121
120
        source = self.make_branch_and_tree('source')
122
 
        self.build_tree_contents([('source/file1', b'content1'),
123
 
                                  ('source/file2', b'content2'), ])
 
121
        self.build_tree_contents([('source/file1', 'content1'),
 
122
                                  ('source/file2', 'content2'),])
124
123
        source.add(['file1', 'file2'])
125
124
        source.commit('added files')
126
 
        self.build_tree_contents([('target/', b''),
127
 
                                  ('target/file1', b'content1'),
128
 
                                  ('target/file2', b'content3'), ])
 
125
        self.build_tree_contents([('target/', ''),
 
126
                                  ('target/file1', 'content1'),
 
127
                                  ('target/file2', 'content3'),])
129
128
        cmd = ['checkout', 'source', 'target']
130
129
        if lightweight:
131
130
            cmd.append('--lightweight')
146
145
        branch.controldir.destroy_workingtree()
147
146
        self.run_bzr('checkout -r 1', working_dir='branch')
148
147
        tree = workingtree.WorkingTree.open('branch')
149
 
        self.assertEqual(b'1', tree.last_revision())
 
148
        self.assertEqual('1', tree.last_revision())
150
149
        branch.controldir.destroy_workingtree()
151
150
        self.run_bzr('checkout -r 0', working_dir='branch')
152
 
        self.assertEqual(b'null:', tree.last_revision())
 
151
        self.assertEqual('null:', tree.last_revision())
153
152
 
154
153
    def test_checkout_files_from(self):
155
154
        branch = _mod_branch.Branch.open('branch')
186
185
        source.add('file1')
187
186
        source.commit('added file')
188
187
        target = source.controldir.sprout('file:second,branch=somebranch',
189
 
                                          create_tree_if_local=False)
 
188
            create_tree_if_local=False)
190
189
        out, err = self.run_bzr('checkout file:,branch=somebranch .',
191
 
                                working_dir='second')
 
190
            working_dir='second')
192
191
        # We should always be creating a lighweight checkout for colocated
193
192
        # branches.
194
193
        self.assertEqual(
195
 
            target.open_branch(name='somebranch').user_url,
 
194
            target.open_branch(name='somebranch').base,
196
195
            target.get_branch_reference(name=""))
 
196
 
 
197
 
 
198
class TestSmartServerCheckout(TestCaseWithTransport):
 
199
 
 
200
    def test_heavyweight_checkout(self):
 
201
        self.setup_smart_server_with_call_log()
 
202
        t = self.make_branch_and_tree('from')
 
203
        for count in range(9):
 
204
            t.commit(message='commit %d' % count)
 
205
        self.reset_smart_call_log()
 
206
        out, err = self.run_bzr(['checkout', self.get_url('from'), 'target'])
 
207
        # This figure represent the amount of work to perform this use case. It
 
208
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
209
        # being too low. If rpc_count increases, more network roundtrips have
 
210
        # become necessary for this use case. Please do not adjust this number
 
211
        # upwards without agreement from bzr's network support maintainers.
 
212
        self.assertLength(10, self.hpss_calls)
 
213
        self.assertLength(1, self.hpss_connections)
 
214
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
 
215
 
 
216
    def test_lightweight_checkout(self):
 
217
        self.setup_smart_server_with_call_log()
 
218
        t = self.make_branch_and_tree('from')
 
219
        for count in range(9):
 
220
            t.commit(message='commit %d' % count)
 
221
        self.reset_smart_call_log()
 
222
        out, err = self.run_bzr(['checkout', '--lightweight', self.get_url('from'),
 
223
            'target'])
 
224
        # This figure represent the amount of work to perform this use case. It
 
225
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
226
        # being too low. If rpc_count increases, more network roundtrips have
 
227
        # become necessary for this use case. Please do not adjust this number
 
228
        # upwards without agreement from bzr's network support maintainers.
 
229
        self.assertLength(13, self.hpss_calls)
 
230
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)