/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/blackbox/test_status.py

  • Committer: Aaron Bentley
  • Date: 2011-04-29 18:23:18 UTC
  • mto: (5832.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 5834.
  • Revision ID: aaron@aaronbentley.com-20110429182318-wi335ccddmi64272
Fix PreviewTree.get_file_size.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
    conflicts,
34
34
    errors,
35
35
    osutils,
 
36
    status,
36
37
    )
37
38
import bzrlib.branch
38
39
from bzrlib.osutils import pathjoin
44
45
 
45
46
class BranchStatus(TestCaseWithTransport):
46
47
 
 
48
    def setUp(self):
 
49
        super(BranchStatus, self).setUp()
 
50
        # As TestCase.setUp clears all hooks, we install this default
 
51
        # post_status hook handler for the test.
 
52
        status.hooks.install_named_hook('post_status',
 
53
            status._show_shelve_summary,
 
54
            'bzr status')
 
55
 
47
56
    def assertStatus(self, expected_lines, working_tree,
48
57
        revision=None, short=False, pending=True, verbose=False):
49
58
        """Run status in working_tree and look for output.
202
211
        wt = self.make_branch_and_tree('.')
203
212
        b = wt.branch
204
213
 
205
 
        self.build_tree(['directory/','directory/hello.c', 'bye.c','test.c','dir2/'])
 
214
        self.build_tree(['directory/','directory/hello.c',
 
215
                         'bye.c','test.c','dir2/',
 
216
                         'missing.c'])
206
217
        wt.add('directory')
207
218
        wt.add('test.c')
208
219
        wt.commit('testing')
 
220
        wt.add('missing.c')
 
221
        unlink('missing.c')
209
222
 
210
223
        self.assertStatus([
 
224
                'missing:\n',
 
225
                '  missing.c\n',
211
226
                'unknown:\n',
212
227
                '  bye.c\n',
213
228
                '  dir2/\n',
218
233
        self.assertStatus([
219
234
                '?   bye.c\n',
220
235
                '?   dir2/\n',
 
236
                '+!  missing.c\n',
221
237
                '?   directory/hello.c\n'
222
238
                ],
223
239
                wt, short=True)
260
276
        tof.seek(0)
261
277
        self.assertEquals(tof.readlines(), ['+N  test.c\n'])
262
278
 
 
279
        tof = StringIO()
 
280
        show_tree_status(wt, specific_files=['missing.c'], to_file=tof)
 
281
        tof.seek(0)
 
282
        self.assertEquals(tof.readlines(),
 
283
                          ['missing:\n',
 
284
                           '  missing.c\n'])
 
285
 
 
286
        tof = StringIO()
 
287
        show_tree_status(wt, specific_files=['missing.c'], to_file=tof,
 
288
                         short=True)
 
289
        tof.seek(0)
 
290
        self.assertEquals(tof.readlines(),
 
291
                          ['+!  missing.c\n'])
 
292
 
263
293
    def test_specific_files_conflicts(self):
264
294
        tree = self.make_branch_and_tree('.')
265
295
        self.build_tree(['dir2/'])
520
550
        out, err = self.run_bzr('status branch1 -rbranch:branch2')
521
551
        self.assertEqual('', out)
522
552
 
 
553
    def test_status_with_shelves(self):
 
554
        """Ensure that _show_shelve_summary handler works.
 
555
        """
 
556
        wt = self.make_branch_and_tree('.')
 
557
        self.build_tree(['hello.c'])
 
558
        wt.add('hello.c')
 
559
        self.run_bzr(['shelve', '--all', '-m', 'foo'])
 
560
        self.build_tree(['bye.c'])
 
561
        wt.add('bye.c')
 
562
        self.assertStatus([
 
563
                'added:\n',
 
564
                '  bye.c\n',
 
565
                '1 shelf exists. See "bzr shelve --list" for details.\n',
 
566
            ],
 
567
            wt)
 
568
        self.run_bzr(['shelve', '--all', '-m', 'bar'])
 
569
        self.build_tree(['spam.c'])
 
570
        wt.add('spam.c')
 
571
        self.assertStatus([
 
572
                'added:\n',
 
573
                '  spam.c\n',
 
574
                '2 shelves exist. See "bzr shelve --list" for details.\n',
 
575
            ],
 
576
            wt)
 
577
 
523
578
 
524
579
class CheckoutStatus(BranchStatus):
525
580
 
704
759
 
705
760
class TestStatusEncodings(TestCaseWithTransport):
706
761
 
707
 
    def setUp(self):
708
 
        TestCaseWithTransport.setUp(self)
709
 
        self.user_encoding = osutils._cached_user_encoding
710
 
        self.stdout = sys.stdout
711
 
 
712
 
    def tearDown(self):
713
 
        osutils._cached_user_encoding = self.user_encoding
714
 
        sys.stdout = self.stdout
715
 
        TestCaseWithTransport.tearDown(self)
716
 
 
717
762
    def make_uncommitted_tree(self):
718
763
        """Build a branch with uncommitted unicode named changes in the cwd."""
719
764
        working_tree = self.make_branch_and_tree(u'.')
727
772
        return working_tree
728
773
 
729
774
    def test_stdout_ascii(self):
730
 
        sys.stdout = StringIO()
731
 
        osutils._cached_user_encoding = 'ascii'
 
775
        self.overrideAttr(osutils, '_cached_user_encoding', 'ascii')
732
776
        working_tree = self.make_uncommitted_tree()
733
777
        stdout, stderr = self.run_bzr("status")
734
778
 
738
782
""")
739
783
 
740
784
    def test_stdout_latin1(self):
741
 
        sys.stdout = StringIO()
742
 
        osutils._cached_user_encoding = 'latin-1'
 
785
        self.overrideAttr(osutils, '_cached_user_encoding', 'latin-1')
743
786
        working_tree = self.make_uncommitted_tree()
744
787
        stdout, stderr = self.run_bzr('status')
745
788