~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_status.py

  • Committer: Martin
  • Date: 2010-12-16 20:41:47 UTC
  • mfrom: (5050.58.4 2.2)
  • mto: This revision was merged to the branch mainline in revision 5574.
  • Revision ID: gzlist@googlemail.com-20101216204147-aquetqr5v8pilrzx
Merge 2.2 for fixes to lp:686611 and lp:687653

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 shelves exist. See "bzr shelve --list" for details.\n',
 
566
            ],
 
567
            wt)
 
568
 
523
569
 
524
570
class CheckoutStatus(BranchStatus):
525
571
 
704
750
 
705
751
class TestStatusEncodings(TestCaseWithTransport):
706
752
 
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
753
    def make_uncommitted_tree(self):
718
754
        """Build a branch with uncommitted unicode named changes in the cwd."""
719
755
        working_tree = self.make_branch_and_tree(u'.')
727
763
        return working_tree
728
764
 
729
765
    def test_stdout_ascii(self):
730
 
        sys.stdout = StringIO()
731
 
        osutils._cached_user_encoding = 'ascii'
 
766
        self.overrideAttr(osutils, '_cached_user_encoding', 'ascii')
732
767
        working_tree = self.make_uncommitted_tree()
733
768
        stdout, stderr = self.run_bzr("status")
734
769
 
738
773
""")
739
774
 
740
775
    def test_stdout_latin1(self):
741
 
        sys.stdout = StringIO()
742
 
        osutils._cached_user_encoding = 'latin-1'
 
776
        self.overrideAttr(osutils, '_cached_user_encoding', 'latin-1')
743
777
        working_tree = self.make_uncommitted_tree()
744
778
        stdout, stderr = self.run_bzr('status')
745
779