~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Eric Siegerman
  • Date: 2011-02-08 23:06:34 UTC
  • mto: This revision was merged to the branch mainline in revision 5656.
  • Revision ID: pub08@davor.org-20110208230634-u7ek4qdxikw0wu4w
Fix traceback attempting to "bzr dump-btree --raw btree-with-0-rows".

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