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
32
35
class BranchStatus(TestCaseInTempDir):
34
37
def test_branch_status(self):
35
38
"""Test basic branch status"""
36
from cStringIO import StringIO
37
39
from bzrlib.status import show_status
38
40
from bzrlib.branch import Branch
40
b = Branch.initialize('.')
42
b = Branch.initialize(u'.')
42
44
# status with nothing
60
62
def test_branch_status_revisions(self):
61
63
"""Tests branch status with revisions"""
63
b = Branch.initialize('.')
65
b = Branch.initialize(u'.')
66
68
self.build_tree(['hello.c', 'bye.c'])
98
100
def status_string(self, branch):
101
# use a real file rather than StringIO because it doesn't handle
103
tof = codecs.getwriter('utf-8')(TemporaryFile())
100
104
show_status(branch, to_file=tof)
102
return tof.getvalue()
106
return tof.read().decode('utf-8')
104
108
def test_pending(self):
105
"""Pending merges display works"""
109
"""Pending merges display works, including Unicode"""
106
110
mkdir("./branch")
107
111
b = Branch.initialize('./branch')
108
112
b.working_tree().commit("Empty commit 1")
109
113
b_2 = b.clone('./copy')
110
b.working_tree().commit("Empty commit 2")
114
b.working_tree().commit(u"\N{TIBETAN DIGIT TWO} Empty commit 2")
111
115
merge(["./branch", -1], [None, None], this_dir = './copy')
112
116
message = self.status_string(b_2)
113
117
self.assert_(message.startswith("pending merges:\n"))
114
118
self.assert_(message.endswith("Empty commit 2\n"))
115
119
b_2.working_tree().commit("merged")
116
120
# must be long to make sure we see elipsis at the end
117
b.working_tree().commit("Empty commit 3 blah blah blah blah blah blah blah blah blah"
118
" blah blah blah blah blah blah bleh")
121
b.working_tree().commit("Empty commit 3 " +
122
"blah blah blah blah " * 10)
119
123
merge(["./branch", -1], [None, None], this_dir = './copy')
120
124
message = self.status_string(b_2)
121
125
self.assert_(message.startswith("pending merges:\n"))
128
132
from bzrlib.status import show_status
129
133
from bzrlib.branch import Branch
131
b = Branch.initialize('.')
135
b = Branch.initialize(u'.')
133
137
self.build_tree(['directory/','directory/hello.c', 'bye.c','test.c','dir2/'])
134
138
b.working_tree().add('directory')