~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_shelf_ui.py

  • Committer: Aaron Bentley
  • Date: 2009-07-12 13:55:32 UTC
  • mto: (4526.6.5)
  • mto: This revision was merged to the branch mainline in revision 4534.
  • Revision ID: aaron@aaronbentley.com-20090712135532-sib7az25qkd6mphh
Make vocabulary part of reporter.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
    def __init__(self, work_tree, target_tree, diff_writer=None,
29
29
                 auto=False, auto_apply=False, file_list=None, message=None,
30
 
                 destroy=False, vocab_apply=False):
 
30
                 destroy=False, reporter=None):
31
31
        shelf_ui.Shelver.__init__(self, work_tree, target_tree, diff_writer,
32
32
                                  auto, auto_apply, file_list, message,
33
 
                                  destroy, vocab_apply=vocab_apply)
 
33
                                  destroy, reporter=reporter)
34
34
        self.expected = []
35
35
        self.diff_writer = StringIO()
36
36
 
224
224
        self.assertFileEqual(LINES_AJ, 'tree/foo')
225
225
 
226
226
 
227
 
class TestShelverApplyVocab(TestShelver):
 
227
class TestApplyReporter(TestShelver):
228
228
 
229
229
    def test_shelve_not_diff(self):
230
230
        tree = self.create_shelvable_tree()
231
 
        shelver = ExpectShelver(tree, tree.basis_tree(), vocab_apply=True)
 
231
        shelver = ExpectShelver(tree, tree.basis_tree(),
 
232
                                reporter=shelf_ui.ApplyReporter())
232
233
        shelver.expect('Apply change? [yNfq?]', 'n')
233
234
        shelver.expect('Apply change? [yNfq?]', 'n')
234
235
        # No final shelving prompt because no changes were selected
237
238
 
238
239
    def test_shelve_diff_no(self):
239
240
        tree = self.create_shelvable_tree()
240
 
        shelver = ExpectShelver(tree, tree.basis_tree(), vocab_apply=True)
 
241
        shelver = ExpectShelver(tree, tree.basis_tree(),
 
242
                                reporter=shelf_ui.ApplyReporter())
241
243
        shelver.expect('Apply change? [yNfq?]', 'y')
242
244
        shelver.expect('Apply change? [yNfq?]', 'y')
243
245
        shelver.expect('Apply 2 change(s)? [yNfq?]', 'n')
246
248
 
247
249
    def test_shelve_diff(self):
248
250
        tree = self.create_shelvable_tree()
249
 
        shelver = ExpectShelver(tree, tree.basis_tree(), vocab_apply=True)
 
251
        shelver = ExpectShelver(tree, tree.basis_tree(),
 
252
                                reporter=shelf_ui.ApplyReporter())
250
253
        shelver.expect('Apply change? [yNfq?]', 'y')
251
254
        shelver.expect('Apply change? [yNfq?]', 'y')
252
255
        shelver.expect('Apply 2 change(s)? [yNfq?]', 'y')
256
259
    def test_shelve_binary_change(self):
257
260
        tree = self.create_shelvable_tree()
258
261
        self.build_tree_contents([('tree/foo', '\x00')])
259
 
        shelver = ExpectShelver(tree, tree.basis_tree(), vocab_apply=True)
 
262
        shelver = ExpectShelver(tree, tree.basis_tree(),
 
263
                                reporter=shelf_ui.ApplyReporter())
260
264
        shelver.expect('Apply binary changes? [yNfq?]', 'y')
261
265
        shelver.expect('Apply 1 change(s)? [yNfq?]', 'y')
262
266
        shelver.run()
265
269
    def test_shelve_rename(self):
266
270
        tree = self.create_shelvable_tree()
267
271
        tree.rename_one('foo', 'bar')
268
 
        shelver = ExpectShelver(tree, tree.basis_tree(), vocab_apply=True)
 
272
        shelver = ExpectShelver(tree, tree.basis_tree(),
 
273
                                reporter=shelf_ui.ApplyReporter())
269
274
        shelver.expect('Rename "bar" => "foo"? [yNfq?]', 'y')
270
275
        shelver.expect('Apply change? [yNfq?]', 'y')
271
276
        shelver.expect('Apply change? [yNfq?]', 'y')
276
281
    def test_shelve_deletion(self):
277
282
        tree = self.create_shelvable_tree()
278
283
        os.unlink('tree/foo')
279
 
        shelver = ExpectShelver(tree, tree.basis_tree(), vocab_apply=True)
 
284
        shelver = ExpectShelver(tree, tree.basis_tree(),
 
285
                                reporter=shelf_ui.ApplyReporter())
280
286
        shelver.expect('Add file "foo"? [yNfq?]', 'y')
281
287
        shelver.expect('Apply 1 change(s)? [yNfq?]', 'y')
282
288
        shelver.run()
287
293
        tree.commit('add tree root')
288
294
        self.build_tree(['tree/foo'])
289
295
        tree.add('foo')
290
 
        shelver = ExpectShelver(tree, tree.basis_tree(), vocab_apply=True)
 
296
        shelver = ExpectShelver(tree, tree.basis_tree(),
 
297
                                reporter=shelf_ui.ApplyReporter())
291
298
        shelver.expect('Delete file "foo"? [yNfq?]', 'y')
292
299
        shelver.expect('Apply 1 change(s)? [yNfq?]', 'y')
293
300
        shelver.run()
297
304
        tree = self.create_shelvable_tree()
298
305
        os.unlink('tree/foo')
299
306
        os.mkdir('tree/foo')
300
 
        shelver = ExpectShelver(tree, tree.basis_tree(), vocab_apply=True)
 
307
        shelver = ExpectShelver(tree, tree.basis_tree(),
 
308
                               reporter=shelf_ui.ApplyReporter())
301
309
        shelver.expect('Change "foo" from directory to a file? [yNfq?]', 'y')
302
310
        shelver.expect('Apply 1 change(s)? [yNfq?]', 'y')
303
311
 
308
316
        tree.commit("Add symlink")
309
317
        os.unlink('tree/baz')
310
318
        os.symlink('vax', 'tree/baz')
311
 
        shelver = ExpectShelver(tree, tree.basis_tree(), vocab_apply=True)
 
319
        shelver = ExpectShelver(tree, tree.basis_tree(),
 
320
                                reporter=shelf_ui.ApplyReporter())
312
321
        shelver.expect('Change target of "baz" from "vax" to "bar"? [yNfq?]',
313
322
                       'y')
314
323
        shelver.expect('Apply 1 change(s)? [yNfq?]', 'y')