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
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
"""Tests for the Branch.create_checkout"""
|
|
18 |
||
19 |
from bzrlib import ( |
|
20 |
branch, |
|
21 |
)
|
|
22 |
from bzrlib.tests.branch_implementations.test_branch import TestCaseWithBranch |
|
23 |
||
24 |
||
25 |
class TestCreateCheckout(TestCaseWithBranch): |
|
26 |
||
27 |
def test_checkout_format(self): |
|
28 |
"""Make sure the new checkout uses the same branch format."""
|
|
29 |
a_branch = self.make_branch('branch') |
|
30 |
tree = a_branch.create_checkout('checkout') |
|
31 |
if self.branch_format in branch._legacy_formats: |
|
32 |
# Legacy formats create checkouts with the default format.
|
|
33 |
# Only newer formats create identical checkouts.
|
|
34 |
expected_format = branch.BranchFormat.get_default_format() |
|
35 |
else: |
|
36 |
expected_format = a_branch._format |
|
37 |
self.assertEqual(expected_format.get_format_string(), |
|
38 |
tree.branch._format.get_format_string()) |
|
39 |
||
40 |
def test_create_revision_checkout(self): |
|
41 |
"""Test that we can create a checkout from an earlier revision."""
|
|
42 |
tree1 = self.make_branch_and_tree('base') |
|
43 |
self.build_tree(['base/a']) |
|
44 |
tree1.add(['a'], ['a-id']) |
|
45 |
tree1.commit('first', rev_id='rev-1') |
|
46 |
self.build_tree(['base/b']) |
|
47 |
tree1.add(['b'], ['b-id']) |
|
48 |
tree1.commit('second', rev_id='rev-2') |
|
49 |
||
50 |
tree2 = tree1.branch.create_checkout('checkout', revision_id='rev-1') |
|
51 |
self.assertEqual('rev-1', tree2.last_revision()) |
|
52 |
self.failUnlessExists('checkout/a') |
|
53 |
self.failIfExists('checkout/b') |
|
54 |
||
55 |
def test_create_lightweight_checkout(self): |
|
56 |
"""We should be able to make a lightweight checkout."""
|
|
57 |
tree1 = self.make_branch_and_tree('base') |
|
58 |
tree2 = tree1.branch.create_checkout('checkout', lightweight=True) |
|
59 |
self.assertNotEqual(tree1.basedir, tree2.basedir) |
|
60 |
self.assertEqual(tree1.branch.base, tree2.branch.base) |
|
61 |
||
62 |
def test_create_checkout_exists(self): |
|
63 |
"""We shouldn't fail if the directory already exists."""
|
|
64 |
tree1 = self.make_branch_and_tree('base') |
|
65 |
self.build_tree('checkout') |
|
66 |
tree2 = tree1.branch.create_checkout('checkout', lightweight=True) |