1
# Copyright (C) 2006 by Canonical Ltd
2
# -*- coding: utf-8 -*-
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
"""Tests for the info command of bzr."""
22
from bzrlib.osutils import format_date
23
from bzrlib.tests import TestSkipped
24
from bzrlib.tests.blackbox import ExternalBase
27
class TestInfo(ExternalBase):
29
def test_info_standalone_trivial(self):
31
out, err = self.runbzr('info')
33
"""branch format: Bazaar-NG branch, format 6
43
0 versioned subdirectories
54
self.assertEqual('', err)
56
def test_info_up_to_date_checkout(self):
57
a_branch = self.make_branch_and_tree('branch')
58
self.runbzr('checkout branch checkout')
59
out, err = self.runbzr('info checkout')
61
"""branch format: Bazaar-NG Metadir branch format 5
72
0 versioned subdirectories
81
""" % a_branch.bzrdir.root_transport.base,
83
self.assertEqual('', err)
85
def test_info_up_to_date_light_checkout(self):
86
a_branch = self.make_branch_and_tree('branch')
87
self.runbzr('checkout --lightweight branch checkout')
88
out, err = self.runbzr('info checkout')
90
"""working tree format: Bazaar-NG Working Tree format 3
92
branch format: Bazaar-NG branch, format 6
102
0 versioned subdirectories
111
""" % a_branch.bzrdir.root_transport.base,
113
self.assertEqual('', err)
115
def test_info_out_of_date_standalone_tree(self):
116
# FIXME the default format has to change for this to pass
117
# because it currently uses the branch last-revision marker.
118
raise TestSkipped('default format too old')
119
self.make_branch_and_tree('branch')
121
self.runbzr('checkout branch checkout')
122
self.build_tree(['checkout/file'])
123
self.runbzr('add checkout/file')
124
self.runbzr('commit -m add-file checkout')
125
# now branch should be out of date
126
out,err = self.runbzr('update branch')
127
self.assertEqualDiff(
128
"""branch format: Bazaar-NG branch, format 6
130
Working tree is out of date: missing 1 revision.
139
0 versioned subdirectories
148
""" % a_branch.bzrdir.root_transport.base,
150
self.assertEqual('', err)
152
def test_info_out_of_date_checkout(self):
153
# note this deliberately uses a checkout at 'None' to
154
# test the out of date message with a revision notin the
156
a_branch = self.make_branch('branch')
158
self.runbzr('checkout branch checkout')
159
self.runbzr('checkout branch checkout2')
160
self.build_tree(['checkout/file'])
161
self.runbzr('add checkout/file')
162
self.runbzr('commit -m add-file checkout')
163
# now checkout2 should be out of date
164
out,err = self.runbzr('info checkout2')
165
rev = a_branch.repository.get_revision(a_branch.revision_history()[0])
166
datestring = format_date(rev.timestamp, rev.timezone)
167
self.assertEqualDiff(
168
"""branch format: Bazaar-NG Metadir branch format 5
171
Branch is out of date: missing 1 revision.
180
0 versioned subdirectories
189
""" % (a_branch.bzrdir.root_transport.base,
192
self.assertEqual('', err)
194
def test_info_out_of_date_light_checkout(self):
195
# note this deliberately uses a checkout at 'None' to
196
# test the out of date message with a revision notin the
198
a_branch = self.make_branch('branch')
200
self.runbzr('checkout --lightweight branch checkout')
201
self.runbzr('checkout --lightweight branch checkout2')
202
self.build_tree(['checkout/file'])
203
self.runbzr('add checkout/file')
204
self.runbzr('commit -m add-file checkout')
205
# now checkout2 should be out of date
206
out,err = self.runbzr('info checkout2')
207
rev = a_branch.repository.get_revision(a_branch.revision_history()[0])
208
datestring = format_date(rev.timestamp, rev.timezone)
209
self.assertEqualDiff(
210
"""working tree format: Bazaar-NG Working Tree format 3
212
branch format: Bazaar-NG branch, format 6
214
Working tree is out of date: missing 1 revision.
223
0 versioned subdirectories
235
""" % (a_branch.bzrdir.root_transport.base,
240
self.assertEqual('', err)
242
def test_info_parent(self):
243
b = self.make_branch('.')
244
url = 'http://bazaar-vcs.org/bzr/bzr.dev/'
246
out,err = self.runbzr('info')
247
self.assertEqualDiff(
248
"""branch format: Bazaar-NG branch, format 6
258
0 versioned subdirectories
269
http://bazaar-vcs.org/bzr/bzr.dev/
271
self.assertEqual('', err)