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')
132
143
wt.commit(u"\N{TIBETAN DIGIT TWO} Empty commit 2")
133
144
merge(["./branch", -1], [None, None], this_dir = './copy')
134
145
message = self.status_string(wt2)
135
self.assert_(message.startswith("pending merges:\n"))
136
self.assert_(message.endswith("Empty commit 2\n"))
146
self.assertStartsWith(message, "pending merges:\n")
147
self.assertEndsWith(message, "Empty commit 2\n")
137
148
wt2.commit("merged")
138
149
# must be long to make sure we see elipsis at the end
139
wt.commit("Empty commit 3 " +
140
"blah blah blah blah " * 10)
150
wt.commit("Empty commit 3 " +
151
"blah blah blah blah " * 100)
141
152
merge(["./branch", -1], [None, None], this_dir = './copy')
142
153
message = self.status_string(wt2)
143
self.assert_(message.startswith("pending merges:\n"))
154
self.assertStartsWith(message, "pending merges:\n")
144
155
self.assert_("Empty commit 3" in message)
145
self.assert_(message.endswith("...\n"))
156
self.assertEndsWith(message, "...\n")
147
158
def test_branch_status_specific_files(self):
148
159
"""Tests branch status with given specific files"""
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.assertContainsRe(result, "[?] hello.txt\n")
232
263
self.run_bzr("add", "hello.txt")
233
264
result = self.run_bzr("status")[0]
234
self.assert_("added:\n hello.txt\n" in result, result)
265
self.assertContainsRe(result, "added:\n hello.txt\n")
266
result = self.run_bzr("status","--short")[0]
267
self.assertContainsRe(result, "[+]N hello.txt\n")
235
269
self.run_bzr("commit", "-m", "added")
236
270
result = self.run_bzr("status", "-r", "0..1")[0]
237
self.assert_("added:\n hello.txt\n" in result, result)
271
self.assertContainsRe(result, "added:\n hello.txt\n")
272
result = self.run_bzr("status", "--short", "-r", "0..1")[0]
273
self.assertContainsRe(result, "[+]N hello.txt\n")
238
275
self.build_tree(['world.txt'])
239
276
result = self.run_bzr("status", "-r", "0")[0]
240
self.assert_("added:\n hello.txt\n" \
241
"unknown:\n world.txt\n" in result, result)
277
self.assertContainsRe(result, "added:\n hello.txt\n" \
278
"unknown:\n world.txt\n")
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.assertContainsRe(result, "[+]N hello.txt\n" \
284
result2 = self.run_bzr("status", "--short", "-r", "0..")[0]
285
self.assertEquals(result2, result)
287
def assertStatusContains(self, pattern):
288
"""Run status, and assert it contains the given pattern"""
289
result = self.run_bzr("status", "--short")[0]
290
self.assertContainsRe(result, pattern)
292
def test_kind_change_short(self):
293
tree = self.make_branch_and_tree('.')
294
self.build_tree(['file'])
296
tree.commit('added file')
298
self.build_tree(['file/'])
299
self.assertStatusContains('K file => file/')
300
tree.rename_one('file', 'directory')
301
self.assertStatusContains('RK file => directory/')
303
self.assertStatusContains('RD file => directory')
247
306
class TestStatusEncodings(TestCaseWithTransport):