1
# Copyright (C) 2005, 2006 Canonical Ltd
1
# Copyright (C) 2005 by Canonical Ltd
2
# -*- coding: utf-8 -*-
3
4
# This program is free software; you can redistribute it and/or modify
4
5
# it under the terms of the GNU General Public License as published by
5
6
# the Free Software Foundation; either version 2 of the License, or
6
7
# (at your option) any later version.
8
9
# This program is distributed in the hope that it will be useful,
9
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
12
# GNU General Public License for more details.
13
14
# You should have received a copy of the GNU General Public License
14
15
# along with this program; if not, write to the Free Software
15
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
38
38
tree.commit('2', rev_id='2')
40
40
def test_checkout_makes_bound_branch(self):
41
self.run_bzr('checkout branch checkout')
41
self.runbzr('checkout branch checkout')
42
42
# if we have a checkout, the branch base should be 'branch'
43
43
source = bzrdir.BzrDir.open('branch')
44
44
result = bzrdir.BzrDir.open('checkout')
46
46
result.open_branch().get_bound_location())
48
48
def test_checkout_light_makes_checkout(self):
49
self.run_bzr('checkout --lightweight branch checkout')
49
self.runbzr('checkout --lightweight branch checkout')
50
50
# if we have a checkout, the branch base should be 'branch'
51
51
source = bzrdir.BzrDir.open('branch')
52
52
result = bzrdir.BzrDir.open('checkout')
54
54
result.open_branch().bzrdir.root_transport.base)
56
56
def test_checkout_dash_r(self):
57
self.run_bzr('checkout -r -2 branch checkout')
57
self.runbzr('checkout -r -2 branch checkout')
58
58
# the working tree should now be at revision '1' with the content
60
60
result = bzrdir.BzrDir.open('checkout')
61
self.assertEqual(['1'], result.open_workingtree().get_parent_ids())
61
self.assertEqual('1', result.open_workingtree().last_revision())
62
62
self.failIfExists('checkout/added_in_2')
64
64
def test_checkout_light_dash_r(self):
65
self.run_bzr('checkout --lightweight -r -2 branch checkout')
65
self.runbzr('checkout --lightweight -r -2 branch checkout')
66
66
# the working tree should now be at revision '1' with the content
68
68
result = bzrdir.BzrDir.open('checkout')
69
self.assertEqual(['1'], result.open_workingtree().get_parent_ids())
69
self.assertEqual('1', result.open_workingtree().last_revision())
70
70
self.failIfExists('checkout/added_in_2')
72
def test_checkout_reconstitutes_working_trees(self):
73
# doing a 'bzr checkout' in the directory of a branch with no tree
74
# or a 'bzr checkout path' with path the name of a directory with
75
# a branch with no tree will reconsistute the tree.
76
os.mkdir('treeless-branch')
77
branch = bzrdir.BzrDir.create_branch_convenience(
80
format=bzrdir.BzrDirMetaFormat1())
81
# check no tree was created
82
self.assertRaises(errors.NoWorkingTree, branch.bzrdir.open_workingtree)
83
out, err = self.run_bzr('checkout treeless-branch')
84
# we should have a tree now
85
branch.bzrdir.open_workingtree()
87
out, err = self.run_bzr('diff treeless-branch')
89
# now test with no parameters
90
branch = bzrdir.BzrDir.create_branch_convenience(
93
format=bzrdir.BzrDirMetaFormat1())
94
# check no tree was created
95
self.assertRaises(errors.NoWorkingTree, branch.bzrdir.open_workingtree)
96
out, err = self.run_bzr('checkout')
97
# we should have a tree now
98
branch.bzrdir.open_workingtree()
100
out, err = self.run_bzr('diff')