91
91
a = BzrDirMetaFormat1().initialize('a')
92
92
a.create_repository()
94
t = a.create_workingtree()
98
b = t.bzrdir.sprout('b').open_branch()
94
t_a = a.create_workingtree()
95
t_a.commit('commit 1')
96
t_a.commit('commit 2')
97
t_a.commit('commit 3')
98
b = t_a.bzrdir.sprout('b').open_branch()
100
100
uncommit.uncommit(b)
101
t.set_last_revision(t.branch.last_revision())
102
101
self.assertEqual(len(b.revision_history()), 2)
103
self.assertEqual(len(t.branch.revision_history()), 2)
104
t.commit('commit 3b')
102
self.assertEqual(len(t_a.branch.revision_history()), 2)
103
# update A's tree to not have the uncomitted revision referenced.
105
t_a.commit('commit 3b')
105
106
self.assertRaises(BoundBranchOutOfDate, uncommit.uncommit, b)
107
108
uncommit.uncommit(b)
109
110
def test_uncommit_revision(self):
131
132
tree2.commit('unchanged', rev_id='b3')
132
133
tree2.commit('unchanged', rev_id='b4')
134
wt.branch.fetch(tree2.branch)
135
wt.set_pending_merges(['b4'])
135
self.merge(tree2.branch, wt)
136
136
wt.commit('merge b4', rev_id='a3')
138
self.assertEqual('a3', wt.last_revision())
139
self.assertEqual([], wt.pending_merges())
138
self.assertEqual(['a3'], wt.get_parent_ids())
142
141
out, err = self.run_bzr('uncommit', '--force')
144
self.assertEqual('a2', wt.last_revision())
145
self.assertEqual(['b4'], wt.pending_merges())
143
self.assertEqual(['a2', 'b4'], wt.get_parent_ids())
147
145
def test_uncommit_pending_merge(self):
148
146
wt = self.create_simple_tree()
163
161
tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
165
163
tree2.commit('unchanged', rev_id='b3')
166
wt.branch.fetch(tree2.branch)
167
wt.set_pending_merges(['b3'])
165
self.merge(tree2.branch, wt)
168
166
wt.commit('merge b3', rev_id='a3')
170
168
tree2.commit('unchanged', rev_id='b4')
171
wt.branch.fetch(tree2.branch)
172
wt.set_pending_merges(['b4'])
170
self.merge(tree2.branch, wt)
173
171
wt.commit('merge b4', rev_id='a4')
175
self.assertEqual('a4', wt.last_revision())
176
self.assertEqual([], wt.pending_merges())
173
self.assertEqual(['a4'], wt.get_parent_ids())
179
176
out, err = self.run_bzr('uncommit', '--force', '-r', '2')
181
self.assertEqual('a2', wt.last_revision())
182
self.assertEqual(['b3', 'b4'], wt.pending_merges())
178
self.assertEqual(['a2', 'b3', 'b4'], wt.get_parent_ids())
184
180
def test_uncommit_merge_plus_pending(self):
185
181
wt = self.create_simple_tree()
214
210
tree2.commit('unchanged', rev_id='b3')
215
211
tree3.commit('unchanged', rev_id='c3')
216
wt.branch.fetch(tree2.branch)
217
wt.branch.fetch(tree3.branch)
218
wt.set_pending_merges(['b3', 'c3'])
213
self.merge(tree2.branch, wt)
214
self.merge(tree3.branch, wt)
219
215
wt.commit('merge b3, c3', rev_id='a3')
221
217
tree2.commit('unchanged', rev_id='b4')
222
218
tree3.commit('unchanged', rev_id='c4')
223
wt.branch.fetch(tree2.branch)
224
wt.branch.fetch(tree3.branch)
225
wt.set_pending_merges(['c4', 'b4'])
220
self.merge(tree3.branch, wt)
221
self.merge(tree2.branch, wt)
226
222
wt.commit('merge b4, c4', rev_id='a4')
228
self.assertEqual('a4', wt.last_revision())
229
self.assertEqual([], wt.pending_merges())
224
self.assertEqual(['a4'], wt.get_parent_ids())
232
227
out, err = self.run_bzr('uncommit', '--force', '-r', '2')
234
self.assertEqual('a2', wt.last_revision())
235
self.assertEqual(['b3', 'c3', 'c4', 'b4'], wt.pending_merges())
229
self.assertEqual(['a2', 'b3', 'c3', 'c4', 'b4'], wt.get_parent_ids())