41
41
class BranchStatus(TestCaseWithTransport):
43
43
def assertStatus(self, output_lines, working_tree,
44
revision=None, short=False):
45
45
"""Run status in working_tree and look for output.
47
47
:param output_lines: The lines to look for.
48
48
:param working_tree: The tree to run status in.
50
output_string = self.status_string(working_tree, revision)
50
output_string = self.status_string(working_tree, revision, short)
51
51
self.assertEqual(output_lines, output_string.splitlines(True))
53
def status_string(self, wt, revision=None):
53
def status_string(self, wt, revision=None, short=False):
54
54
# use a real file rather than StringIO because it doesn't handle
55
55
# Unicode very well.
56
56
tof = codecs.getwriter('utf-8')(TemporaryFile())
57
show_tree_status(wt, to_file=tof, revision=revision)
57
show_tree_status(wt, to_file=tof, revision=revision, short=short)
59
59
return tof.read().decode('utf-8')
88
93
' pending@pending-0-0\n',
99
'P pending@pending-0-0\n',
92
103
def test_branch_status_revisions(self):
93
104
"""Tests branch status with revisions"""
155
166
wt.commit('testing')
172
' directory/hello.c\n'
179
'? directory/hello.c\n'
158
show_tree_status(wt, to_file=tof)
160
self.assertEquals(tof.readlines(),
164
' directory/hello.c\n'
167
184
self.assertRaises(errors.PathsDoNotExist,
168
185
show_tree_status,
169
186
wt, specific_files=['bye.c','test.c','absent.c'],
177
194
' directory/hello.c\n'
197
show_tree_status(wt, specific_files=['directory'], to_file=tof,
200
self.assertEquals(tof.readlines(), ['? directory/hello.c\n'])
180
203
show_tree_status(wt, specific_files=['dir2'], to_file=tof)
182
205
self.assertEquals(tof.readlines(),
210
show_tree_status(wt, specific_files=['dir2'], to_file=tof, short=True)
212
self.assertEquals(tof.readlines(), ['? dir2\n'])
187
214
def test_status_nonexistent_file(self):
188
215
# files that don't exist in either the basis tree or working tree
227
254
def test_status(self):
228
255
self.run_bzr("init")
229
257
self.build_tree(['hello.txt'])
230
258
result = self.run_bzr("status")[0]
231
259
self.assert_("unknown:\n hello.txt\n" in result, result)
260
result = self.run_bzr("status","--short")[0]
261
self.assert_("? hello.txt\n" in result, result)
232
263
self.run_bzr("add", "hello.txt")
233
264
result = self.run_bzr("status")[0]
234
265
self.assert_("added:\n hello.txt\n" in result, result)
266
result = self.run_bzr("status","--short")[0]
267
self.assert_("A hello.txt\n" in result, result)
235
269
self.run_bzr("commit", "-m", "added")
236
270
result = self.run_bzr("status", "-r", "0..1")[0]
237
271
self.assert_("added:\n hello.txt\n" in result, result)
272
result = self.run_bzr("status", "--short", "-r", "0..1")[0]
273
self.assert_("A hello.txt\n" in result, result)
238
275
self.build_tree(['world.txt'])
239
276
result = self.run_bzr("status", "-r", "0")[0]
240
277
self.assert_("added:\n hello.txt\n" \
241
278
"unknown:\n world.txt\n" in result, result)
243
279
result2 = self.run_bzr("status", "-r", "0..")[0]
244
280
self.assertEquals(result2, result)
281
result = self.run_bzr("status", "--short", "-r", "0")[0]
282
self.assert_("A hello.txt\n" \
283
"? world.txt\n" in result, result)
284
result2 = self.run_bzr("status", "--short", "-r", "0..")[0]
285
self.assertEquals(result2, result)
247
288
class TestStatusEncodings(TestCaseWithTransport):