~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

MergeĀ fromĀ mainline

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
 
27
27
from cStringIO import StringIO
28
 
from os import mkdir
 
28
from os import mkdir, chdir
29
29
from tempfile import TemporaryFile
30
30
import codecs
31
31
 
 
32
import bzrlib.branch
32
33
from bzrlib.builtins import merge
 
34
import bzrlib.bzrdir as bzrdir
 
35
from bzrlib.osutils import pathjoin
33
36
from bzrlib.revisionspec import RevisionSpec
34
 
from bzrlib.status import show_status
 
37
from bzrlib.status import show_tree_status
35
38
from bzrlib.tests import TestCaseWithTransport
36
39
from bzrlib.workingtree import WorkingTree
37
40
 
45
48
 
46
49
        # status with nothing
47
50
        tof = StringIO()
48
 
        show_status(b, to_file=tof)
 
51
        show_tree_status(wt, to_file=tof)
49
52
        self.assertEquals(tof.getvalue(), "")
50
53
 
51
54
        tof = StringIO()
52
55
        self.build_tree(['hello.c', 'bye.c'])
53
56
        wt.add_pending_merge('pending@pending-0-0')
54
 
        show_status(b, to_file=tof)
 
57
        show_tree_status(wt, to_file=tof)
55
58
        tof.seek(0)
56
59
        self.assertEquals(tof.readlines(),
57
60
                          ['unknown:\n',
76
79
        revs =[]
77
80
        revs.append(RevisionSpec(0))
78
81
        
79
 
        show_status(b, to_file=tof, revision=revs)
 
82
        show_tree_status(wt, to_file=tof, revision=revs)
80
83
        
81
84
        tof.seek(0)
82
85
        self.assertEquals(tof.readlines(),
91
94
        tof = StringIO()
92
95
        revs.append(RevisionSpec(1))
93
96
        
94
 
        show_status(b, to_file=tof, revision=revs)
 
97
        show_tree_status(wt, to_file=tof, revision=revs)
95
98
        
96
99
        tof.seek(0)
97
100
        self.assertEquals(tof.readlines(),
99
102
                           '  bye.c\n',
100
103
                           '  hello.c\n'])
101
104
 
102
 
    def status_string(self, branch):
 
105
    def status_string(self, wt):
103
106
        # use a real file rather than StringIO because it doesn't handle
104
107
        # Unicode very well.
105
108
        tof = codecs.getwriter('utf-8')(TemporaryFile())
106
 
        show_status(branch, to_file=tof)
 
109
        show_tree_status(wt, to_file=tof)
107
110
        tof.seek(0)
108
111
        return tof.read().decode('utf-8')
109
112
 
118
121
        wt2 = b_2_dir.open_workingtree()
119
122
        wt.commit(u"\N{TIBETAN DIGIT TWO} Empty commit 2")
120
123
        merge(["./branch", -1], [None, None], this_dir = './copy')
121
 
        message = self.status_string(b_2)
 
124
        message = self.status_string(wt2)
122
125
        self.assert_(message.startswith("pending merges:\n"))
123
126
        self.assert_(message.endswith("Empty commit 2\n")) 
124
127
        wt2.commit("merged")
126
129
        wt.commit("Empty commit 3 " + 
127
130
                   "blah blah blah blah " * 10)
128
131
        merge(["./branch", -1], [None, None], this_dir = './copy')
129
 
        message = self.status_string(b_2)
 
132
        message = self.status_string(wt2)
130
133
        self.assert_(message.startswith("pending merges:\n"))
131
134
        self.assert_("Empty commit 3" in message)
132
135
        self.assert_(message.endswith("...\n")) 
142
145
        wt.commit('testing')
143
146
        
144
147
        tof = StringIO()
145
 
        show_status(b, to_file=tof)
 
148
        show_tree_status(wt, to_file=tof)
146
149
        tof.seek(0)
147
150
        self.assertEquals(tof.readlines(),
148
151
                          ['unknown:\n',
152
155
                           ])
153
156
 
154
157
        tof = StringIO()
155
 
        show_status(b, specific_files=['bye.c','test.c','absent.c'], to_file=tof)
 
158
        show_tree_status(wt, specific_files=['bye.c','test.c','absent.c'], 
 
159
                         to_file=tof)
156
160
        tof.seek(0)
157
161
        self.assertEquals(tof.readlines(),
158
162
                          ['unknown:\n',
160
164
                           ])
161
165
        
162
166
        tof = StringIO()
163
 
        show_status(b, specific_files=['directory'], to_file=tof)
 
167
        show_tree_status(wt, specific_files=['directory'], to_file=tof)
164
168
        tof.seek(0)
165
169
        self.assertEquals(tof.readlines(),
166
170
                          ['unknown:\n',
167
171
                           '  directory/hello.c\n'
168
172
                           ])
169
173
        tof = StringIO()
170
 
        show_status(b, specific_files=['dir2'], to_file=tof)
 
174
        show_tree_status(wt, specific_files=['dir2'], to_file=tof)
171
175
        tof.seek(0)
172
176
        self.assertEquals(tof.readlines(),
173
177
                          ['unknown:\n',
174
178
                           '  dir2\n'
175
179
                           ])
176
180
 
 
181
class CheckoutStatus(BranchStatus):
 
182
 
 
183
    def setUp(self):
 
184
        super(CheckoutStatus, self).setUp()
 
185
        mkdir('codir')
 
186
        chdir('codir')
 
187
        
 
188
    def make_branch_and_tree(self, relpath):
 
189
        source = self.make_branch(pathjoin('..', relpath))
 
190
        checkout = bzrdir.BzrDirMetaFormat1().initialize(relpath)
 
191
        bzrlib.branch.BranchReferenceFormat().initialize(checkout, source)
 
192
        return checkout.create_workingtree()
 
193
 
177
194
 
178
195
class TestStatus(TestCaseWithTransport):
179
196