66
63
LINES_AY = 'a\nb\nc\nd\ne\nf\ng\nh\ni\ny\n'
69
class ShelfTestCase(tests.TestCaseWithTransport):
66
class TestShelver(tests.TestCaseWithTransport):
71
68
def create_shelvable_tree(self):
72
69
tree = self.make_branch_and_tree('tree')
76
73
self.build_tree_contents([('tree/foo', LINES_ZY)])
80
class TestShelver(ShelfTestCase):
82
76
def test_unexpected_prompt_failure(self):
83
77
tree = self.create_shelvable_tree()
84
78
tree.lock_tree_write()
196
190
shelver.expect('Shelve adding file "foo"? [yNfq?]', 'y')
197
191
shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y')
199
self.assertPathDoesNotExist('tree/foo')
193
self.failIfExists('tree/foo')
201
195
def test_shelve_kind_change(self):
202
196
tree = self.create_shelvable_tree()
211
205
shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y')
213
207
def test_shelve_modify_target(self):
214
self.requireFeature(features.SymlinkFeature)
208
self.requireFeature(tests.SymlinkFeature)
215
209
tree = self.create_shelvable_tree()
216
210
os.symlink('bar', 'tree/baz')
217
211
tree.add('baz', 'baz-id')
308
def test_shelve_old_root_preserved(self):
302
def test_shelve_old_root_deleted(self):
309
303
tree1 = self.make_branch_and_tree('tree1')
310
304
tree1.commit('add root')
311
tree1_root_id = tree1.get_root_id()
312
305
tree2 = self.make_branch_and_tree('tree2')
313
306
rev2 = tree2.commit('add root')
314
self.assertNotEquals(tree1_root_id, tree2.get_root_id())
315
307
tree1.merge_from_branch(tree2.branch,
316
308
from_revision=revision.NULL_REVISION)
317
tree1.commit('merging in tree2')
318
self.assertEquals(tree1_root_id, tree1.get_root_id())
309
tree1.commit('Replaced root entry')
319
310
# This is essentially assertNotRaises(InconsistentDelta)
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))
311
self.expectFailure('Cannot shelve replacing a root entry',
312
self.assertRaises, AssertionError,
313
self.assertRaises, errors.InconsistentDelta,
314
self.shelve_all, tree1, rev2)
330
316
def test_shelve_split(self):
331
317
outer_tree = self.make_branch_and_tree('outer')
436
422
shelver.expect('Delete file "foo"? [yNfq?]', 'y')
437
423
shelver.expect('Apply 1 change(s)? [yNfq?]', 'y')
439
self.assertPathDoesNotExist('tree/foo')
425
self.failIfExists('tree/foo')
441
427
def test_shelve_kind_change(self):
442
428
tree = self.create_shelvable_tree()
451
437
shelver.expect('Apply 1 change(s)? [yNfq?]', 'y')
453
439
def test_shelve_modify_target(self):
454
self.requireFeature(features.SymlinkFeature)
440
self.requireFeature(tests.SymlinkFeature)
455
441
tree = self.create_shelvable_tree()
456
442
os.symlink('bar', 'tree/baz')
457
443
tree.add('baz', 'baz-id')