~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-09-01 08:02:42 UTC
  • mfrom: (5390.3.3 faster-revert-593560)
  • Revision ID: pqm@pqm.ubuntu.com-20100901080242-esg62ody4frwmy66
(spiv) Avoid repeatedly calling self.target.all_file_ids() in
 InterTree.iter_changes. (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2005-2010 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
472
472
        self.assertEqual("working tree is out of date, run 'bzr update'\n",
473
473
                         err)
474
474
 
 
475
    def test_status_on_ignored(self):
 
476
        """Tests branch status on an unversioned file which is considered ignored.
 
477
 
 
478
        See https://bugs.launchpad.net/bzr/+bug/40103
 
479
        """
 
480
        tree = self.make_branch_and_tree('.')
 
481
 
 
482
        self.build_tree(['test1.c', 'test1.c~', 'test2.c~'])
 
483
        result = self.run_bzr('status')[0]
 
484
        self.assertContainsRe(result, "unknown:\n  test1.c\n")
 
485
        short_result = self.run_bzr('status --short')[0]
 
486
        self.assertContainsRe(short_result, "\?   test1.c\n")
 
487
 
 
488
        result = self.run_bzr('status test1.c')[0]
 
489
        self.assertContainsRe(result, "unknown:\n  test1.c\n")
 
490
        short_result = self.run_bzr('status --short test1.c')[0]
 
491
        self.assertContainsRe(short_result, "\?   test1.c\n")
 
492
 
 
493
        result = self.run_bzr('status test1.c~')[0]
 
494
        self.assertContainsRe(result, "ignored:\n  test1.c~\n")
 
495
        short_result = self.run_bzr('status --short test1.c~')[0]
 
496
        self.assertContainsRe(short_result, "I   test1.c~\n")
 
497
 
 
498
        result = self.run_bzr('status test1.c~ test2.c~')[0]
 
499
        self.assertContainsRe(result, "ignored:\n  test1.c~\n  test2.c~\n")
 
500
        short_result = self.run_bzr('status --short test1.c~ test2.c~')[0]
 
501
        self.assertContainsRe(short_result, "I   test1.c~\nI   test2.c~\n")
 
502
 
 
503
        result = self.run_bzr('status test1.c test1.c~ test2.c~')[0]
 
504
        self.assertContainsRe(result, "unknown:\n  test1.c\nignored:\n  test1.c~\n  test2.c~\n")
 
505
        short_result = self.run_bzr('status --short test1.c test1.c~ test2.c~')[0]
 
506
        self.assertContainsRe(short_result, "\?   test1.c\nI   test1.c~\nI   test2.c~\n")
 
507
 
475
508
    def test_status_write_lock(self):
476
509
        """Test that status works without fetching history and
477
510
        having a write lock.
498
531
    def make_branch_and_tree(self, relpath):
499
532
        source = self.make_branch(pathjoin('..', relpath))
500
533
        checkout = bzrdir.BzrDirMetaFormat1().initialize(relpath)
501
 
        bzrlib.branch.BranchReferenceFormat().initialize(checkout, source)
 
534
        bzrlib.branch.BranchReferenceFormat().initialize(checkout,
 
535
            target_branch=source)
502
536
        return checkout.create_workingtree()
503
537
 
504
538
 
595
629
        result2 = self.run_bzr("status -SV -r 0..")[0]
596
630
        self.assertEquals(result2, result)
597
631
 
598
 
    def assertStatusContains(self, pattern):
 
632
    def assertStatusContains(self, pattern, short=False):
599
633
        """Run status, and assert it contains the given pattern"""
600
 
        result = self.run_bzr("status --short")[0]
 
634
        if short:
 
635
            result = self.run_bzr("status --short")[0]
 
636
        else:
 
637
            result = self.run_bzr("status")[0]
601
638
        self.assertContainsRe(result, pattern)
602
639
 
 
640
    def test_kind_change_plain(self):
 
641
        tree = self.make_branch_and_tree('.')
 
642
        self.build_tree(['file'])
 
643
        tree.add('file')
 
644
        tree.commit('added file')
 
645
        unlink('file')
 
646
        self.build_tree(['file/'])
 
647
        self.assertStatusContains('kind changed:\n  file \(file => directory\)')
 
648
        tree.rename_one('file', 'directory')
 
649
        self.assertStatusContains('renamed:\n  file/ => directory/\n' \
 
650
                                  'modified:\n  directory/\n')
 
651
        rmdir('directory')
 
652
        self.assertStatusContains('removed:\n  file\n')
 
653
 
603
654
    def test_kind_change_short(self):
604
655
        tree = self.make_branch_and_tree('.')
605
656
        self.build_tree(['file'])
607
658
        tree.commit('added file')
608
659
        unlink('file')
609
660
        self.build_tree(['file/'])
610
 
        self.assertStatusContains('K  file => file/')
 
661
        self.assertStatusContains('K  file => file/',
 
662
                                   short=True)
611
663
        tree.rename_one('file', 'directory')
612
 
        self.assertStatusContains('RK  file => directory/')
 
664
        self.assertStatusContains('RK  file => directory/',
 
665
                                   short=True)
613
666
        rmdir('directory')
614
 
        self.assertStatusContains('RD  file => directory')
 
667
        self.assertStatusContains('RD  file => directory',
 
668
                                   short=True)
615
669
 
616
670
    def test_status_illegal_revision_specifiers(self):
617
671
        out, err = self.run_bzr('status -r 1..23..123', retcode=3)
650
704
 
651
705
class TestStatusEncodings(TestCaseWithTransport):
652
706
 
653
 
    def setUp(self):
654
 
        TestCaseWithTransport.setUp(self)
655
 
        self.user_encoding = osutils._cached_user_encoding
656
 
        self.stdout = sys.stdout
657
 
 
658
 
    def tearDown(self):
659
 
        bzrlib.user_encoding = self.user_encoding
660
 
        sys.stdout = self.stdout
661
 
        TestCaseWithTransport.tearDown(self)
662
 
 
663
707
    def make_uncommitted_tree(self):
664
708
        """Build a branch with uncommitted unicode named changes in the cwd."""
665
709
        working_tree = self.make_branch_and_tree(u'.')
673
717
        return working_tree
674
718
 
675
719
    def test_stdout_ascii(self):
676
 
        sys.stdout = StringIO()
677
 
        osutils._cached_user_encoding = 'ascii'
 
720
        self.overrideAttr(osutils, '_cached_user_encoding', 'ascii')
678
721
        working_tree = self.make_uncommitted_tree()
679
722
        stdout, stderr = self.run_bzr("status")
680
723
 
684
727
""")
685
728
 
686
729
    def test_stdout_latin1(self):
687
 
        sys.stdout = StringIO()
688
 
        osutils._cached_user_encoding = 'latin-1'
 
730
        self.overrideAttr(osutils, '_cached_user_encoding', 'latin-1')
689
731
        working_tree = self.make_uncommitted_tree()
690
732
        stdout, stderr = self.run_bzr('status')
691
733