/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_shelf_ui.py

  • Committer: Vincent Ladeuil
  • Date: 2009-12-15 15:05:26 UTC
  • mto: (4905.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4906.
  • Revision ID: v.ladeuil+lp@free.fr-20091215150526-5opw59co07f7uhz3
Implement config.get_user_option_as_list.

* bzrlib/tests/test_config.py:
(TestGetConfig.test_get_user_option_as_list): 

* bzrlib/config.py:
(Config.get_user_option_as_list): A typed accessor.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2008 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
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
 
""")