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. |
1 |
# Copyright (C) 2007 Canonical Ltd
|
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 |
)
|
|
2018.5.122
by Robert Collins
More Branch implementation test passing foo. |
22 |
from bzrlib.remote import RemoteBranch |
4523.1.1
by Martin Pool
Rename tests.branch_implementations to per_branch |
23 |
from bzrlib.tests.per_branch.test_branch import 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. |
24 |
|
25 |
||
26 |
class TestCreateCheckout(TestCaseWithBranch): |
|
27 |
||
28 |
def test_checkout_format(self): |
|
2975.1.1
by Robert Collins
Minor fixes for foreign format friendliness. |
29 |
"""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. |
30 |
a_branch = self.make_branch('branch') |
31 |
tree = a_branch.create_checkout('checkout') |
|
2975.1.1
by Robert Collins
Minor fixes for foreign format friendliness. |
32 |
# All branches can define the format they want checkouts made in.
|
33 |
# This checks it is honoured.
|
|
34 |
expected_format = a_branch._get_checkout_format().get_branch_format() |
|
2018.5.122
by Robert Collins
More Branch implementation test passing foo. |
35 |
self.assertEqual(expected_format.__class__, |
36 |
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. |
37 |
|
38 |
def test_create_revision_checkout(self): |
|
39 |
"""Test that we can create a checkout from an earlier revision."""
|
|
40 |
tree1 = self.make_branch_and_tree('base') |
|
41 |
self.build_tree(['base/a']) |
|
42 |
tree1.add(['a'], ['a-id']) |
|
43 |
tree1.commit('first', rev_id='rev-1') |
|
44 |
self.build_tree(['base/b']) |
|
45 |
tree1.add(['b'], ['b-id']) |
|
46 |
tree1.commit('second', rev_id='rev-2') |
|
47 |
||
48 |
tree2 = tree1.branch.create_checkout('checkout', revision_id='rev-1') |
|
49 |
self.assertEqual('rev-1', tree2.last_revision()) |
|
50 |
self.failUnlessExists('checkout/a') |
|
51 |
self.failIfExists('checkout/b') |
|
52 |
||
53 |
def test_create_lightweight_checkout(self): |
|
54 |
"""We should be able to make a lightweight checkout."""
|
|
55 |
tree1 = self.make_branch_and_tree('base') |
|
56 |
tree2 = tree1.branch.create_checkout('checkout', lightweight=True) |
|
57 |
self.assertNotEqual(tree1.basedir, tree2.basedir) |
|
58 |
self.assertEqual(tree1.branch.base, tree2.branch.base) |
|
59 |
||
60 |
def test_create_checkout_exists(self): |
|
61 |
"""We shouldn't fail if the directory already exists."""
|
|
62 |
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 |
63 |
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. |
64 |
tree2 = tree1.branch.create_checkout('checkout', lightweight=True) |