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')
38
38
def test_remove_tree_original_branch(self):
39
self.run_bzr('remove-tree', working_dir='branch1')
40
self.assertPathDoesNotExist('branch1/foo')
40
self.run_bzr('remove-tree')
41
self.failIfExists('foo')
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')
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')
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')
57
self.run_bzr('remove-tree')
58
self.failIfExists('foo')
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')
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')
70
self.run_bzr('remove-tree')
71
self.failIfExists('foo')
73
self.failUnlessExists('branch1/foo')
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')
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')
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')
93
self.failUnlessExists('branch1/foo')
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')
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')
107
output = self.run_bzr_error(["Not a branch"],
108
'remove-tree', retcode=3)
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)
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')
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)
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')
153
160
def test_remove_tree_shelved_changes(self):
154
161
# https://bugs.launchpad.net/bzr/+bug/586639