~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_remove_tree.py

  • Committer: Robert Collins
  • Date: 2007-07-04 08:08:13 UTC
  • mfrom: (2572 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2587.
  • Revision ID: robertc@robertcollins.net-20070704080813-wzebx0r88fvwj5rq
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2006 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
 
 
18
"""Black-box tests for bzr remove-tree."""
 
19
 
 
20
import os
 
21
 
 
22
from bzrlib.tests.blackbox import ExternalBase
 
23
 
 
24
 
 
25
class TestRemoveTree(ExternalBase):
 
26
 
 
27
    def setUp(self):
 
28
        super(TestRemoveTree, self).setUp()
 
29
        self.tree = self.make_branch_and_tree('branch1')
 
30
        self.build_tree(['branch1/foo'])
 
31
        self.tree.add('foo')
 
32
        self.tree.commit('1')
 
33
        self.failUnlessExists('branch1/foo')
 
34
 
 
35
    # Success modes
 
36
 
 
37
    def test_remove_tree_original_branch(self):
 
38
        os.chdir('branch1')
 
39
        self.run_bzr('remove-tree')
 
40
        self.failIfExists('foo')
 
41
    
 
42
    def test_remove_tree_original_branch_explicit(self):
 
43
        self.run_bzr('remove-tree', 'branch1')
 
44
        self.failIfExists('branch1/foo')
 
45
 
 
46
    def test_remove_tree_sprouted_branch(self):
 
47
        self.tree.bzrdir.sprout('branch2')
 
48
        self.failUnlessExists('branch2/foo')
 
49
        os.chdir('branch2')
 
50
        self.run_bzr('remove-tree')
 
51
        self.failIfExists('foo')
 
52
    
 
53
    def test_remove_tree_sprouted_branch_explicit(self):
 
54
        self.tree.bzrdir.sprout('branch2')
 
55
        self.failUnlessExists('branch2/foo')
 
56
        self.run_bzr('remove-tree', 'branch2')
 
57
        self.failIfExists('branch2/foo')
 
58
 
 
59
    def test_remove_tree_checkout(self):
 
60
        self.tree.branch.create_checkout('branch2', lightweight=False)
 
61
        self.failUnlessExists('branch2/foo')
 
62
        os.chdir('branch2')
 
63
        self.run_bzr('remove-tree')
 
64
        self.failIfExists('foo')
 
65
        os.chdir('..')
 
66
        self.failUnlessExists('branch1/foo')
 
67
    
 
68
    def test_remove_tree_checkout_explicit(self):
 
69
        self.tree.branch.create_checkout('branch2', lightweight=False)
 
70
        self.failUnlessExists('branch2/foo')
 
71
        self.run_bzr('remove-tree', 'branch2')
 
72
        self.failIfExists('branch2/foo')
 
73
        self.failUnlessExists('branch1/foo')
 
74
 
 
75
    # Failure modes
 
76
 
 
77
    def test_remove_tree_lightweight_checkout(self):
 
78
        self.tree.branch.create_checkout('branch2', lightweight=True)
 
79
        self.failUnlessExists('branch2/foo')
 
80
        os.chdir('branch2')
 
81
        output = self.run_bzr_error(
 
82
            ["You cannot remove the working tree from a lightweight checkout"],
 
83
            'remove-tree', retcode=3)
 
84
        self.failUnlessExists('foo')
 
85
        os.chdir('..')
 
86
        self.failUnlessExists('branch1/foo')
 
87
    
 
88
    def test_remove_tree_lightweight_checkout_explicit(self):
 
89
        self.tree.branch.create_checkout('branch2', lightweight=True)
 
90
        self.failUnlessExists('branch2/foo')
 
91
        output = self.run_bzr(
 
92
            ["Cannot remove working tree from lightweight checkout"],
 
93
            'remove-tree', 'branch2', retcode=3)
 
94
        self.failUnlessExists('branch2/foo')
 
95
        self.failUnlessExists('branch1/foo')
 
96
 
 
97
    def test_remove_tree_empty_dir(self):
 
98
        os.mkdir('branch2')
 
99
        os.chdir('branch2')
 
100
        output = self.run_bzr(["Not a branch"],
 
101
                              'remove-tree', retcode=3)
 
102
 
 
103
    def test_remove_tree_repeatedly(self):
 
104
        self.run_bzr('remove-tree', 'branch1')
 
105
        self.failIfExists('branch1/foo')
 
106
        output = self.run_bzr_error(["No working tree to remove"],
 
107
                                    'remove-tree', 'branch1', retcode=3)
 
108
 
 
109
    def test_remove_tree_remote_path(self):
 
110
        # TODO: I can't think of a way to implement this...
 
111
        pass