24
from bzrlib.selftest import InTempDir
24
from bzrlib.selftest import TestCaseInTempDir
25
from bzrlib.revisionspec import RevisionSpec
26
from bzrlib.merge import merge
27
from cStringIO import StringIO
28
from bzrlib.status import show_status
29
from bzrlib.branch import Branch
31
from bzrlib.clone import copy_branch
26
class BranchStatus(InTempDir):
28
"""Basic 'bzr mkdir' operation"""
33
class BranchStatus(TestCaseInTempDir):
35
def test_branch_status(self):
36
"""Test basic branch status"""
29
37
from cStringIO import StringIO
30
38
from bzrlib.status import show_status
31
39
from bzrlib.branch import Branch
33
b = Branch('.', init=True)
41
b = Branch.initialize('.')
35
43
# status with nothing
41
49
self.build_tree(['hello.c', 'bye.c'])
50
b.add_pending_merge('pending@pending-0-0')
42
51
show_status(b, to_file=tof)
44
53
self.assertEquals(tof.readlines(),
58
' pending@pending-0-0\n'
61
def test_branch_status_revisions(self):
62
"""Tests branch status with revisions"""
64
b = Branch.initialize('.')
67
self.build_tree(['hello.c', 'bye.c'])
70
b.commit('Test message')
74
revs.append(RevisionSpec(0))
76
show_status(b, to_file=tof, revision=revs)
79
self.assertEquals(tof.readlines(),
84
self.build_tree(['more.c'])
86
b.commit('Another test message')
89
revs.append(RevisionSpec(1))
91
show_status(b, to_file=tof, revision=revs)
94
self.assertEquals(tof.readlines(),
99
def status_string(self, branch):
101
show_status(branch, to_file=tof)
103
return tof.getvalue()
105
def test_pending(self):
106
"""Pending merges display works"""
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
124
def test_branch_status_specific_files(self):
125
"""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('.')
132
self.build_tree(['directory/','directory/hello.c', 'bye.c','test.c','dir2/'])
138
show_status(b, to_file=tof)
140
self.assertEquals(tof.readlines(),
144
' directory/hello.c\n'
148
show_status(b, specific_files=['bye.c','test.c','absent.c'], to_file=tof)
150
self.assertEquals(tof.readlines(),
156
show_status(b, specific_files=['directory'], to_file=tof)
158
self.assertEquals(tof.readlines(),
160
' directory/hello.c\n'
163
show_status(b, specific_files=['dir2'], to_file=tof)
165
self.assertEquals(tof.readlines(),