89
91
class TestCommit(TestCaseWithWorkingTree):
93
def test_autodelete_renamed(self):
94
tree_a = self.make_branch_and_tree('a')
95
self.build_tree(['a/dir/', 'a/dir/f1', 'a/dir/f2'])
96
tree_a.add(['dir', 'dir/f1', 'dir/f2'], ['dir-id', 'f1-id', 'f2-id'])
97
rev_id1 = tree_a.commit('init')
98
# Start off by renaming entries,
99
# but then actually auto delete the whole tree
100
# https://bugs.launchpad.net/bzr/+bug/114615
101
tree_a.rename_one('dir/f1', 'dir/a')
102
tree_a.rename_one('dir/f2', 'dir/z')
103
osutils.rmtree('a/dir')
104
tree_a.commit('autoremoved')
108
root_id = tree_a.inventory.root.file_id
109
paths = [(path, ie.file_id)
110
for path, ie in tree_a.iter_entries_by_dir()]
113
# The only paths left should be the root
114
self.assertEqual([('', root_id)], paths)
116
def test_no_autodelete_renamed_away(self):
117
tree_a = self.make_branch_and_tree('a')
118
self.build_tree(['a/dir/', 'a/dir/f1', 'a/dir/f2', 'a/dir2/'])
119
tree_a.add(['dir', 'dir/f1', 'dir/f2', 'dir2'],
120
['dir-id', 'f1-id', 'f2-id', 'dir2-id'])
121
rev_id1 = tree_a.commit('init')
122
# Rename one entry out of this directory
123
tree_a.rename_one('dir/f1', 'dir2/a')
124
osutils.rmtree('a/dir')
125
tree_a.commit('autoremoved')
129
root_id = tree_a.inventory.root.file_id
130
paths = [(path, ie.file_id)
131
for path, ie in tree_a.iter_entries_by_dir()]
134
# The only paths left should be the root
135
self.assertEqual([('', root_id), ('dir2', 'dir2-id'),
139
def test_no_autodelete_alternate_renamed(self):
140
# Test for bug #114615
141
tree_a = self.make_branch_and_tree('A')
142
self.build_tree(['A/a/', 'A/a/m', 'A/a/n'])
143
tree_a.add(['a', 'a/m', 'a/n'], ['a-id', 'm-id', 'n-id'])
144
tree_a.commit('init')
148
root_id = tree_a.inventory.root.file_id
152
tree_b = tree_a.bzrdir.sprout('B').open_workingtree()
153
self.build_tree(['B/xyz/'])
154
tree_b.add(['xyz'], ['xyz-id'])
155
tree_b.rename_one('a/m', 'xyz/m')
156
osutils.rmtree('B/a')
157
tree_b.commit('delete in B')
159
paths = [(path, ie.file_id)
160
for path, ie in tree_b.iter_entries_by_dir()]
161
self.assertEqual([('', root_id),
166
self.build_tree_contents([('A/a/n', 'new contents for n\n')])
167
tree_a.commit('change n in A')
169
# Merging from A should introduce conflicts because 'n' was modified
170
# and removed, so 'a' needs to be restored.
171
num_conflicts = tree_b.merge_from_branch(tree_a.branch)
172
self.assertEqual(3, num_conflicts)
173
paths = [(path, ie.file_id)
174
for path, ie in tree_b.iter_entries_by_dir()]
175
self.assertEqual([('', root_id),
178
('a/n.OTHER', 'n-id'),
181
osutils.rmtree('B/a')
184
tree_b.set_conflicts(conflicts.ConflictList())
185
except errors.UnsupportedOperation:
186
# On WT2, set_conflicts is unsupported, but the rmtree has the same
189
tree_b.commit('autoremove a, without touching xyz/m')
190
paths = [(path, ie.file_id)
191
for path, ie in tree_b.iter_entries_by_dir()]
192
self.assertEqual([('', root_id),
91
197
def test_commit_sets_last_revision(self):
92
198
tree = self.make_branch_and_tree('tree')
93
199
committed_id = tree.commit('foo', rev_id='foo')