21
from bzrlib import uncommit, workingtree
21
from bzrlib import uncommit
22
22
from bzrlib.bzrdir import BzrDirMetaFormat1
23
from bzrlib.errors import BzrError, BoundBranchOutOfDate
23
from bzrlib.errors import BoundBranchOutOfDate
24
24
from bzrlib.tests import TestCaseWithTransport
25
from bzrlib.tests.script import ScriptRunner
25
from bzrlib.tests.script import (
28
31
class TestUncommit(TestCaseWithTransport):
61
64
out, err = self.run_bzr('status')
62
65
self.assertEquals(out, 'modified:\n a\n')
67
def test_uncommit_interactive(self):
68
"""Uncommit seeks confirmation, and doesn't proceed without it."""
69
wt = self.create_simple_tree()
74
The above revision(s) will be removed.
75
2>Uncommit these revisions? ([y]es, [n]o): no
79
self.assertEqual(['a2'], wt.get_parent_ids())
64
81
def test_uncommit_no_history(self):
65
82
wt = self.make_branch_and_tree('tree')
66
83
out, err = self.run_bzr('uncommit --force', retcode=1)
102
119
t_a.commit('commit 3')
103
120
b = t_a.branch.create_checkout('b').branch
104
121
uncommit.uncommit(b)
105
self.assertEqual(len(b.revision_history()), 2)
106
self.assertEqual(len(t_a.branch.revision_history()), 2)
122
self.assertEqual(b.last_revision_info()[0], 2)
123
self.assertEqual(t_a.branch.last_revision_info()[0], 2)
107
124
# update A's tree to not have the uncommitted revision referenced.
109
126
t_a.commit('commit 3b')
263
280
tree.commit(u'\u1234 message')
264
281
out, err = self.run_bzr('uncommit --force tree', encoding='ascii')
265
282
self.assertContainsRe(out, r'\? message')
284
def test_uncommit_removes_tags(self):
285
tree = self.make_branch_and_tree('tree')
286
revid = tree.commit('message')
287
tree.branch.tags.set_tag("atag", revid)
288
out, err = self.run_bzr('uncommit --force tree')
289
self.assertEquals({}, tree.branch.tags.get_tag_dict())
291
def test_uncommit_keep_tags(self):
292
tree = self.make_branch_and_tree('tree')
293
revid = tree.commit('message')
294
tree.branch.tags.set_tag("atag", revid)
295
out, err = self.run_bzr('uncommit --keep-tags --force tree')
296
self.assertEquals({"atag": revid}, tree.branch.tags.get_tag_dict())
299
class TestSmartServerUncommit(TestCaseWithTransport):
301
def test_uncommit(self):
302
self.setup_smart_server_with_call_log()
303
t = self.make_branch_and_tree('from')
304
for count in range(2):
305
t.commit(message='commit %d' % count)
306
self.reset_smart_call_log()
307
out, err = self.run_bzr(['uncommit', '--force', self.get_url('from')])
308
# This figure represent the amount of work to perform this use case. It
309
# is entirely ok to reduce this number if a test fails due to rpc_count
310
# being too low. If rpc_count increases, more network roundtrips have
311
# become necessary for this use case. Please do not adjust this number
312
# upwards without agreement from bzr's network support maintainers.
313
self.assertLength(14, self.hpss_calls)