~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Robey Pointer
  • Date: 2006-09-03 00:28:18 UTC
  • mfrom: (1981 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1996.
  • Revision ID: robey@lag.net-20060903002818-71ca5c7bfea93a26
merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
 
41
41
class BranchStatus(TestCaseWithTransport):
42
42
    
 
43
    def assertStatus(self, output_lines, working_tree,
 
44
        revision=None):
 
45
        """Run status in working_tree and look for output.
 
46
        
 
47
        :param output_lines: The lines to look for.
 
48
        :param working_tree: The tree to run status in.
 
49
        """
 
50
        output_string = self.status_string(working_tree, revision)
 
51
        self.assertEqual(output_lines, output_string.splitlines(True))
 
52
    
 
53
    def status_string(self, wt, revision=None):
 
54
        # use a real file rather than StringIO because it doesn't handle
 
55
        # Unicode very well.
 
56
        tof = codecs.getwriter('utf-8')(TemporaryFile())
 
57
        show_tree_status(wt, to_file=tof, revision=revision)
 
58
        tof.seek(0)
 
59
        return tof.read().decode('utf-8')
 
60
 
43
61
    def test_branch_status(self):
44
62
        """Test basic branch status"""
45
63
        wt = self.make_branch_and_tree('.')
46
 
        b = wt.branch
47
64
 
48
65
        ignores._set_user_ignores(['./.bazaar'])
49
66
 
50
 
        # status with nothing
51
 
        tof = StringIO()
52
 
        show_tree_status(wt, to_file=tof)
53
 
        self.assertEquals(tof.getvalue(), "")
 
67
        # status with no commits or files - it must
 
68
        # work and show no output. We do this with no
 
69
        # commits to be sure that it's not going to fail
 
70
        # as a corner case.
 
71
        self.assertStatus([], wt)
54
72
 
55
 
        tof = StringIO()
56
73
        self.build_tree(['hello.c', 'bye.c'])
57
 
        wt.add_pending_merge('pending@pending-0-0')
58
 
        show_tree_status(wt, to_file=tof)
59
 
        tof.seek(0)
60
 
        self.assertEquals(tof.readlines(),
61
 
                          ['unknown:\n',
62
 
                           '  bye.c\n',
63
 
                           '  hello.c\n',
64
 
                           'pending merges:\n',
65
 
                           '  pending@pending-0-0\n'
66
 
                           ])
 
74
        self.assertStatus([
 
75
                'unknown:\n',
 
76
                '  bye.c\n',
 
77
                '  hello.c\n',
 
78
            ],
 
79
            wt)
 
80
 
 
81
        # add a commit to allow showing pending merges.
 
82
        wt.commit('create a parent to allow testing merge output')
 
83
 
 
84
        wt.add_parent_tree_id('pending@pending-0-0')
 
85
        self.assertStatus([
 
86
                'unknown:\n',
 
87
                '  bye.c\n',
 
88
                '  hello.c\n',
 
89
                'pending merges:\n',
 
90
                '  pending@pending-0-0\n',
 
91
            ],
 
92
            wt)
67
93
 
68
94
    def test_branch_status_revisions(self):
69
95
        """Tests branch status with revisions"""
70
96
        wt = self.make_branch_and_tree('.')
71
 
        b = wt.branch
72
97
 
73
98
        ignores._set_user_ignores(['./.bazaar'])
74
99
 
75
 
        tof = StringIO()
76
100
        self.build_tree(['hello.c', 'bye.c'])
77
101
        wt.add('hello.c')
78
102
        wt.add('bye.c')
79
103
        wt.commit('Test message')
80
104
 
81
 
        tof = StringIO()
82
 
        revs =[]
83
 
        revs.append(RevisionSpec(0))
84
 
        
85
 
        show_tree_status(wt, to_file=tof, revision=revs)
86
 
        
87
 
        tof.seek(0)
88
 
        self.assertEquals(tof.readlines(),
89
 
                          ['added:\n',
90
 
                           '  bye.c\n',
91
 
                           '  hello.c\n'])
 
105
        revs = [RevisionSpec.from_string('0')]
 
106
        self.assertStatus([
 
107
                'added:\n',
 
108
                '  bye.c\n',
 
109
                '  hello.c\n'
 
110
            ],
 
111
            wt,
 
112
            revision=revs)
92
113
 
93
114
        self.build_tree(['more.c'])
94
115
        wt.add('more.c')
95
116
        wt.commit('Another test message')
96
117
        
97
 
        tof = StringIO()
98
 
        revs.append(RevisionSpec(1))
99
 
        
100
 
        show_tree_status(wt, to_file=tof, revision=revs)
101
 
        
102
 
        tof.seek(0)
103
 
        self.assertEquals(tof.readlines(),
104
 
                          ['added:\n',
105
 
                           '  bye.c\n',
106
 
                           '  hello.c\n'])
107
 
 
108
 
    def status_string(self, wt):
109
 
        # use a real file rather than StringIO because it doesn't handle
110
 
        # Unicode very well.
111
 
        tof = codecs.getwriter('utf-8')(TemporaryFile())
112
 
        show_tree_status(wt, to_file=tof)
113
 
        tof.seek(0)
114
 
        return tof.read().decode('utf-8')
 
118
        revs.append(RevisionSpec.from_string('1'))
 
119
        self.assertStatus([
 
120
                'added:\n',
 
121
                '  bye.c\n',
 
122
                '  hello.c\n',
 
123
            ],
 
124
            wt,
 
125
            revision=revs)
115
126
 
116
127
    def test_pending(self):
117
128
        """Pending merges display works, including Unicode"""