1
1
# Copyright (C) 2005, 2006 by Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
11
# GNU General Public License for more details.
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
42
41
class BranchStatus(TestCaseWithTransport):
44
def test_branch_status(self):
43
def assertStatus(self, output_lines, working_tree,
45
"""Run status in working_tree and look for output.
47
:param output_lines: The lines to look for.
48
:param working_tree: The tree to run status in.
50
output_string = self.status_string(working_tree, revision)
51
self.assertEqual(output_lines, output_string.splitlines(True))
53
def status_string(self, wt, revision=None):
54
# use a real file rather than StringIO because it doesn't handle
56
tof = codecs.getwriter('utf-8')(TemporaryFile())
57
show_tree_status(wt, to_file=tof, revision=revision)
59
return tof.read().decode('utf-8')
61
def test_branch_status(self):
45
62
"""Test basic branch status"""
46
63
wt = self.make_branch_and_tree('.')
51
show_tree_status(wt, to_file=tof)
52
self.assertEquals(tof.getvalue(), "")
65
# status with no commits or files - it must
66
# work and show no output. We do this with no
67
# commits to be sure that it's not going to fail
69
self.assertStatus([], wt)
55
71
self.build_tree(['hello.c', 'bye.c'])
56
wt.add_pending_merge('pending@pending-0-0')
57
show_tree_status(wt, to_file=tof)
59
self.assertEquals(tof.readlines(),
64
' pending@pending-0-0\n'
79
# add a commit to allow showing pending merges.
80
wt.commit('create a parent to allow testing merge output')
82
wt.add_parent_tree_id('pending@pending-0-0')
88
' pending@pending-0-0\n',
67
92
def test_branch_status_revisions(self):
68
93
"""Tests branch status with revisions"""
69
94
wt = self.make_branch_and_tree('.')
73
96
self.build_tree(['hello.c', 'bye.c'])
76
99
wt.commit('Test message')
80
revs.append(RevisionSpec(0))
82
show_tree_status(wt, to_file=tof, revision=revs)
85
self.assertEquals(tof.readlines(),
101
revs = [RevisionSpec.from_string('0')]
90
110
self.build_tree(['more.c'])
92
112
wt.commit('Another test message')
95
revs.append(RevisionSpec(1))
97
show_tree_status(wt, to_file=tof, revision=revs)
100
self.assertEquals(tof.readlines(),
105
def status_string(self, wt):
106
# use a real file rather than StringIO because it doesn't handle
108
tof = codecs.getwriter('utf-8')(TemporaryFile())
109
show_tree_status(wt, to_file=tof)
111
return tof.read().decode('utf-8')
114
revs.append(RevisionSpec.from_string('1'))
113
123
def test_pending(self):
114
124
"""Pending merges display works, including Unicode"""