~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_shelf_ui.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-11-17 03:20:35 UTC
  • mfrom: (4792.4.3 456036)
  • Revision ID: pqm@pqm.ubuntu.com-20091117032035-s3sgtlixj1lrminn
(Gordon Tyler) Fix IndexError during 'bzr ignore /' (#456036)

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
from cStringIO import StringIO
19
19
import os
20
20
import sys
21
 
from textwrap import dedent
22
21
 
23
22
from bzrlib import (
24
23
    errors,
26
25
    revision,
27
26
    tests,
28
27
)
29
 
from bzrlib.tests import script
30
28
 
31
29
 
32
30
class ExpectShelver(shelf_ui.Shelver):
505
503
        self.assertFileEqual(LINES_AJ, 'tree/foo')
506
504
        self.assertEqual(1, tree.get_shelf_manager().last_shelf())
507
505
 
508
 
    def test_unshelve_args_preview(self):
509
 
        tree = self.create_tree_with_shelf()
510
 
        write_diff_to = StringIO()
511
 
        unshelver = shelf_ui.Unshelver.from_args(
512
 
            directory='tree', action='preview', write_diff_to=write_diff_to)
513
 
        try:
514
 
            unshelver.run()
515
 
        finally:
516
 
            unshelver.tree.unlock()
517
 
        # The changes were not unshelved.
518
 
        self.assertFileEqual(LINES_AJ, 'tree/foo')
519
 
        self.assertEqual(1, tree.get_shelf_manager().last_shelf())
520
 
 
521
 
        # But the diff was written to write_diff_to.
522
 
        diff = write_diff_to.getvalue()
523
 
        expected = dedent("""\
524
 
            @@ -1,4 +1,4 @@
525
 
            -a
526
 
            +z
527
 
             b
528
 
             c
529
 
             d
530
 
            @@ -7,4 +7,4 @@
531
 
             g
532
 
             h
533
 
             i
534
 
            -j
535
 
            +y
536
 
 
537
 
            """)
538
 
        self.assertEqualDiff(expected, diff[-len(expected):])
539
 
 
540
506
    def test_unshelve_args_delete_only(self):
541
507
        tree = self.make_branch_and_tree('tree')
542
508
        manager = tree.get_shelf_manager()
564
530
        self.assertRaises(errors.InvalidShelfId,
565
531
            shelf_ui.Unshelver.from_args, directory='tree',
566
532
            action='delete-only', shelf_id='foo')
567
 
 
568
 
 
569
 
class TestUnshelveScripts(TestUnshelver, 
570
 
                          script.TestCaseWithTransportAndScript): 
571
 
 
572
 
    def test_unshelve_messages_keep(self):
573
 
        self.create_tree_with_shelf()
574
 
        self.run_script("""
575
 
$ cd tree
576
 
$ bzr unshelve --keep
577
 
2>Using changes with id "1".
578
 
2> M  foo
579
 
2>All changes applied successfully.
580
 
""")
581
 
 
582
 
    def test_unshelve_messages_delete(self):
583
 
        self.create_tree_with_shelf()
584
 
        self.run_script("""
585
 
$ cd tree
586
 
$ bzr unshelve --delete-only
587
 
2>Deleted changes with id "1".
588
 
""")
589
 
 
590
 
    def test_unshelve_messages_apply(self):
591
 
        self.create_tree_with_shelf()
592
 
        self.run_script("""
593
 
$ cd tree
594
 
$ bzr unshelve --apply
595
 
2>Using changes with id "1".
596
 
2> M  foo
597
 
2>All changes applied successfully.
598
 
2>Deleted changes with id "1".
599
 
""")
600
 
 
601
 
    def test_unshelve_messages_dry_run(self):
602
 
        self.create_tree_with_shelf()
603
 
        self.run_script("""
604
 
$ cd tree
605
 
$ bzr unshelve --dry-run
606
 
2>Using changes with id "1".
607
 
2> M  foo
608
 
""")