24
from cStringIO import StringIO
26
from tempfile import TemporaryFile
24
29
from bzrlib.tests import TestCaseInTempDir
25
30
from bzrlib.revisionspec import RevisionSpec
26
31
from bzrlib.merge import merge
27
from cStringIO import StringIO
28
32
from bzrlib.status import show_status
29
33
from bzrlib.branch import Branch
31
34
from bzrlib.clone import copy_branch
33
36
class BranchStatus(TestCaseInTempDir):
99
102
def status_string(self, branch):
103
# use a real file rather than StringIO because it doesn't handle
105
tof = codecs.getwriter('utf-8')(TemporaryFile())
101
106
show_status(branch, to_file=tof)
103
return tof.getvalue()
108
return tof.read().decode('utf-8')
105
110
def test_pending(self):
106
"""Pending merges display works"""
111
"""Pending merges display works, including Unicode"""
107
112
mkdir("./branch")
108
113
b = Branch.initialize('./branch')
109
114
b.working_tree().commit("Empty commit 1")
110
115
b_2 = copy_branch(b, './copy')
111
b.working_tree().commit("Empty commit 2")
116
b.working_tree().commit(u"\N{TIBETAN DIGIT TWO} Empty commit 2")
112
117
merge(["./branch", -1], [None, None], this_dir = './copy')
113
118
message = self.status_string(b_2)
114
119
self.assert_(message.startswith("pending merges:\n"))
115
120
self.assert_(message.endswith("Empty commit 2\n"))
116
121
b_2.working_tree().commit("merged")
117
122
# must be long to make sure we see elipsis at the end
118
b.working_tree().commit("Empty commit 3 blah blah blah blah blah blah blah blah blah"
119
" blah blah blah blah blah blah bleh")
123
b.working_tree().commit("Empty commit 3 " +
124
"blah blah blah blah " * 10)
120
125
merge(["./branch", -1], [None, None], this_dir = './copy')
121
126
message = self.status_string(b_2)
122
127
self.assert_(message.startswith("pending merges:\n"))