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.
26
29
from tempfile import TemporaryFile
29
from bzrlib.tests import TestCaseInTempDir
32
from bzrlib.branch import Branch
33
from bzrlib.builtins import merge
30
34
from bzrlib.revisionspec import RevisionSpec
31
from bzrlib.merge import merge
32
35
from bzrlib.status import show_status
33
from bzrlib.branch import Branch
34
from bzrlib.clone import copy_branch
36
class BranchStatus(TestCaseInTempDir):
36
from bzrlib.tests import TestCaseWithTransport
37
from bzrlib.workingtree import WorkingTree
40
class BranchStatus(TestCaseWithTransport):
38
42
def test_branch_status(self):
39
43
"""Test basic branch status"""
40
from bzrlib.status import show_status
41
from bzrlib.branch import Branch
43
b = Branch.initialize(u'.')
44
wt = self.make_branch_and_tree('.')
45
47
# status with nothing
51
53
self.build_tree(['hello.c', 'bye.c'])
52
b.working_tree().add_pending_merge('pending@pending-0-0')
54
wt.add_pending_merge('pending@pending-0-0')
53
55
show_status(b, to_file=tof)
55
57
self.assertEquals(tof.readlines(),
63
65
def test_branch_status_revisions(self):
64
66
"""Tests branch status with revisions"""
66
b = Branch.initialize(u'.')
67
wt = self.make_branch_and_tree('.')
69
71
self.build_tree(['hello.c', 'bye.c'])
70
b.working_tree().add('hello.c')
71
b.working_tree().add('bye.c')
72
b.working_tree().commit('Test message')
74
wt.commit('Test message')
86
88
self.build_tree(['more.c'])
87
b.working_tree().add('more.c')
88
b.working_tree().commit('Another test message')
90
wt.commit('Another test message')
91
93
revs.append(RevisionSpec(1))
109
111
def test_pending(self):
110
112
"""Pending merges display works, including Unicode"""
111
113
mkdir("./branch")
112
b = Branch.initialize('./branch')
113
b.working_tree().commit("Empty commit 1")
114
b_2 = copy_branch(b, './copy')
115
b.working_tree().commit(u"\N{TIBETAN DIGIT TWO} Empty commit 2")
114
wt = self.make_branch_and_tree('branch')
116
wt.commit("Empty commit 1")
117
b_2_dir = b.bzrdir.sprout('./copy')
118
b_2 = b_2_dir.open_branch()
119
wt2 = b_2_dir.open_workingtree()
120
wt.commit(u"\N{TIBETAN DIGIT TWO} Empty commit 2")
116
121
merge(["./branch", -1], [None, None], this_dir = './copy')
117
122
message = self.status_string(b_2)
118
123
self.assert_(message.startswith("pending merges:\n"))
119
124
self.assert_(message.endswith("Empty commit 2\n"))
120
b_2.working_tree().commit("merged")
121
126
# 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)
127
wt.commit("Empty commit 3 " +
128
"blah blah blah blah " * 10)
124
129
merge(["./branch", -1], [None, None], this_dir = './copy')
125
130
message = self.status_string(b_2)
126
131
self.assert_(message.startswith("pending merges:\n"))
130
135
def test_branch_status_specific_files(self):
131
136
"""Tests branch status with given specific files"""
132
from cStringIO import StringIO
133
from bzrlib.status import show_status
134
from bzrlib.branch import Branch
136
b = Branch.initialize(u'.')
137
wt = self.make_branch_and_tree('.')
138
140
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
b.working_tree().commit('testing')
144
146
show_status(b, to_file=tof)