~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
            status._show_shelve_summary,
54
54
            'bzr status')
55
55
 
56
 
    def assertStatus(self, expected_lines, working_tree,
 
56
    def assertStatus(self, expected_lines, working_tree, specific_files=None,
57
57
        revision=None, short=False, pending=True, verbose=False):
58
58
        """Run status in working_tree and look for output.
59
59
 
60
60
        :param expected_lines: The lines to look for.
61
61
        :param working_tree: The tree to run status in.
62
62
        """
63
 
        output_string = self.status_string(working_tree, revision, short,
 
63
        output_string = self.status_string(working_tree, specific_files, revision, short,
64
64
                pending, verbose)
65
65
        self.assertEqual(expected_lines, output_string.splitlines(True))
66
66
 
67
 
    def status_string(self, wt, revision=None, short=False, pending=True,
68
 
        verbose=False):
 
67
    def status_string(self, wt, specific_files=None, revision=None,
 
68
        short=False, pending=True, verbose=False):
69
69
        # use a real file rather than StringIO because it doesn't handle
70
70
        # Unicode very well.
71
71
        tof = codecs.getwriter('utf-8')(TemporaryFile())
72
 
        show_tree_status(wt, to_file=tof, revision=revision, short=short,
73
 
                show_pending=pending, verbose=verbose)
 
72
        show_tree_status(wt, specific_files=specific_files, to_file=tof,
 
73
                revision=revision, short=short, show_pending=pending,
 
74
                verbose=verbose)
74
75
        tof.seek(0)
75
76
        return tof.read().decode('utf-8')
76
77
 
324
325
        wt.add('FILE_D')
325
326
        wt.add('FILE_E')
326
327
        wt.commit('Create five empty files.')
327
 
        open('FILE_B', 'w').write('Modification to file FILE_B.')
328
 
        open('FILE_C', 'w').write('Modification to file FILE_C.')
 
328
        with open('FILE_B', 'w') as f: f.write('Modification to file FILE_B.')
 
329
        with open('FILE_C', 'w') as f: f.write('Modification to file FILE_C.')
329
330
        unlink('FILE_E')  # FILE_E will be versioned but missing
330
 
        open('FILE_Q', 'w').write('FILE_Q is added but not committed.')
 
331
        with open('FILE_Q', 'w') as f: f.write('FILE_Q is added but not committed.')
331
332
        wt.add('FILE_Q')  # FILE_Q will be added but not committed
332
333
        open('UNVERSIONED_BUT_EXISTING', 'w')
333
334
        return wt
477
478
          ' M  FILE_B\n',
478
479
          'X   NONEXISTENT\n',
479
480
          ]
 
481
        expected.sort()
480
482
        out, err = self.run_bzr('status --short NONEXISTENT '
481
483
                                'FILE_A FILE_B UNVERSIONED_BUT_EXISTING '
482
484
                                'FILE_C FILE_D FILE_E FILE_Q', retcode=3)
483
 
        self.assertEqual(expected, out.splitlines(True))
 
485
        actual = out.splitlines(True)
 
486
        actual.sort()
 
487
        self.assertEqual(expected, actual)
484
488
        self.assertContainsRe(err,
485
489
                              r'.*ERROR: Path\(s\) do not exist: '
486
490
                              'NONEXISTENT.*')
566
570
            ],
567
571
            wt)
568
572
        self.run_bzr(['shelve', '--all', '-m', 'bar'])
569
 
        self.build_tree(['spam.c'])
 
573
        self.build_tree(['eggs.c', 'spam.c'])
 
574
        wt.add('eggs.c')
570
575
        wt.add('spam.c')
571
576
        self.assertStatus([
572
577
                'added:\n',
 
578
                '  eggs.c\n',
573
579
                '  spam.c\n',
574
580
                '2 shelves exist. See "bzr shelve --list" for details.\n',
575
581
            ],
576
582
            wt)
 
583
        self.assertStatus([
 
584
                'added:\n',
 
585
                '  spam.c\n',
 
586
            ],
 
587
            wt,
 
588
            specific_files=['spam.c'])
577
589
 
578
590
 
579
591
class CheckoutStatus(BranchStatus):
586
598
    def make_branch_and_tree(self, relpath):
587
599
        source = self.make_branch(pathjoin('..', relpath))
588
600
        checkout = bzrdir.BzrDirMetaFormat1().initialize(relpath)
589
 
        bzrlib.branch.BranchReferenceFormat().initialize(checkout,
590
 
            target_branch=source)
 
601
        checkout.set_branch_reference(source)
591
602
        return checkout.create_workingtree()
592
603
 
593
604
 
634
645
        self.assertContainsRe(result, "[+]N  hello.txt\n")
635
646
 
636
647
        self.build_tree(['world.txt'])
637
 
        result = self.run_bzr("status --short -r 0")[0]
 
648
        result = self.run_bzr("status -S -r 0")[0]
638
649
        self.assertContainsRe(result, "[+]N  hello.txt\n" \
639
650
                                      "[?]   world.txt\n")
640
 
        result2 = self.run_bzr("status --short -r 0..")[0]
 
651
        result2 = self.run_bzr("status -S -r 0..")[0]
641
652
        self.assertEquals(result2, result)
642
653
 
643
654
    def test_status_versioned(self):