~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Andrew Bennetts
  • Date: 2010-10-08 08:15:14 UTC
  • mto: This revision was merged to the branch mainline in revision 5498.
  • Revision ID: andrew.bennetts@canonical.com-20101008081514-dviqzrdfwyzsqbz2
Split NEWS into per-release doc/en/release-notes/bzr-*.txt

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2012 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
31
31
        self.build_tree(['branch1/foo'])
32
32
        self.tree.add('foo')
33
33
        self.tree.commit('1')
34
 
        self.assertPathExists('branch1/foo')
 
34
        self.failUnlessExists('branch1/foo')
35
35
 
36
36
    # Success modes
37
37
 
38
38
    def test_remove_tree_original_branch(self):
39
 
        self.run_bzr('remove-tree', working_dir='branch1')
40
 
        self.assertPathDoesNotExist('branch1/foo')
 
39
        os.chdir('branch1')
 
40
        self.run_bzr('remove-tree')
 
41
        self.failIfExists('foo')
41
42
 
42
43
    def test_remove_tree_original_branch_explicit(self):
43
44
        self.run_bzr('remove-tree branch1')
44
 
        self.assertPathDoesNotExist('branch1/foo')
 
45
        self.failIfExists('branch1/foo')
45
46
 
46
47
    def test_remove_tree_multiple_branch_explicit(self):
47
48
        self.tree.bzrdir.sprout('branch2')
48
49
        self.run_bzr('remove-tree branch1 branch2')
49
 
        self.assertPathDoesNotExist('branch1/foo')
50
 
        self.assertPathDoesNotExist('branch2/foo')
 
50
        self.failIfExists('branch1/foo')
 
51
        self.failIfExists('branch2/foo')
51
52
 
52
53
    def test_remove_tree_sprouted_branch(self):
53
54
        self.tree.bzrdir.sprout('branch2')
54
 
        self.assertPathExists('branch2/foo')
55
 
        self.run_bzr('remove-tree', working_dir='branch2')
56
 
        self.assertPathDoesNotExist('branch2/foo')
 
55
        self.failUnlessExists('branch2/foo')
 
56
        os.chdir('branch2')
 
57
        self.run_bzr('remove-tree')
 
58
        self.failIfExists('foo')
57
59
 
58
60
    def test_remove_tree_sprouted_branch_explicit(self):
59
61
        self.tree.bzrdir.sprout('branch2')
60
 
        self.assertPathExists('branch2/foo')
 
62
        self.failUnlessExists('branch2/foo')
61
63
        self.run_bzr('remove-tree branch2')
62
 
        self.assertPathDoesNotExist('branch2/foo')
 
64
        self.failIfExists('branch2/foo')
63
65
 
64
66
    def test_remove_tree_checkout(self):
65
67
        self.tree.branch.create_checkout('branch2', lightweight=False)
66
 
        self.assertPathExists('branch2/foo')
67
 
        self.run_bzr('remove-tree', working_dir='branch2')
68
 
        self.assertPathDoesNotExist('branch2/foo')
69
 
        self.assertPathExists('branch1/foo')
 
68
        self.failUnlessExists('branch2/foo')
 
69
        os.chdir('branch2')
 
70
        self.run_bzr('remove-tree')
 
71
        self.failIfExists('foo')
 
72
        os.chdir('..')
 
73
        self.failUnlessExists('branch1/foo')
70
74
 
71
75
    def test_remove_tree_checkout_explicit(self):
72
76
        self.tree.branch.create_checkout('branch2', lightweight=False)
73
 
        self.assertPathExists('branch2/foo')
 
77
        self.failUnlessExists('branch2/foo')
74
78
        self.run_bzr('remove-tree branch2')
75
 
        self.assertPathDoesNotExist('branch2/foo')
76
 
        self.assertPathExists('branch1/foo')
 
79
        self.failIfExists('branch2/foo')
 
80
        self.failUnlessExists('branch1/foo')
77
81
 
78
82
    # Failure modes
79
83
 
80
84
    def test_remove_tree_lightweight_checkout(self):
81
85
        self.tree.branch.create_checkout('branch2', lightweight=True)
82
 
        self.assertPathExists('branch2/foo')
 
86
        self.failUnlessExists('branch2/foo')
 
87
        os.chdir('branch2')
