~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_checkout.py

  • Committer: Martin Packman
  • Date: 2011-12-08 19:00:14 UTC
  • mto: This revision was merged to the branch mainline in revision 6359.
  • Revision ID: martin.packman@canonical.com-20111208190014-mi8jm6v7jygmhb0r
Use --include-duplicates for make update-pot which already combines multiple msgid strings prettily

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2009-2012 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
27
27
from bzrlib.tests import (
28
28
    TestCaseWithTransport,
29
29
    )
30
 
from bzrlib.tests.matchers import ContainsNoVfsCalls
31
30
from bzrlib.tests.features import (
32
31
    HardlinkFeature,
33
32
    )
76
75
        self.assertEqual(['1'], result.open_workingtree().get_parent_ids())
77
76
        self.assertPathDoesNotExist('checkout/added_in_2')
78
77
 
79
 
    def test_checkout_into_empty_dir(self):
80
 
        self.make_bzrdir('checkout')
81
 
        out, err = self.run_bzr(['checkout', 'branch', 'checkout'])
82
 
        result = bzrdir.BzrDir.open('checkout')
83
 
        tree = result.open_workingtree()
84
 
        branch = result.open_branch()
85
 
 
86
78
    def test_checkout_reconstitutes_working_trees(self):
87
79
        # doing a 'bzr checkout' in the directory of a branch with no tree
88
80
        # or a 'bzr checkout path' with path the name of a directory with
140
132
    def test_checkout_in_branch_with_r(self):
141
133
        branch = _mod_branch.Branch.open('branch')
142
134
        branch.bzrdir.destroy_workingtree()
143
 
        self.run_bzr('checkout -r 1', working_dir='branch')
144
 
        tree = workingtree.WorkingTree.open('branch')
 
135
        os.chdir('branch')
 
136
        self.run_bzr('checkout -r 1')
 
137
        tree = workingtree.WorkingTree.open('.')
145
138
        self.assertEqual('1', tree.last_revision())
146
139
        branch.bzrdir.destroy_workingtree()
147
 
        self.run_bzr('checkout -r 0', working_dir='branch')
 
140
        self.run_bzr('checkout -r 0')
148
141
        self.assertEqual('null:', tree.last_revision())
149
142
 
150
143
    def test_checkout_files_from(self):
176
169
        target_stat = os.stat('target/file1')
177
170
        self.assertEqual(second_stat, target_stat)
178
171
 
179
 
    def test_colo_checkout(self):
180
 
        source = self.make_branch_and_tree('source', format='development-colo')
181
 
        self.build_tree(['source/file1'])
182
 
        source.add('file1')
183
 
        source.commit('added file')
184
 
        target = source.bzrdir.sprout('file:second,branch=somebranch',
185
 
            create_tree_if_local=False)
186
 
        out, err = self.run_bzr('checkout file:,branch=somebranch .',
187
 
            working_dir='second')
188
 
        # We should always be creating a lighweight checkout for colocated
189
 
        # branches.
190
 
        self.assertEquals(
191
 
            target.open_branch(name='somebranch').base,
192
 
            target.get_branch_reference(name=""))
193
 
 
194
172
 
195
173
class TestSmartServerCheckout(TestCaseWithTransport):
196
174
 
200
178
        for count in range(9):
201
179
            t.commit(message='commit %d' % count)
202
180
        self.reset_smart_call_log()
203
 
        out, err = self.run_bzr(['checkout', self.get_url('from'), 'target'])
 
181
        out, err = self.run_bzr(['checkout', self.get_url('from'),
 
182
            'target'])
204
183
        # This figure represent the amount of work to perform this use case. It
205
184
        # is entirely ok to reduce this number if a test fails due to rpc_count
206
185
        # being too low. If rpc_count increases, more network roundtrips have
207
186
        # become necessary for this use case. Please do not adjust this number
208
187
        # upwards without agreement from bzr's network support maintainers.
209
 
        self.assertLength(10, self.hpss_calls)
210
 
        self.assertLength(1, self.hpss_connections)
211
 
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
 
188
        self.assertLength(17, self.hpss_calls)
212
189
 
213
190
    def test_lightweight_checkout(self):
214
191
        self.setup_smart_server_with_call_log()
223
200
        # being too low. If rpc_count increases, more network roundtrips have
224
201
        # become necessary for this use case. Please do not adjust this number
225
202
        # upwards without agreement from bzr's network support maintainers.
226
 
        self.assertLength(13, self.hpss_calls)
227
 
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
 
203
        if len(self.hpss_calls) < 34 or len(self.hpss_calls) > 48:
 
204
            self.fail(
 
205
                "Incorrect length: wanted between 34 and 48, got %d for %r" % (
 
206
                    len(self.hpss_calls), self.hpss_calls))