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