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):
35
38
def test_branch_status(self):
36
39
"""Test basic branch status"""
37
from cStringIO import StringIO
38
40
from bzrlib.status import show_status
39
41
from bzrlib.branch import Branch
41
b = Branch.initialize('.')
43
b = Branch.initialize(u'.')
43
45
# status with nothing
61
63
def test_branch_status_revisions(self):
62
64
"""Tests branch status with revisions"""
64
b = Branch.initialize('.')
66
b = Branch.initialize(u'.')
67
69
self.build_tree(['hello.c', 'bye.c'])
99
101
def status_string(self, branch):
102
# use a real file rather than StringIO because it doesn't handle
104
tof = codecs.getwriter('utf-8')(TemporaryFile())
101
105
show_status(branch, to_file=tof)
103
return tof.getvalue()
107
return tof.read().decode('utf-8')
105
109
def test_pending(self):
106
"""Pending merges display works"""
110
"""Pending merges display works, including Unicode"""
107
111
mkdir("./branch")
108
112
b = Branch.initialize('./branch')
109
113
b.working_tree().commit("Empty commit 1")
110
114
b_2 = copy_branch(b, './copy')
111
b.working_tree().commit("Empty commit 2")
115
b.working_tree().commit(u"\N{TIBETAN DIGIT TWO} Empty commit 2")
112
116
merge(["./branch", -1], [None, None], this_dir = './copy')
113
117
message = self.status_string(b_2)
114
118
self.assert_(message.startswith("pending merges:\n"))
115
119
self.assert_(message.endswith("Empty commit 2\n"))
116
120
b_2.working_tree().commit("merged")
117
121
# 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")
122
b.working_tree().commit("Empty commit 3 " +
123
"blah blah blah blah " * 10)
120
124
merge(["./branch", -1], [None, None], this_dir = './copy')
121
125
message = self.status_string(b_2)
122
126
self.assert_(message.startswith("pending merges:\n"))
129
133
from bzrlib.status import show_status
130
134
from bzrlib.branch import Branch
132
b = Branch.initialize('.')
136
b = Branch.initialize(u'.')
134
138
self.build_tree(['directory/','directory/hello.c', 'bye.c','test.c','dir2/'])
135
139
b.working_tree().add('directory')