18
18
"""Tests of status command.
20
20
Most of these depend on the particular formatting used.
21
As such they really are blackbox tests even though some of the
22
tests are not using self.capture. If we add tests for the programmatic
23
interface later, they will be non blackbox tests.
24
from bzrlib.selftest import TestCaseInTempDir
25
from bzrlib.revisionspec import RevisionSpec
26
from bzrlib.merge import merge
27
27
from cStringIO import StringIO
28
from bzrlib.status import show_status
29
from bzrlib.branch import Branch
30
28
from os import mkdir
29
from tempfile import TemporaryFile
31
32
from bzrlib.clone import copy_branch
33
from bzrlib.branch import Branch
34
from bzrlib.builtins import merge
35
from bzrlib.revisionspec import RevisionSpec
36
from bzrlib.status import show_status
37
from bzrlib.tests import TestCaseInTempDir
38
from bzrlib.workingtree import WorkingTree
33
41
class BranchStatus(TestCaseInTempDir):
35
43
def test_branch_status(self):
36
44
"""Test basic branch status"""
37
from cStringIO import StringIO
38
from bzrlib.status import show_status
39
from bzrlib.branch import Branch
41
b = Branch.initialize('.')
45
wt = WorkingTree.create_standalone('.')
43
48
# status with nothing
99
104
def status_string(self, branch):
105
# use a real file rather than StringIO because it doesn't handle
107
tof = codecs.getwriter('utf-8')(TemporaryFile())
101
108
show_status(branch, to_file=tof)
103
return tof.getvalue()
110
return tof.read().decode('utf-8')
105
112
def test_pending(self):
106
"""Pending merges display works"""
113
"""Pending merges display works, including Unicode"""
107
114
mkdir("./branch")
108
b = Branch.initialize('./branch')
109
b.commit("Empty commit 1")
110
b_2 = copy_branch(b, './copy')
111
b.commit("Empty commit 2")
112
merge(["./branch", -1], [None, None], this_dir = './copy')
113
message = self.status_string(b_2)
114
assert (message.startswith("pending merges:\n")), message
115
assert (message.endswith("Empty commit 2\n")), message
117
b.commit("Empty commit 3 blah blah blah blah blah blah blah blah blah")
118
merge(["./branch", -1], [None, None], this_dir = './copy')
119
message = self.status_string(b_2)
120
assert (message.startswith("pending merges:\n")), message
121
assert ("Empty commit 3" in message), message
122
assert (message.endswith("...\n")), message
115
wt = WorkingTree.create_standalone('branch')
117
wt.commit("Empty commit 1")
118
b_2 = b.clone('./copy')
119
wt2 = WorkingTree('copy', b_2)
120
wt.commit(u"\N{TIBETAN DIGIT TWO} Empty commit 2")
121
merge(["./branch", -1], [None, None], this_dir = './copy')
122
message = self.status_string(b_2)
123
self.assert_(message.startswith("pending merges:\n"))
124
self.assert_(message.endswith("Empty commit 2\n"))
126
# must be long to make sure we see elipsis at the end
127
wt.commit("Empty commit 3 " +
128
"blah blah blah blah " * 10)
129
merge(["./branch", -1], [None, None], this_dir = './copy')
130
message = self.status_string(b_2)
131
self.assert_(message.startswith("pending merges:\n"))
132
self.assert_("Empty commit 3" in message)
133
self.assert_(message.endswith("...\n"))
124
135
def test_branch_status_specific_files(self):
125
136
"""Tests branch status with given specific files"""
126
from cStringIO import StringIO
127
from bzrlib.status import show_status
128
from bzrlib.branch import Branch
130
b = Branch.initialize('.')
137
wt = WorkingTree.create_standalone('.')
132
140
self.build_tree(['directory/','directory/hello.c', 'bye.c','test.c','dir2/'])
138
146
show_status(b, to_file=tof)