~bzr-pqm/bzr/bzr.dev

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
5010.2.13 by Vincent Ladeuil
Fix imports in per_branch/test_create_checkout.py.
19
from bzrlib.tests import per_branch
20
21
22
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.
23
6127.1.9 by Jelmer Vernooij
Add lightweight option to _get_checkout_format().
24
    def test_checkout_format_lightweight(self):
25
        """Make sure the new light checkout uses the desired branch format."""
26
        a_branch = self.make_branch('branch')
27
        tree = a_branch.create_checkout('checkout', lightweight=True)
28
        # All branches can define the format they want checkouts made in.
29
        # This checks it is honoured.
30
        expected_format = a_branch._get_checkout_format(lightweight=True)
6305.5.16 by Jelmer Vernooij
Some test fixes.
31
        self.assertEqual(expected_format.get_branch_format().network_name(),
32
                         tree.branch._format.network_name())
6127.1.9 by Jelmer Vernooij
Add lightweight option to _get_checkout_format().
33
34
    def test_checkout_format_heavyweight(self):
35
        """Make sure the new heavy checkout uses the desired branch format."""
36
        a_branch = self.make_branch('branch')
37
        tree = a_branch.create_checkout('checkout', lightweight=False)
38
        # All branches can define the format they want checkouts made in.
39
        # This checks it is honoured.
40
        expected_format = a_branch._get_checkout_format(lightweight=False)
6282.6.40 by Jelmer Vernooij
Fix tests.
41
        self.assertEqual(expected_format.get_branch_format().network_name(),
42
                         tree.branch._format.network_name())
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.
43
44
    def test_create_revision_checkout(self):
45
        """Test that we can create a checkout from an earlier revision."""
46
        tree1 = self.make_branch_and_tree('base')
47
        self.build_tree(['base/a'])
48
        tree1.add(['a'], ['a-id'])
49
        tree1.commit('first', rev_id='rev-1')
50
        self.build_tree(['base/b'])
51
        tree1.add(['b'], ['b-id'])
52
        tree1.commit('second', rev_id='rev-2')
53
54
        tree2 = tree1.branch.create_checkout('checkout', revision_id='rev-1')
55
        self.assertEqual('rev-1', tree2.last_revision())
5784.1.3 by Martin Pool
Switch away from using failUnlessExists and failIfExists
56
        self.assertPathExists('checkout/a')
57
        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.
58
59
    def test_create_lightweight_checkout(self):
60
        """We should be able to make a lightweight checkout."""
61
        tree1 = self.make_branch_and_tree('base')
62
        tree2 = tree1.branch.create_checkout('checkout', lightweight=True)
63
        self.assertNotEqual(tree1.basedir, tree2.basedir)
64
        self.assertEqual(tree1.branch.base, tree2.branch.base)
65
66
    def test_create_checkout_exists(self):
67
        """We shouldn't fail if the directory already exists."""
68
        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
69
        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.
70
        tree2 = tree1.branch.create_checkout('checkout', lightweight=True)