~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: 2010-01-13 00:25:44 UTC
  • mfrom: (4902.1.9 2.1.0rc1-unshelve-preview)
  • Revision ID: pqm@pqm.ubuntu.com-20100113002544-mztf6nwrfgqienjc
(salgado) bug # 308122, Implement 'bzr unshelve --preview'

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
21
22
 
22
23
from bzrlib import (
23
24
    errors,
504
505
        self.assertFileEqual(LINES_AJ, 'tree/foo')
505
506
        self.assertEqual(1, tree.get_shelf_manager().last_shelf())
506
507
 
 
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
 
507
540
    def test_unshelve_args_delete_only(self):
508
541
        tree = self.make_branch_and_tree('tree')
509
542
        manager = tree.get_shelf_manager()