60
60
out, err = self.run_bzr('status')
61
61
self.assertEquals(out, 'modified:\n a\n')
63
def test_uncommit_no_history(self):
64
wt = self.make_branch_and_tree('tree')
65
out, err = self.run_bzr('uncommit --force', retcode=1)
66
self.assertEqual('', err)
67
self.assertEqual('No revisions to uncommit.\n', out)
63
69
def test_uncommit_checkout(self):
64
70
wt = self.create_simple_tree()
65
71
checkout_tree = wt.branch.create_checkout('checkout')
104
110
b.pull(t_a.branch)
105
111
uncommit.uncommit(b)
113
def test_uncommit_bound_local(self):
114
t_a = self.make_branch_and_tree('a')
115
rev_id1 = t_a.commit('commit 1')
116
rev_id2 = t_a.commit('commit 2')
117
rev_id3 = t_a.commit('commit 3')
118
b = t_a.branch.create_checkout('b').branch
120
out, err = self.run_bzr(['uncommit', '--local', 'b', '--force'])
121
self.assertEqual(rev_id3, t_a.last_revision())
122
self.assertEqual((3, rev_id3), t_a.branch.last_revision_info())
123
self.assertEqual((2, rev_id2), b.last_revision_info())
107
125
def test_uncommit_revision(self):
108
126
wt = self.create_simple_tree()
155
173
wt = self.create_simple_tree()
157
175
tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
159
176
tree2.commit('unchanged', rev_id='b3')
178
tree3 = wt.bzrdir.sprout('tree3').open_workingtree()
179
tree3.commit('unchanged', rev_id='c3')
161
181
wt.merge_from_branch(tree2.branch)
162
182
wt.commit('merge b3', rev_id='a3')
164
tree2.commit('unchanged', rev_id='b4')
166
wt.merge_from_branch(tree2.branch)
167
wt.commit('merge b4', rev_id='a4')
184
wt.merge_from_branch(tree3.branch)
185
wt.commit('merge c3', rev_id='a4')
169
187
self.assertEqual(['a4'], wt.get_parent_ids())
172
190
out, err = self.run_bzr('uncommit --force -r 2')
174
self.assertEqual(['a2', 'b3', 'b4'], wt.get_parent_ids())
192
self.assertEqual(['a2', 'b3', 'c3'], wt.get_parent_ids())
176
194
def test_uncommit_merge_plus_pending(self):
177
195
wt = self.create_simple_tree()
179
197
tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
181
198
tree2.commit('unchanged', rev_id='b3')
199
tree3 = wt.bzrdir.sprout('tree3').open_workingtree()
200
tree3.commit('unchanged', rev_id='c3')
182
202
wt.branch.fetch(tree2.branch)
183
203
wt.set_pending_merges(['b3'])
184
204
wt.commit('merge b3', rev_id='a3')
186
tree2.commit('unchanged', rev_id='b4')
187
wt.branch.fetch(tree2.branch)
188
wt.set_pending_merges(['b4'])
190
self.assertEqual(['a3', 'b4'], wt.get_parent_ids())
207
wt.merge_from_branch(tree3.branch)
209
self.assertEqual(['a3', 'c3'], wt.get_parent_ids())
193
212
out, err = self.run_bzr('uncommit --force -r 2')
195
self.assertEqual(['a2', 'b3', 'b4'], wt.get_parent_ids())
214
self.assertEqual(['a2', 'b3', 'c3'], wt.get_parent_ids())
216
def test_uncommit_shows_log_with_revision_id(self):
217
wt = self.create_simple_tree()
219
out, err = self.run_bzr('uncommit --force', working_dir='tree')
220
self.assertContainsRe(out, r'second commit')
221
self.assertContainsRe(err, r'You can restore the old tip by running')
222
self.assertContainsRe(err, r'bzr pull . -r revid:a2')
197
224
def test_uncommit_octopus_merge(self):
198
225
# Check that uncommit keeps the pending merges in the same order
226
# though it will also filter out ones in the ancestry
199
227
wt = self.create_simple_tree()
201
229
tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
221
249
out, err = self.run_bzr('uncommit --force -r 2')
223
self.assertEqual(['a2', 'b3', 'c3', 'c4', 'b4'], wt.get_parent_ids())
251
self.assertEqual(['a2', 'c4', 'b4'], wt.get_parent_ids())
253
def test_uncommit_nonascii(self):
254
tree = self.make_branch_and_tree('tree')
255
tree.commit(u'\u1234 message')
256
out, err = self.run_bzr('uncommit --force tree', encoding='ascii')
257
self.assertContainsRe(out, r'\? message')