~bzr-pqm/bzr/bzr.dev

1534.5.1 by Robert Collins
Give info some reasonable output and tests.
1
# Copyright (C) 2006 by Canonical Ltd
2
# -*- coding: utf-8 -*-
3
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.
8
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.
13
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
17
18
19
"""Tests for the info command of bzr."""
20
21
22
from bzrlib.osutils import format_date
23
from bzrlib.tests import TestSkipped
24
from bzrlib.tests.blackbox import ExternalBase
25
26
27
class TestInfo(ExternalBase):
28
29
    def test_info_standalone_trivial(self):
30
        self.runbzr("init")
31
        out, err = self.runbzr('info')
32
        self.assertEqualDiff(
33
"""branch format: Bazaar-NG branch, format 6
34
35
in the working tree:
36
         0 unchanged
37
         0 modified
38
         0 added
39
         0 removed
40
         0 renamed
41
         0 unknown
42
         0 ignored
43
         0 versioned subdirectories
44
45
branch history:
46
         0 revisions
47
         0 committers
48
49
revision store:
50
         0 revisions
51
         0 kB
52
""",
53
        out)
54
        self.assertEqual('', err)
55
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')
60
        self.assertEqualDiff(
1587.1.14 by Robert Collins
Make bound branch creation happen via 'checkout'
61
"""branch format: Bazaar-NG Metadir branch format 5
62
bound to branch: %s
63
64
in the working tree:
65
         0 unchanged
66
         0 modified
67
         0 added
68
         0 removed
69
         0 renamed
70
         0 unknown
71
         0 ignored
72
         0 versioned subdirectories
73
74
branch history:
75
         0 revisions
76
         0 committers
77
78
revision store:
79
         0 revisions
80
         0 kB
81
""" % a_branch.bzrdir.root_transport.base,
82
        out)
83
        self.assertEqual('', err)
84
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')
89
        self.assertEqualDiff(
1534.5.1 by Robert Collins
Give info some reasonable output and tests.
90
"""working tree format: Bazaar-NG Working Tree format 3
91
branch location: %s
92
branch format: Bazaar-NG branch, format 6
93
94
in the working tree:
95
         0 unchanged
96
         0 modified
97
         0 added
98
         0 removed
99
         0 renamed
100
         0 unknown
101
         0 ignored
102
         0 versioned subdirectories
103
104
branch history:
105
         0 revisions
106
         0 committers
107
108
revision store:
109
         0 revisions
110
         0 kB
111
""" % a_branch.bzrdir.root_transport.base,
112
        out)
113
        self.assertEqual('', err)
114
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')
120
        # make a checkout
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
129
130
Working tree is out of date: missing 1 revision.
131
in the working tree:
132
         0 unchanged
133
         0 modified
134
         0 added
135
         0 removed
136
         0 renamed
137
         0 unknown
138
         0 ignored
139
         0 versioned subdirectories
140
141
branch history:
142
         0 revisions
143
         0 committers
144
145
revision store:
146
         0 revisions
147
         0 kB
148
""" % a_branch.bzrdir.root_transport.base,
149
        out)
150
        self.assertEqual('', err)
151
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 
155
        # revision history.
156
        a_branch = self.make_branch('branch')
157
        # make two checkouts
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(
1587.1.14 by Robert Collins
Make bound branch creation happen via 'checkout'
168
"""branch format: Bazaar-NG Metadir branch format 5
169
bound to branch: %s
170
171
Branch is out of date: missing 1 revision.
172
in the working tree:
173
         0 unchanged
174
         0 modified
175
         0 added
176
         0 removed
177
         0 renamed
178
         0 unknown
179
         0 ignored
180
         0 versioned subdirectories
181
182
branch history:
183
         0 revisions
184
         0 committers
185
186
revision store:
187
         0 revisions
188
         0 kB
189
""" % (a_branch.bzrdir.root_transport.base,
190
       ),
191
            out)
192
        self.assertEqual('', err)
193
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 
197
        # revision history.
198
        a_branch = self.make_branch('branch')
199
        # make two checkouts
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(
1534.5.1 by Robert Collins
Give info some reasonable output and tests.
210
"""working tree format: Bazaar-NG Working Tree format 3
211
branch location: %s
212
branch format: Bazaar-NG branch, format 6
213
214
Working tree is out of date: missing 1 revision.
215
in the working tree:
216
         0 unchanged
217
         0 modified
218
         0 added
219
         0 removed
220
         0 renamed
221
         0 unknown
222
         0 ignored
223
         0 versioned subdirectories
224
225
branch history:
226
         1 revision
227
         1 committer
228
         0 days old
229
   first revision: %s
230
  latest revision: %s
231
232
revision store:
233
         1 revision
234
         0 kB
235
""" % (a_branch.bzrdir.root_transport.base,
236
       datestring,
237
       datestring,
238
       ),
239
            out)
240
        self.assertEqual('', err)
1611.1.1 by Olaf Conradi
Add parent location to info command (Closes feature bug #33364).
241
242
    def test_info_parent(self):
243
        b = self.make_branch('.')
244
        url = 'http://bazaar-vcs.org/bzr/bzr.dev/'
245
        b.set_parent(url)
246
        out,err = self.runbzr('info')
247
        self.assertEqualDiff(
248
"""branch format: Bazaar-NG branch, format 6
249
250
in the working tree:
251
         0 unchanged
252
         0 modified
253
         0 added
254
         0 removed
255
         0 renamed
256
         0 unknown
257
         0 ignored
258
         0 versioned subdirectories
259
260
branch history:
261
         0 revisions
262
         0 committers
263
264
revision store:
265
         0 revisions
266
         0 kB
267
268
parent location:
269
  http://bazaar-vcs.org/bzr/bzr.dev/
270
""", out)
271
        self.assertEqual('', err)
272