224
225
self.assertFileEqual(LINES_AJ, 'tree/foo')
228
class TestApplyReporter(TestShelver):
230
def test_shelve_not_diff(self):
231
tree = self.create_shelvable_tree()
232
shelver = ExpectShelver(tree, tree.basis_tree(),
233
reporter=shelf_ui.ApplyReporter())
234
shelver.expect('Apply change? [yNfq?]', 'n')
235
shelver.expect('Apply change? [yNfq?]', 'n')
236
# No final shelving prompt because no changes were selected
238
self.assertFileEqual(LINES_ZY, 'tree/foo')
240
def test_shelve_diff_no(self):
241
tree = self.create_shelvable_tree()
242
shelver = ExpectShelver(tree, tree.basis_tree(),
243
reporter=shelf_ui.ApplyReporter())
244
shelver.expect('Apply change? [yNfq?]', 'y')
245
shelver.expect('Apply change? [yNfq?]', 'y')
246
shelver.expect('Apply 2 change(s)? [yNfq?]', 'n')
248
self.assertFileEqual(LINES_ZY, 'tree/foo')
250
def test_shelve_diff(self):
251
tree = self.create_shelvable_tree()
252
shelver = ExpectShelver(tree, tree.basis_tree(),
253
reporter=shelf_ui.ApplyReporter())
254
shelver.expect('Apply change? [yNfq?]', 'y')
255
shelver.expect('Apply change? [yNfq?]', 'y')
256
shelver.expect('Apply 2 change(s)? [yNfq?]', 'y')
258
self.assertFileEqual(LINES_AJ, 'tree/foo')
260
def test_shelve_binary_change(self):
261
tree = self.create_shelvable_tree()
262
self.build_tree_contents([('tree/foo', '\x00')])
263
shelver = ExpectShelver(tree, tree.basis_tree(),
264
reporter=shelf_ui.ApplyReporter())
265
shelver.expect('Apply binary changes? [yNfq?]', 'y')
266
shelver.expect('Apply 1 change(s)? [yNfq?]', 'y')
268
self.assertFileEqual(LINES_AJ, 'tree/foo')
270
def test_shelve_rename(self):
271
tree = self.create_shelvable_tree()
272
tree.rename_one('foo', 'bar')
273
shelver = ExpectShelver(tree, tree.basis_tree(),
274
reporter=shelf_ui.ApplyReporter())
275
shelver.expect('Rename "bar" => "foo"? [yNfq?]', 'y')
276
shelver.expect('Apply change? [yNfq?]', 'y')
277
shelver.expect('Apply change? [yNfq?]', 'y')
278
shelver.expect('Apply 3 change(s)? [yNfq?]', 'y')
280
self.assertFileEqual(LINES_AJ, 'tree/foo')
282
def test_shelve_deletion(self):
283
tree = self.create_shelvable_tree()
284
os.unlink('tree/foo')
285
shelver = ExpectShelver(tree, tree.basis_tree(),
286
reporter=shelf_ui.ApplyReporter())
287
shelver.expect('Add file "foo"? [yNfq?]', 'y')
288
shelver.expect('Apply 1 change(s)? [yNfq?]', 'y')
290
self.assertFileEqual(LINES_AJ, 'tree/foo')
292
def test_shelve_creation(self):
293
tree = self.make_branch_and_tree('tree')
294
tree.commit('add tree root')
295
self.build_tree(['tree/foo'])
297
shelver = ExpectShelver(tree, tree.basis_tree(),
298
reporter=shelf_ui.ApplyReporter())
299
shelver.expect('Delete file "foo"? [yNfq?]', 'y')
300
shelver.expect('Apply 1 change(s)? [yNfq?]', 'y')
302
self.failIfExists('tree/foo')
304
def test_shelve_kind_change(self):
305
tree = self.create_shelvable_tree()
306
os.unlink('tree/foo')
308
shelver = ExpectShelver(tree, tree.basis_tree(),
309
reporter=shelf_ui.ApplyReporter())
310
shelver.expect('Change "foo" from directory to a file? [yNfq?]', 'y')
311
shelver.expect('Apply 1 change(s)? [yNfq?]', 'y')
313
def test_shelve_modify_target(self):
314
self.requireFeature(tests.SymlinkFeature)
315
tree = self.create_shelvable_tree()
316
os.symlink('bar', 'tree/baz')
317
tree.add('baz', 'baz-id')
318
tree.commit("Add symlink")
319
os.unlink('tree/baz')
320
os.symlink('vax', 'tree/baz')
321
shelver = ExpectShelver(tree, tree.basis_tree(),
322
reporter=shelf_ui.ApplyReporter())
323
shelver.expect('Change target of "baz" from "vax" to "bar"? [yNfq?]',
325
shelver.expect('Apply 1 change(s)? [yNfq?]', 'y')
327
self.assertEqual('bar', os.readlink('tree/baz'))
227
330
class TestUnshelver(tests.TestCaseWithTransport):
229
332
def create_tree_with_shelf(self):