/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Aaron Bentley
  • Date: 2006-09-09 18:52:57 UTC
  • mfrom: (1996 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1997.
  • Revision ID: aaron.bentley@utoronto.ca-20060909185257-ce0ee03ee5125ff1
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
import sys
29
29
from tempfile import TemporaryFile
30
30
 
31
 
from bzrlib import bzrdir, errors, ignores
 
31
from bzrlib import bzrdir, errors
32
32
import bzrlib.branch
33
33
from bzrlib.builtins import merge
34
34
from bzrlib.osutils import pathjoin
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
 
 
48
 
        ignores._set_user_ignores(['./.bazaar'])
49
 
 
50
 
        # status with nothing
51
 
        tof = StringIO()
52
 
        show_tree_status(wt, to_file=tof)
53
 
        self.assertEquals(tof.getvalue(), "")
54
 
 
55
 
        tof = StringIO()
 
64
 
 
65
        # status with no commits or files - it must
 
66
        # work and show no output. We do this with no
 
67
        # commits to be sure that it's not going to fail
 
68
        # as a corner case.
 
69
        self.assertStatus([], wt)
 
70
 
56
71
        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
 
                           ])
 
72
        self.assertStatus([
 
73
                'unknown:\n',
 
74
                '  bye.c\n',
 
75
                '  hello.c\n',
 
76
            ],
 
77
            wt)
 
78
 
 
79
        # add a commit to allow showing pending merges.
 
80
        wt.commit('create a parent to allow testing merge output')
 
81
 
 
82
        wt.add_parent_tree_id('pending@pending-0-0')
 
83
        self.assertStatus([
 
84
                'unknown:\n',
 
85
                '  bye.c\n',
 
86
                '  hello.c\n',
 
87
                'pending merges:\n',
 
88
                '  pending@pending-0-0\n',
 
89
            ],
 
90
            wt)
67
91
 
68
92
    def test_branch_status_revisions(self):
69
93
        """Tests branch status with revisions"""
70
94
        wt = self.make_branch_and_tree('.')
71
 
        b = wt.branch
72
 
 
73
 
        ignores._set_user_ignores(['./.bazaar'])
74
 
 
75
 
        tof = StringIO()
 
95
 
76
96
        self.build_tree(['hello.c', 'bye.c'])
77
97
        wt.add('hello.c')
78
98
        wt.add('bye.c')
79
99
        wt.commit('Test message')
80
100
 
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'])
 
101
        revs = [RevisionSpec.from_string('0')]
 
102
        self.assertStatus([
 
103
                'added:\n',
 
104
                '  bye.c\n',
 
105
                '  hello.c\n'
 
106
            ],
 
107
            wt,
 
108
            revision=revs)
92
109
 
93
110
        self.build_tree(['more.c'])
94
111
        wt.add('more.c')
95
112
        wt.commit('Another test message')
96
113
        
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')
 
114
        revs.append(RevisionSpec.from_string('1'))
 
115
        self.assertStatus([
 
116
                'added:\n',
 
117
                '  bye.c\n',
 
118
                '  hello.c\n',
 
119
            ],
 
120
            wt,
 
121
            revision=revs)
115
122
 
116
123
    def test_pending(self):
117
124
        """Pending merges display works, including Unicode"""
142
149
        wt = self.make_branch_and_tree('.')
143
150
        b = wt.branch
144
151
 
145
 
        ignores._set_user_ignores(['./.bazaar'])
146
 
 
147
152
        self.build_tree(['directory/','directory/hello.c', 'bye.c','test.c','dir2/'])
148
153
        wt.add('directory')
149
154
        wt.add('test.c')
204
209
class TestStatus(TestCaseWithTransport):
205
210
 
206
211
    def test_status(self):
207
 
        ignores._set_user_ignores(['./.bazaar'])
208
 
 
209
212
        self.run_bzr("init")
210
213
        self.build_tree(['hello.txt'])
211
214
        result = self.run_bzr("status")[0]