63
66
LINES_AY = 'a\nb\nc\nd\ne\nf\ng\nh\ni\ny\n'
66
class TestShelver(tests.TestCaseWithTransport):
69
class ShelfTestCase(tests.TestCaseWithTransport):
68
71
def create_shelvable_tree(self):
69
72
tree = self.make_branch_and_tree('tree')
73
76
self.build_tree_contents([('tree/foo', LINES_ZY)])
80
class TestShelver(ShelfTestCase):
76
82
def test_unexpected_prompt_failure(self):
77
83
tree = self.create_shelvable_tree()
78
84
tree.lock_tree_write()
205
211
shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y')
207
213
def test_shelve_modify_target(self):
208
self.requireFeature(tests.SymlinkFeature)
214
self.requireFeature(features.SymlinkFeature)
209
215
tree = self.create_shelvable_tree()
210
216
os.symlink('bar', 'tree/baz')
211
217
tree.add('baz', 'baz-id')
302
def test_shelve_old_root_deleted(self):
308
def test_shelve_old_root_preserved(self):
303
309
tree1 = self.make_branch_and_tree('tree1')
304
310
tree1.commit('add root')
311
tree1_root_id = tree1.get_root_id()
305
312
tree2 = self.make_branch_and_tree('tree2')
306
313
rev2 = tree2.commit('add root')
314
self.assertNotEquals(tree1_root_id, tree2.get_root_id())
307
315
tree1.merge_from_branch(tree2.branch,
308
316
from_revision=revision.NULL_REVISION)
309
tree1.commit('Replaced root entry')
317
tree1.commit('merging in tree2')
318
self.assertEquals(tree1_root_id, tree1.get_root_id())
310
319
# 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)
320
# With testtools 0.9.9, it can be rewritten as:
321
# with ExpectedException(AssertionError,
322
# 'InconsistentDelta not raised'):
323
# with ExpectedException(errors.InconsistentDelta, ''):
324
# self.shelve_all(tree1, rev2)
325
e = self.assertRaises(AssertionError, self.assertRaises,
326
errors.InconsistentDelta, self.shelve_all, tree1,
328
self.assertContainsRe('InconsistentDelta not raised', str(e))
316
330
def test_shelve_split(self):
317
331
outer_tree = self.make_branch_and_tree('outer')
437
451
shelver.expect('Apply 1 change(s)? [yNfq?]', 'y')
439
453
def test_shelve_modify_target(self):
440
self.requireFeature(tests.SymlinkFeature)
454
self.requireFeature(features.SymlinkFeature)
441
455
tree = self.create_shelvable_tree()
442
456
os.symlink('bar', 'tree/baz')
443
457
tree.add('baz', 'baz-id')