24
from cStringIO import StringIO
26
from tempfile import TemporaryFile
29
from bzrlib.tests import TestCaseInTempDir
24
from bzrlib.selftest import TestCaseInTempDir
30
25
from bzrlib.revisionspec import RevisionSpec
31
26
from bzrlib.merge import merge
27
from cStringIO import StringIO
32
28
from bzrlib.status import show_status
33
29
from bzrlib.branch import Branch
34
31
from bzrlib.clone import copy_branch
36
33
class BranchStatus(TestCaseInTempDir):
38
35
def test_branch_status(self):
39
36
"""Test basic branch status"""
37
from cStringIO import StringIO
40
38
from bzrlib.status import show_status
41
39
from bzrlib.branch import Branch
43
b = Branch.initialize(u'.')
41
b = Branch.initialize('.')
45
43
# status with nothing
63
61
def test_branch_status_revisions(self):
64
62
"""Tests branch status with revisions"""
66
b = Branch.initialize(u'.')
64
b = Branch.initialize('.')
69
67
self.build_tree(['hello.c', 'bye.c'])
70
b.working_tree().add('hello.c')
71
b.working_tree().add('bye.c')
72
70
b.working_tree().commit('Test message')
101
99
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())
105
101
show_status(branch, to_file=tof)
107
return tof.read().decode('utf-8')
103
return tof.getvalue()
109
105
def test_pending(self):
110
"""Pending merges display works, including Unicode"""
106
"""Pending merges display works"""
111
107
mkdir("./branch")
112
108
b = Branch.initialize('./branch')
113
109
b.working_tree().commit("Empty commit 1")
114
110
b_2 = copy_branch(b, './copy')
115
b.working_tree().commit(u"\N{TIBETAN DIGIT TWO} Empty commit 2")
111
b.working_tree().commit("Empty commit 2")
116
112
merge(["./branch", -1], [None, None], this_dir = './copy')
117
113
message = self.status_string(b_2)
118
114
self.assert_(message.startswith("pending merges:\n"))
119
115
self.assert_(message.endswith("Empty commit 2\n"))
120
116
b_2.working_tree().commit("merged")
121
117
# must be long to make sure we see elipsis at the end
122
b.working_tree().commit("Empty commit 3 " +
123
"blah blah blah blah " * 10)
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")
124
120
merge(["./branch", -1], [None, None], this_dir = './copy')
125
121
message = self.status_string(b_2)
126
122
self.assert_(message.startswith("pending merges:\n"))
133
129
from bzrlib.status import show_status
134
130
from bzrlib.branch import Branch
136
b = Branch.initialize(u'.')
132
b = Branch.initialize('.')
138
134
self.build_tree(['directory/','directory/hello.c', 'bye.c','test.c','dir2/'])
139
b.working_tree().add('directory')
140
b.working_tree().add('test.c')
141
137
b.working_tree().commit('testing')