1668.1.3
by Martin Pool
[patch] use the correct transaction when committing snapshot (Malone: #43959) |
1 |
# Copyright (C) 2005, 2006 by Canonical Ltd
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
1508.1.20
by Robert Collins
Create a checkout command. |
3 |
# This program is free software; you can redistribute it and/or modify
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
7 |
#
|
1508.1.20
by Robert Collins
Create a checkout command. |
8 |
# This program is distributed in the hope that it will be useful,
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
12 |
#
|
1508.1.20
by Robert Collins
Create a checkout command. |
13 |
# You should have received a copy of the GNU General Public License
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
"""Tests for the 'checkout' CLI command."""
|
|
18 |
||
19 |
from cStringIO import StringIO |
|
20 |
import os |
|
21 |
import re |
|
22 |
import shutil |
|
23 |
import sys |
|
24 |
||
25 |
import bzrlib.bzrdir as bzrdir |
|
1508.1.28
by Robert Collins
Test using bzr checkout to reconstitute working trees. |
26 |
import bzrlib.errors as errors |
1508.1.20
by Robert Collins
Create a checkout command. |
27 |
from bzrlib.tests.blackbox import ExternalBase |
28 |
||
29 |
||
30 |
class TestCheckout(ExternalBase): |
|
31 |
||
32 |
def setUp(self): |
|
33 |
super(TestCheckout, self).setUp() |
|
1508.1.21
by Robert Collins
Implement -r limit for checkout command. |
34 |
tree = bzrdir.BzrDir.create_standalone_workingtree('branch') |
35 |
tree.commit('1', rev_id='1', allow_pointless=True) |
|
36 |
self.build_tree(['branch/added_in_2']) |
|
37 |
tree.add('added_in_2') |
|
38 |
tree.commit('2', rev_id='2') |
|
1508.1.20
by Robert Collins
Create a checkout command. |
39 |
|
1587.1.14
by Robert Collins
Make bound branch creation happen via 'checkout' |
40 |
def test_checkout_makes_bound_branch(self): |
1508.1.20
by Robert Collins
Create a checkout command. |
41 |
self.runbzr('checkout branch checkout') |
42 |
# if we have a checkout, the branch base should be 'branch'
|
|
43 |
source = bzrdir.BzrDir.open('branch') |
|
44 |
result = bzrdir.BzrDir.open('checkout') |
|
45 |
self.assertEqual(source.open_branch().bzrdir.root_transport.base, |
|
1587.1.14
by Robert Collins
Make bound branch creation happen via 'checkout' |
46 |
result.open_branch().get_bound_location()) |
47 |
||
48 |
def test_checkout_light_makes_checkout(self): |
|
49 |
self.runbzr('checkout --lightweight branch checkout') |
|
50 |
# if we have a checkout, the branch base should be 'branch'
|
|
51 |
source = bzrdir.BzrDir.open('branch') |
|
52 |
result = bzrdir.BzrDir.open('checkout') |
|
53 |
self.assertEqual(source.open_branch().bzrdir.root_transport.base, |
|
1508.1.20
by Robert Collins
Create a checkout command. |
54 |
result.open_branch().bzrdir.root_transport.base) |
1508.1.21
by Robert Collins
Implement -r limit for checkout command. |
55 |
|
56 |
def test_checkout_dash_r(self): |
|
57 |
self.runbzr('checkout -r -2 branch checkout') |
|
58 |
# the working tree should now be at revision '1' with the content
|
|
59 |
# from 1.
|
|
60 |
result = bzrdir.BzrDir.open('checkout') |
|
61 |
self.assertEqual('1', result.open_workingtree().last_revision()) |
|
62 |
self.failIfExists('checkout/added_in_2') |
|
63 |
||
1587.1.14
by Robert Collins
Make bound branch creation happen via 'checkout' |
64 |
def test_checkout_light_dash_r(self): |
65 |
self.runbzr('checkout --lightweight -r -2 branch checkout') |
|
66 |
# the working tree should now be at revision '1' with the content
|
|
67 |
# from 1.
|
|
68 |
result = bzrdir.BzrDir.open('checkout') |
|
69 |
self.assertEqual('1', result.open_workingtree().last_revision()) |
|
70 |
self.failIfExists('checkout/added_in_2') |
|
71 |
||
1508.1.28
by Robert Collins
Test using bzr checkout to reconstitute working trees. |
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( |
|
78 |
'treeless-branch', |
|
79 |
force_new_tree=False, |
|
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() |
|
86 |
# with no diff
|
|
87 |
out, err = self.run_bzr('diff', 'treeless-branch') |
|
88 |
||
89 |
# now test with no parameters
|
|
90 |
branch = bzrdir.BzrDir.create_branch_convenience( |
|
91 |
'.', |
|
92 |
force_new_tree=False, |
|
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() |
|
99 |
# with no diff
|
|
100 |
out, err = self.run_bzr('diff') |