83
88
        output = self.run_bzr_error(
84
89
            ["You cannot remove the working tree from a lightweight checkout"],
85
 
            'remove-tree', retcode=3, working_dir='branch2')
86
 
        self.assertPathExists('branch2/foo')
87
 
        self.assertPathExists('branch1/foo')
 
90
            'remove-tree', retcode=3)
 
91
        self.failUnlessExists('foo')
 
92
        os.chdir('..')
 
93
        self.failUnlessExists('branch1/foo')
88
94
 
89
95
    def test_remove_tree_lightweight_checkout_explicit(self):
90
96
        self.tree.branch.create_checkout('branch2', lightweight=True)
91
 
        self.assertPathExists('branch2/foo')
 
97
        self.failUnlessExists('branch2/foo')
92
98
        output = self.run_bzr_error(
93
99
            ["You cannot remove the working tree from a lightweight checkout"],
94
100
            'remove-tree branch2', retcode=3)
95
 
        self.assertPathExists('branch2/foo')
96
 
        self.assertPathExists('branch1/foo')
 
101
        self.failUnlessExists('branch2/foo')
 
102
        self.failUnlessExists('branch1/foo')
97
103
 
98
104
    def test_remove_tree_empty_dir(self):
99
105
        os.mkdir('branch2')
100
 
        output = self.run_bzr_error(
101
 
            ["Not a branch"], 'remove-tree', retcode=3, working_dir='branch2')
 
106
        os.chdir('branch2')
 
107
        output = self.run_bzr_error(["Not a branch"],
 
108
                                    'remove-tree', retcode=3)
102
109
 
103
110
    def test_remove_tree_repeatedly(self):
104
111
        self.run_bzr('remove-tree branch1')
105
 
        self.assertPathDoesNotExist('branch1/foo')
 
112
        self.failIfExists('branch1/foo')
106
113
        output = self.run_bzr_error(["No working tree to remove"],
107
114
                                    'remove-tree branch1', retcode=3)
108
115
 
120
127
        self.build_tree(['branch1/bar'])
121
128
        self.tree.add('bar')
122
129
        self.run_bzr('remove-tree branch1 --force')
123
 
        self.assertPathDoesNotExist('branch1/foo')
124
 
        self.assertPathExists('branch1/bar')
 
130
        self.failIfExists('branch1/foo')
 
131
        self.failUnlessExists('branch1/bar')
125
132
 
126
133
    def test_remove_tree_pending_merges(self):
127
134
        self.run_bzr(['branch', 'branch1', 'branch2'])
128
135
        self.build_tree(['branch1/bar'])
129
136
        self.tree.add('bar')
130
137
        self.tree.commit('2')
131
 
        self.assertPathExists('branch1/bar')
 
138
        self.failUnlessExists('branch1/bar')
132
139
        self.run_bzr(['merge', '../branch1'], working_dir='branch2')
133
 
        self.assertPathExists('branch2/bar')
 
140
        self.failUnlessExists('branch2/bar')
134
141
        self.run_bzr(['revert', '.'], working_dir='branch2')
135
 
        self.assertPathDoesNotExist('branch2/bar')
 
142
        self.failIfExists('branch2/bar')
136
143
        output = self.run_bzr_error(["Working tree .* has uncommitted changes"],
137
144
                                    'remove-tree branch2', retcode=3)
138
145
 
141
148
        self.build_tree(['branch1/bar'])
142
149
        self.tree.add('bar')
143
150
        self.tree.commit('2')
144
 
        self.assertPathExists('branch1/bar')
 
151
        self.failUnlessExists('branch1/bar')
145
152
        self.run_bzr(['merge', '../branch1'], working_dir='branch2')
146
 
        self.assertPathExists('branch2/bar')
 
153
        self.failUnlessExists('branch2/bar')
147
154
        self.run_bzr(['revert', '.'], working_dir='branch2')
148
 
        self.assertPathDoesNotExist('branch2/bar')
 
155
        self.failIfExists('branch2/bar')
149
156
        self.run_bzr('remove-tree branch2 --force')
150
 
        self.assertPathDoesNotExist('branch2/foo')
151
 
        self.assertPathDoesNotExist('branch2/bar')
 
157
        self.failIfExists('branch2/foo')
 
158
        self.failIfExists('branch2/bar')
152
159
 
153
160
    def test_remove_tree_shelved_changes(self):
154
161
        # https://bugs.launchpad.net/bzr/+bug/586639