/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_reconfigure.py

  • Committer: Aaron Bentley
  • Date: 2007-09-09 07:13:15 UTC
  • mto: This revision was merged to the branch mainline in revision 2826.
  • Revision ID: aaron.bentley@utoronto.ca-20070909071315-9rdv0zzhp3ksc238
Implement destroy_branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
from bzrlib import (
 
18
    branch as _mod_branch,
 
19
    errors,
 
20
    reconfigure,
 
21
    tests,
 
22
    workingtree,
 
23
    )
 
24
 
 
25
 
 
26
class TestReconfigure(tests.TestCaseWithTransport):
 
27
 
 
28
    def test_tree_to_branch(self):
 
29
        tree = self.make_branch_and_tree('tree')
 
30
        reconfiguration = reconfigure.Reconfigure.to_branch(tree.bzrdir)
 
31
        reconfiguration.apply()
 
32
        self.assertRaises(errors.NoWorkingTree, workingtree.WorkingTree.open,
 
33
                          'tree')
 
34
 
 
35
    def test_modified_tree_to_branch(self):
 
36
        tree = self.make_branch_and_tree('tree')
 
37
        self.build_tree(['tree/file'])
 
38
        tree.add('file')
 
39
        reconfiguration = reconfigure.Reconfigure.to_branch(tree.bzrdir)
 
40
        self.assertRaises(errors.UncommittedChanges, reconfiguration.apply)
 
41
        reconfiguration.apply(force=True)
 
42
        self.assertRaises(errors.NoWorkingTree, workingtree.WorkingTree.open,
 
43
                          'tree')
 
44
 
 
45
    def test_branch_to_branch(self):
 
46
        branch = self.make_branch('branch')
 
47
        self.assertRaises(errors.AlreadyBranch,
 
48
                          reconfigure.Reconfigure.to_branch, branch.bzrdir)
 
49
 
 
50
    def test_repo_to_branch(self):
 
51
        repo = self.make_repository('repo')
 
52
        self.assertRaises(errors.ReconfigurationNotSupported,
 
53
                          reconfigure.Reconfigure.to_branch, repo.bzrdir)
 
54
 
 
55
    def test_checkout_to_branch(self):
 
56
        branch = self.make_branch('branch')
 
57
        checkout = branch.create_checkout('checkout')
 
58
        reconfiguration = reconfigure.Reconfigure.to_branch(checkout.bzrdir)
 
59
        reconfiguration.apply()
 
60
        self.assertIs(None, checkout.branch.get_bound_location())
 
61
 
 
62
    def test_lightweight_checkout_to_branch(self):
 
63
        branch = self.make_branch('branch')
 
64
        checkout = branch.create_checkout('checkout', lightweight=True)
 
65
        self.assertRaises(errors.ReconfigurationNotSupported,
 
66
                          reconfigure.Reconfigure.to_branch, checkout.bzrdir)
 
67
 
 
68
    def test_branch_to_tree(self):
 
69
        branch = self.make_branch('branch')
 
70
        reconfiguration=reconfigure.Reconfigure.to_tree(branch.bzrdir)
 
71
        reconfiguration.apply()
 
72
        branch.bzrdir.open_workingtree()
 
73
 
 
74
    def test_tree_to_tree(self):
 
75
        tree = self.make_branch_and_tree('tree')
 
76
        self.assertRaises(errors.AlreadyTree, reconfigure.Reconfigure.to_tree,
 
77
                          tree.bzrdir)
 
78
 
 
79
    def test_select_bind_location(self):
 
80
        branch = self.make_branch('branch')
 
81
        reconfiguration = reconfigure.Reconfigure(branch.bzrdir)
 
82
        self.assertRaises(errors.NoBindLocation,
 
83
                          reconfiguration._select_bind_location)
 
84
        branch.set_parent('http://parent')
 
85
        self.assertEqual('http://parent',
 
86
                         reconfiguration._select_bind_location())
 
87
        branch.set_push_location('sftp://push')
 
88
        self.assertEqual('sftp://push',
 
89
                         reconfiguration._select_bind_location())
 
90
        branch.set_bound_location('bzr:old-bound')
 
91
        branch.set_bound_location(None)
 
92
        self.assertEqual('bzr:old-bound',
 
93
                         reconfiguration._select_bind_location())
 
94
 
 
95
    def test_tree_to_checkout(self):
 
96
        # A tree with no related branches and no supplied bind location cannot
 
97
        # become a checkout
 
98
        parent = self.make_branch('parent')
 
99
 
 
100
        tree = self.make_branch_and_tree('tree')
 
101
        reconfiguration = reconfigure.Reconfigure.to_checkout(tree.bzrdir)
 
102
        self.assertRaises(errors.NoBindLocation, reconfiguration.apply)
 
103
        # setting a parent allows it to become a checkout
 
104
        tree.branch.set_parent(parent.base)
 
105
        reconfiguration.apply()
 
106
        # supplying a location allows it to become a checkout
 
107
        tree2 = self.make_branch_and_tree('tree2')
 
108
        reconfiguration = reconfigure.Reconfigure.to_checkout(tree2.bzrdir,
 
109
                                                              parent.base)
 
110
        reconfiguration.apply()
 
111
 
 
112
    def test_checkout_to_checkout(self):
 
113
        parent = self.make_branch('parent')
 
114
        checkout = parent.create_checkout('checkout')
 
115
        self.assertRaises(errors.AlreadyCheckout,
 
116
                          reconfigure.Reconfigure.to_checkout, checkout.bzrdir)