4988.10.5
by John Arbash Meinel
Merge bzr.dev 5021 to resolve NEWS |
1 |
# Copyright (C) 2007, 2009, 2010 Canonical Ltd
|
2370.3.1
by John Arbash Meinel
(John Arbash Meinel) Fix bug #93854, make 'bzr checkout' create branches in the same format as the source. |
2 |
#
|
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.
|
|
7 |
#
|
|
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.
|
|
12 |
#
|
|
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
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2370.3.1
by John Arbash Meinel
(John Arbash Meinel) Fix bug #93854, make 'bzr checkout' create branches in the same format as the source. |
16 |
|
17 |
"""Tests for the Branch.create_checkout"""
|
|
18 |
||
19 |
from bzrlib import ( |
|
20 |
branch, |
|
21 |
)
|
|
5010.2.13
by Vincent Ladeuil
Fix imports in per_branch/test_create_checkout.py. |
22 |
from bzrlib.tests import per_branch |
23 |
||
24 |
||
25 |
class TestCreateCheckout(per_branch.TestCaseWithBranch): |
|
2370.3.1
by John Arbash Meinel
(John Arbash Meinel) Fix bug #93854, make 'bzr checkout' create branches in the same format as the source. |
26 |
|
27 |
def test_checkout_format(self): |
|
2975.1.1
by Robert Collins
Minor fixes for foreign format friendliness. |
28 |
"""Make sure the new checkout uses the desired branch format."""
|
2370.3.1
by John Arbash Meinel
(John Arbash Meinel) Fix bug #93854, make 'bzr checkout' create branches in the same format as the source. |
29 |
a_branch = self.make_branch('branch') |
30 |
tree = a_branch.create_checkout('checkout') |
|
2975.1.1
by Robert Collins
Minor fixes for foreign format friendliness. |
31 |
# All branches can define the format they want checkouts made in.
|
32 |
# This checks it is honoured.
|
|
33 |
expected_format = a_branch._get_checkout_format().get_branch_format() |
|
2018.5.122
by Robert Collins
More Branch implementation test passing foo. |
34 |
self.assertEqual(expected_format.__class__, |
35 |
tree.branch._format.__class__) |
|
2370.3.1
by John Arbash Meinel
(John Arbash Meinel) Fix bug #93854, make 'bzr checkout' create branches in the same format as the source. |
36 |
|
37 |
def test_create_revision_checkout(self): |
|
38 |
"""Test that we can create a checkout from an earlier revision."""
|
|
39 |
tree1 = self.make_branch_and_tree('base') |
|
40 |
self.build_tree(['base/a']) |
|
41 |
tree1.add(['a'], ['a-id']) |
|
42 |
tree1.commit('first', rev_id='rev-1') |
|
43 |
self.build_tree(['base/b']) |
|
44 |
tree1.add(['b'], ['b-id']) |
|
45 |
tree1.commit('second', rev_id='rev-2') |
|
46 |
||
47 |
tree2 = tree1.branch.create_checkout('checkout', revision_id='rev-1') |
|
48 |
self.assertEqual('rev-1', tree2.last_revision()) |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
49 |
self.assertPathExists('checkout/a') |
50 |
self.assertPathDoesNotExist('checkout/b') |
|
2370.3.1
by John Arbash Meinel
(John Arbash Meinel) Fix bug #93854, make 'bzr checkout' create branches in the same format as the source. |
51 |
|
52 |
def test_create_lightweight_checkout(self): |
|
53 |
"""We should be able to make a lightweight checkout."""
|
|
54 |
tree1 = self.make_branch_and_tree('base') |
|
55 |
tree2 = tree1.branch.create_checkout('checkout', lightweight=True) |
|
56 |
self.assertNotEqual(tree1.basedir, tree2.basedir) |
|
57 |
self.assertEqual(tree1.branch.base, tree2.branch.base) |
|
58 |
||
59 |
def test_create_checkout_exists(self): |
|
60 |
"""We shouldn't fail if the directory already exists."""
|
|
61 |
tree1 = self.make_branch_and_tree('base') |
|
3044.1.1
by Martin Pool
Fix up calls to TestCase.build_tree passing a string rather than a list |
62 |
self.build_tree(['checkout/']) |
2370.3.1
by John Arbash Meinel
(John Arbash Meinel) Fix bug #93854, make 'bzr checkout' create branches in the same format as the source. |
63 |
tree2 = tree1.branch.create_checkout('checkout', lightweight=True) |