1
# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
1
# Copyright (C) 2005, 2006, 2009 Canonical Ltd
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
31
from bzrlib.tests import (
32
TestCaseWithTransport,
31
from bzrlib.tests.blackbox import (
34
34
from bzrlib.tests import (
37
from bzrlib.tests.features import (
42
class TestCheckout(TestCaseWithTransport):
40
class TestCheckout(ExternalBase):
45
43
super(TestCheckout, self).setUp()
66
64
result.open_branch().bzrdir.root_transport.base)
68
66
def test_checkout_dash_r(self):
69
out, err = self.run_bzr(['checkout', '-r', '-2', 'branch', 'checkout'])
67
self.run_bzr('checkout -r -2 branch checkout')
70
68
# the working tree should now be at revision '1' with the content
72
70
result = bzrdir.BzrDir.open('checkout')
73
71
self.assertEqual(['1'], result.open_workingtree().get_parent_ids())
74
self.assertPathDoesNotExist('checkout/added_in_2')
72
self.failIfExists('checkout/added_in_2')
76
74
def test_checkout_light_dash_r(self):
77
out, err = self.run_bzr(['checkout','--lightweight', '-r', '-2',
78
'branch', 'checkout'])
75
self.run_bzr('checkout --lightweight -r -2 branch checkout')
79
76
# the working tree should now be at revision '1' with the content
81
78
result = bzrdir.BzrDir.open('checkout')
82
79
self.assertEqual(['1'], result.open_workingtree().get_parent_ids())
83
self.assertPathDoesNotExist('checkout/added_in_2')
80
self.failIfExists('checkout/added_in_2')
85
82
def test_checkout_reconstitutes_working_trees(self):
86
83
# doing a 'bzr checkout' in the directory of a branch with no tree
126
123
cmd.append('--lightweight')
127
124
self.run_bzr('checkout source target')
128
125
# files with unique content should be moved
129
self.assertPathExists('target/file2.moved')
126
self.failUnlessExists('target/file2.moved')
130
127
# files with content matching tree should not be moved
131
self.assertPathDoesNotExist('target/file1.moved')
128
self.failIfExists('target/file1.moved')
133
130
def test_checkout_existing_dir_heavy(self):
134
131
self._test_checkout_existing_dir(False)
158
155
self.build_tree(['source/file1'])
159
156
source.add('file1')
160
157
source.commit('added file')
161
out, err = self.run_bzr('checkout source target --hardlink')
158
out, err = self.run_bzr(['checkout', 'source', 'target',
159
'--files-from', 'source',
162
161
source_stat = os.stat('source/file1')
163
162
target_stat = os.stat('target/file1')
164
163
self.assertEqual(source_stat, target_stat)
166
def test_checkout_hardlink_files_from(self):
167
self.requireFeature(HardlinkFeature)
168
source = self.make_branch_and_tree('source')
169
self.build_tree(['source/file1'])
171
source.commit('added file')
172
source.bzrdir.sprout('second')
173
out, err = self.run_bzr('checkout source target --hardlink'
174
' --files-from second')
175
second_stat = os.stat('second/file1')
176
target_stat = os.stat('target/file1')
177
self.assertEqual(second_stat, target_stat)