63
63
LINES_AY = 'a\nb\nc\nd\ne\nf\ng\nh\ni\ny\n'
66
class TestShelver(tests.TestCaseWithTransport):
66
class ShelfTestCase(tests.TestCaseWithTransport):
68
68
def create_shelvable_tree(self):
69
69
tree = self.make_branch_and_tree('tree')
73
73
self.build_tree_contents([('tree/foo', LINES_ZY)])
77
class TestShelver(ShelfTestCase):
76
79
def test_unexpected_prompt_failure(self):
77
80
tree = self.create_shelvable_tree()
78
81
tree.lock_tree_write()
302
def test_shelve_old_root_deleted(self):
305
def test_shelve_old_root_preserved(self):
303
306
tree1 = self.make_branch_and_tree('tree1')
304
307
tree1.commit('add root')
308
tree1_root_id = tree1.get_root_id()
305
309
tree2 = self.make_branch_and_tree('tree2')
306
310
rev2 = tree2.commit('add root')
311
self.assertNotEquals(tree1_root_id, tree2.get_root_id())
307
312
tree1.merge_from_branch(tree2.branch,
308
313
from_revision=revision.NULL_REVISION)
309
tree1.commit('Replaced root entry')
314
tree1.commit('merging in tree2')
315
self.assertEquals(tree1_root_id, tree1.get_root_id())
310
316
# This is essentially assertNotRaises(InconsistentDelta)
311
self.expectFailure('Cannot shelve replacing a root entry',
312
self.assertRaises, AssertionError,
313
self.assertRaises, errors.InconsistentDelta,
314
self.shelve_all, tree1, rev2)
317
# With testtools 0.9.9, it can be rewritten as:
318
# with ExpectedException(AssertionError,
319
# 'InconsistentDelta not raised'):
320
# with ExpectedException(errors.InconsistentDelta, ''):
321
# self.shelve_all(tree1, rev2)
322
e = self.assertRaises(AssertionError, self.assertRaises,
323
errors.InconsistentDelta, self.shelve_all, tree1,
325
self.assertContainsRe('InconsistentDelta not raised', str(e))
316
327
def test_shelve_split(self):
317
328
outer_tree = self.make_branch_and_tree('outer')