99
102
self.assertTrue(tree.has_filename('d'))
106
def test_unversion_renamed(self):
107
tree = self.make_branch_and_tree('a')
108
self.build_tree(['a/dir/', 'a/dir/f1', 'a/dir/f2', 'a/dir/f3',
110
tree.add(['dir', 'dir/f1', 'dir/f2', 'dir/f3', 'dir2'],
111
['dir-id', 'f1-id', 'f2-id', 'f3-id', 'dir2-id'])
112
rev_id1 = tree.commit('init')
113
# Start off by renaming entries, and then unversion a bunch of entries
114
# https://bugs.launchpad.net/bzr/+bug/114615
115
tree.rename_one('dir/f1', 'dir/a')
116
tree.rename_one('dir/f2', 'dir/z')
117
tree.move(['dir/f3'], 'dir2')
121
root_id = tree.inventory.root.file_id
122
paths = [(path, ie.file_id)
123
for path, ie in tree.iter_entries_by_dir()]
126
self.assertEqual([('', root_id),
131
('dir2/f3', 'f3-id'),
134
tree.unversion(set(['dir-id']))
135
paths = [(path, ie.file_id)
136
for path, ie in tree.iter_entries_by_dir()]
138
self.assertEqual([('', root_id),
140
('dir2/f3', 'f3-id'),
143
def test_unversion_after_conflicted_merge(self):
144
# Test for bug #114615
145
tree_a = self.make_branch_and_tree('A')
146
self.build_tree(['A/a/', 'A/a/m', 'A/a/n'])
147
tree_a.add(['a', 'a/m', 'a/n'], ['a-id', 'm-id', 'n-id'])
148
tree_a.commit('init')
152
root_id = tree_a.inventory.root.file_id
156
tree_b = tree_a.bzrdir.sprout('B').open_workingtree()
157
self.build_tree(['B/xyz/'])
158
tree_b.add(['xyz'], ['xyz-id'])
159
tree_b.rename_one('a/m', 'xyz/m')
160
tree_b.unversion(['a-id'])
161
tree_b.commit('delete in B')
163
paths = [(path, ie.file_id)
164
for path, ie in tree_b.iter_entries_by_dir()]
165
self.assertEqual([('', root_id),
170
self.build_tree_contents([('A/a/n', 'new contents for n\n')])
171
tree_a.commit('change n in A')
173
# Merging from A should introduce conflicts because 'n' was modified
174
# and removed, so 'a' needs to be restored. We also have a conflict
175
# because 'a' is still an existing directory
176
num_conflicts = tree_b.merge_from_branch(tree_a.branch)
177
self.assertEqual(4, num_conflicts)
178
paths = [(path, ie.file_id)
179
for path, ie in tree_b.iter_entries_by_dir()]
180
self.assertEqual([('', root_id),
183
('a/n.OTHER', 'n-id'),
186
tree_b.unversion(['a-id'])
187
paths = [(path, ie.file_id)
188
for path, ie in tree_b.iter_entries_by_dir()]
189
self.assertEqual([('', root_id),