~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
1769.2.1 by Alexander Belchenko
win32 fix for blackbox.test_info.TestInfo.test_info_non_existing
21
import sys
1534.5.1 by Robert Collins
Give info some reasonable output and tests.
22
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
23
import bzrlib
1534.5.1 by Robert Collins
Give info some reasonable output and tests.
24
from bzrlib.osutils import format_date
25
from bzrlib.tests import TestSkipped
26
from bzrlib.tests.blackbox import ExternalBase
27
28
29
class TestInfo(ExternalBase):
30
1694.2.6 by Martin Pool
[merge] bzr.dev
31
    def test_info_non_existing(self):
1769.2.1 by Alexander Belchenko
win32 fix for blackbox.test_info.TestInfo.test_info_non_existing
32
        if sys.platform == "win32":
33
            location = "C:/i/do/not/exist/"
34
        else:
35
            location = "/i/do/not/exist/"
36
        out, err = self.runbzr('info '+location, retcode=3)
1694.2.6 by Martin Pool
[merge] bzr.dev
37
        self.assertEqual(out, '')
1769.2.1 by Alexander Belchenko
win32 fix for blackbox.test_info.TestInfo.test_info_non_existing
38
        self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
1694.2.6 by Martin Pool
[merge] bzr.dev
39
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
40
    def test_info_standalone(self):
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
41
        transport = self.get_transport()
42
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
43
        # Create initial standalone branch
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
44
        old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
45
        bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirFormat6())
46
        tree1 = self.make_branch_and_tree('standalone')
47
        bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
48
        self.build_tree(['standalone/a'])
49
        tree1.add('a')
50
        branch1 = tree1.branch
51
        out, err = self.runbzr('info standalone')
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
52
        self.assertEqualDiff(
53
"""Location:
1694.2.6 by Martin Pool
[merge] bzr.dev
54
  branch root: %s
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
55
56
Format:
1624.3.19 by Olaf Conradi
New call get_format_description to give a user-friendly description of a
57
       control: All-in-one format 6
58
  working tree: Working tree format 2
59
        branch: Branch format 4
60
    repository: Weave repository format 6
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
61
62
In the working tree:
63
         0 unchanged
64
         0 modified
65
         1 added
66
         0 removed
67
         0 renamed
68
         0 unknown
69
         0 ignored
70
         0 versioned subdirectories
71
72
Branch history:
73
         0 revisions
74
75
Revision store:
76
         0 revisions
1624.3.14 by Olaf Conradi
Move to using kibi for binary prefix as per standard IEEE 1541.
77
         0 KiB
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
78
""" % branch1.bzrdir.root_transport.base, out)
79
        self.assertEqual('', err)
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
80
        tree1.commit('commit one')
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
81
        rev = branch1.repository.get_revision(branch1.revision_history()[0])
82
        datestring_first = format_date(rev.timestamp, rev.timezone)
83
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
84
        # Branch standalone with push location
85
        branch2 = branch1.bzrdir.sprout('branch').open_branch()
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
86
        branch2.set_push_location(branch1.bzrdir.root_transport.base)
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
87
        out, err = self.runbzr('info branch --verbose')
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
88
        self.assertEqualDiff(
89
"""Location:
1694.2.6 by Martin Pool
[merge] bzr.dev
90
  branch root: %s
91
92
Related branches:
93
      parent branch: %s
94
  publish to branch: %s
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
95
96
Format:
1624.3.19 by Olaf Conradi
New call get_format_description to give a user-friendly description of a
97
       control: All-in-one format 6
98
  working tree: Working tree format 2
99
        branch: Branch format 4
100
    repository: Weave repository format 6
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
101
102
In the working tree:
103
         1 unchanged
104
         0 modified
105
         0 added
106
         0 removed
107
         0 renamed
108
         0 unknown
109
         0 ignored
110
         0 versioned subdirectories
111
112
Branch history:
113
         1 revision
114
         1 committer
115
         0 days old
116
   first revision: %s
117
  latest revision: %s
118
119
Revision store:
120
         1 revision
1694.2.6 by Martin Pool
[merge] bzr.dev
121
         %d KiB
122
""" % (branch2.bzrdir.root_transport.base,
123
       branch1.bzrdir.root_transport.base,
124
       branch1.bzrdir.root_transport.base,
125
       datestring_first, datestring_first,
126
       # poking at _revision_store isn't all that clean, but neither is
127
       # having the ui test dependent on the exact overhead of a given store.
128
       branch2.repository._revision_store.total_size(
129
        branch2.repository.get_transaction())[1] / 1024,
130
       ), out)
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
131
        self.assertEqual('', err)
132
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
133
        # Branch and bind to standalone, needs upgrade to metadir
134
        # (creates backup as unknown)
1624.3.47 by Olaf Conradi
Fix test case for bzr info in upgrading a standalone branch to metadir,
135
        branch1.bzrdir.sprout('bound')
136
        bzrlib.upgrade.upgrade('bound', bzrlib.bzrdir.BzrDirMetaFormat1())
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
137
        branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
138
        branch3.bind(branch1)
1780.1.2 by Robert Collins
(robertc)Partial refactoring of info tests to be more robust to format changes.
139
        bound_tree = branch3.bzrdir.open_workingtree()
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
140
        out, err = self.runbzr('info bound')
141
        self.assertEqualDiff(
142
"""Location:
1694.2.6 by Martin Pool
[merge] bzr.dev
143
       checkout root: %s
144
  checkout of branch: %s
145
146
Related branches:
147
  parent branch: %s
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
148
149
Format:
1624.3.19 by Olaf Conradi
New call get_format_description to give a user-friendly description of a
150
       control: Meta directory format 1
1780.1.2 by Robert Collins
(robertc)Partial refactoring of info tests to be more robust to format changes.
151
  working tree: %s
1624.3.19 by Olaf Conradi
New call get_format_description to give a user-friendly description of a
152
        branch: Branch format 5
1666.1.6 by Robert Collins
Make knit the default format.
153
    repository: %s
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
154
155
In the working tree:
156
         1 unchanged
157
         0 modified
158
         0 added
159
         0 removed
160
         0 renamed
161
         1 unknown
162
         0 ignored
163
         0 versioned subdirectories
164
165
Branch history:
166
         1 revision
167
         0 days old
168
   first revision: %s
169
  latest revision: %s
170
171
Revision store:
172
         1 revision
1666.1.6 by Robert Collins
Make knit the default format.
173
         %d KiB
1694.2.6 by Martin Pool
[merge] bzr.dev
174
""" % (branch3.bzrdir.root_transport.base,
175
       branch1.bzrdir.root_transport.base,
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
176
       branch1.bzrdir.root_transport.base,
1780.1.2 by Robert Collins
(robertc)Partial refactoring of info tests to be more robust to format changes.
177
       bound_tree._format.get_format_description(),      
1666.1.6 by Robert Collins
Make knit the default format.
178
       branch3.repository._format.get_format_description(),
179
       datestring_first, datestring_first,
180
       # poking at _revision_store isn't all that clean, but neither is
181
       # having the ui test dependent on the exact overhead of a given store.
182
       branch3.repository._revision_store.total_size(
183
        branch3.repository.get_transaction())[1] / 1024,
184
       ), out)
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
185
        self.assertEqual('', err)
186
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
187
        # Checkout standalone (same as above, but does not have parent set)
188
        old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
189
        bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
190
        branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout')
191
        bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
192
        branch4.bind(branch1)
193
        branch4.bzrdir.open_workingtree().update()
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
194
        out, err = self.runbzr('info checkout --verbose')
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
195
        self.assertEqualDiff(
196
"""Location:
1694.2.6 by Martin Pool
[merge] bzr.dev
197
       checkout root: %s
198
  checkout of branch: %s
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
199
200
Format:
1624.3.19 by Olaf Conradi
New call get_format_description to give a user-friendly description of a
201
       control: Meta directory format 1
202
  working tree: Working tree format 3
203
        branch: Branch format 5
1666.1.6 by Robert Collins
Make knit the default format.
204
    repository: %s
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
205
206
In the working tree:
207
         1 unchanged
208
         0 modified
209
         0 added
210
         0 removed
211
         0 renamed
212
         0 unknown
213
         0 ignored
214
         0 versioned subdirectories
215
216
Branch history:
217
         1 revision
218
         1 committer
219
         0 days old
220
   first revision: %s
221
  latest revision: %s
222
223
Revision store:
224
         1 revision
1666.1.6 by Robert Collins
Make knit the default format.
225
         %d KiB
1694.2.6 by Martin Pool
[merge] bzr.dev
226
""" % (branch4.bzrdir.root_transport.base,
227
       branch1.bzrdir.root_transport.base,
1666.1.6 by Robert Collins
Make knit the default format.
228
       branch4.repository._format.get_format_description(),
229
       datestring_first, datestring_first,
230
       # poking at _revision_store isn't all that clean, but neither is
231
       # having the ui test dependent on the exact overhead of a given store.
232
       branch4.repository._revision_store.total_size(
233
        branch4.repository.get_transaction())[1] / 1024,
234
       ), out)
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
235
        self.assertEqual('', err)
236
237
        # Lightweight checkout (same as above, different branch and repository)
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
238
        old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
239
        bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
240
        transport.mkdir('lightcheckout')
241
        dir5 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('lightcheckout')
242
        bzrlib.branch.BranchReferenceFormat().initialize(dir5, branch1)
243
        dir5.create_workingtree()
244
        tree5 = dir5.open_workingtree()
245
        bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
246
        branch5 = tree5.branch
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
247
        out, err = self.runbzr('info lightcheckout')
248
        self.assertEqualDiff(
249
"""Location:
1780.1.2 by Robert Collins
(robertc)Partial refactoring of info tests to be more robust to format changes.
250
 light checkout root: %s
251
  checkout of branch: %s
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
252
253
Format:
1624.3.19 by Olaf Conradi
New call get_format_description to give a user-friendly description of a
254
       control: Meta directory format 1
255
  working tree: Working tree format 3
256
        branch: Branch format 4
257
    repository: Weave repository format 6
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
258
259
In the working tree:
260
         1 unchanged
261
         0 modified
262
         0 added
263
         0 removed
264
         0 renamed
265
         0 unknown
266
         0 ignored
267
         0 versioned subdirectories
268
269
Branch history:
270
         1 revision
271
         0 days old
272
   first revision: %s
273
  latest revision: %s
274
275
Revision store:
276
         1 revision
1624.3.14 by Olaf Conradi
Move to using kibi for binary prefix as per standard IEEE 1541.
277
         0 KiB
1694.2.6 by Martin Pool
[merge] bzr.dev
278
""" % (tree5.bzrdir.root_transport.base,
279
       branch1.bzrdir.root_transport.base,
280
       datestring_first, datestring_first,
281
       ), out)
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
282
        self.assertEqual('', err)
283
284
        # Update initial standalone branch
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
285
        self.build_tree(['standalone/b'])
286
        tree1.add('b')
287
        tree1.commit('commit two')
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
288
        rev = branch1.repository.get_revision(branch1.revision_history()[-1])
289
        datestring_last = format_date(rev.timestamp, rev.timezone)
290
291
        # Out of date branched standalone branch will not be detected
292
        out, err = self.runbzr('info branch')
293
        self.assertEqualDiff(
294
"""Location:
1694.2.6 by Martin Pool
[merge] bzr.dev
295
  branch root: %s
296
297
Related branches:
298
      parent branch: %s
299
  publish to branch: %s
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
300
301
Format:
1624.3.19 by Olaf Conradi
New call get_format_description to give a user-friendly description of a
302
       control: All-in-one format 6
303
  working tree: Working tree format 2
304
        branch: Branch format 4
305
    repository: Weave repository format 6
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
306
307
In the working tree:
308
         1 unchanged
309
         0 modified
310
         0 added
311
         0 removed
312
         0 renamed
313
         0 unknown
314
         0 ignored
315
         0 versioned subdirectories
316
317
Branch history:
318
         1 revision
319
         0 days old
320
   first revision: %s
321
  latest revision: %s
322
323
Revision store:
324
         1 revision
1624.3.14 by Olaf Conradi
Move to using kibi for binary prefix as per standard IEEE 1541.
325
         0 KiB
1694.2.6 by Martin Pool
[merge] bzr.dev
326
""" % (branch2.bzrdir.root_transport.base,
327
       branch1.bzrdir.root_transport.base,
328
       branch1.bzrdir.root_transport.base,
329
       datestring_first, datestring_first,
330
       ), out)
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
331
        self.assertEqual('', err)
332
333
        # Out of date bound branch
334
        out, err = self.runbzr('info bound')
335
        self.assertEqualDiff(
336
"""Location:
1694.2.6 by Martin Pool
[merge] bzr.dev
337
       checkout root: %s
338
  checkout of branch: %s
339
340
Related branches:
341
  parent branch: %s
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
342
343
Format:
1624.3.19 by Olaf Conradi
New call get_format_description to give a user-friendly description of a
344
       control: Meta directory format 1
345
  working tree: Working tree format 3
346
        branch: Branch format 5
1666.1.6 by Robert Collins
Make knit the default format.
347
    repository: %s
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
348
349
Branch is out of date: missing 1 revision.
350
351
In the working tree:
352
         1 unchanged
353
         0 modified
354
         0 added
355
         0 removed
356
         0 renamed
357
         1 unknown
358
         0 ignored
359
         0 versioned subdirectories
360
361
Branch history:
362
         1 revision
363
         0 days old
364
   first revision: %s
365
  latest revision: %s
366
367
Revision store:
368
         1 revision
1666.1.6 by Robert Collins
Make knit the default format.
369
         %d KiB
1694.2.6 by Martin Pool
[merge] bzr.dev
370
""" % (branch3.bzrdir.root_transport.base,
371
       branch1.bzrdir.root_transport.base,
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
372
       branch1.bzrdir.root_transport.base,
1666.1.6 by Robert Collins
Make knit the default format.
373
       branch3.repository._format.get_format_description(),
374
       datestring_first, datestring_first,
375
       # poking at _revision_store isn't all that clean, but neither is
376
       # having the ui test dependent on the exact overhead of a given store.
377
       branch3.repository._revision_store.total_size(
378
        branch3.repository.get_transaction())[1] / 1024,
379
       ), out)
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
380
        self.assertEqual('', err)
381
382
        # Out of date checkout
383
        out, err = self.runbzr('info checkout')
384
        self.assertEqualDiff(
385
"""Location:
1694.2.6 by Martin Pool
[merge] bzr.dev
386
       checkout root: %s
387
  checkout of branch: %s
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
388
389
Format:
1624.3.19 by Olaf Conradi
New call get_format_description to give a user-friendly description of a
390
       control: Meta directory format 1
391
  working tree: Working tree format 3
392
        branch: Branch format 5
1666.1.6 by Robert Collins
Make knit the default format.
393
    repository: %s
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
394
395
Branch is out of date: missing 1 revision.
396
397
In the working tree:
398
         1 unchanged
399
         0 modified
400
         0 added
401
         0 removed
402
         0 renamed
403
         0 unknown
404
         0 ignored
405
         0 versioned subdirectories
406
407
Branch history:
408
         1 revision
409
         0 days old
410
   first revision: %s
411
  latest revision: %s
412
413
Revision store:
414
         1 revision
1666.1.6 by Robert Collins
Make knit the default format.
415
         %d KiB
1694.2.6 by Martin Pool
[merge] bzr.dev
416
""" % (branch4.bzrdir.root_transport.base,
417
       branch1.bzrdir.root_transport.base,
1666.1.6 by Robert Collins
Make knit the default format.
418
       branch4.repository._format.get_format_description(),
419
       datestring_first, datestring_first,
420
       # poking at _revision_store isn't all that clean, but neither is
421
       # having the ui test dependent on the exact overhead of a given store.
422
       branch4.repository._revision_store.total_size(
423
        branch4.repository.get_transaction())[1] / 1024,
424
       ), out)
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
425
        self.assertEqual('', err)
426
427
        # Out of date lightweight checkout
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
428
        out, err = self.runbzr('info lightcheckout --verbose')
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
429
        self.assertEqualDiff(
430
"""Location:
1780.1.2 by Robert Collins
(robertc)Partial refactoring of info tests to be more robust to format changes.
431
 light checkout root: %s
432
  checkout of branch: %s
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
433
434
Format:
1624.3.19 by Olaf Conradi
New call get_format_description to give a user-friendly description of a
435
       control: Meta directory format 1
436
  working tree: Working tree format 3
437
        branch: Branch format 4
438
    repository: Weave repository format 6
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
439
440
Working tree is out of date: missing 1 revision.
441
442
In the working tree:
443
         1 unchanged
444
         0 modified
445
         0 added
446
         0 removed
447
         0 renamed
448
         0 unknown
449
         0 ignored
450
         0 versioned subdirectories
451
452
Branch history:
453
         2 revisions
454
         1 committer
455
         0 days old
456
   first revision: %s
457
  latest revision: %s
458
459
Revision store:
460
         2 revisions
1624.3.14 by Olaf Conradi
Move to using kibi for binary prefix as per standard IEEE 1541.
461
         0 KiB
1694.2.6 by Martin Pool
[merge] bzr.dev
462
""" % (tree5.bzrdir.root_transport.base,
463
       branch1.bzrdir.root_transport.base,
464
       datestring_first, datestring_last,
465
       ), out)
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
466
        self.assertEqual('', err)
467
1624.3.48 by Olaf Conradi
Add info on standalone branches without a working tree.
468
    def test_info_standalone_no_tree(self):
469
        # create standalone branch without a working tree
470
        branch = self.make_branch('branch')
471
        repo = branch.repository
472
        out, err = self.runbzr('info branch')
473
        self.assertEqualDiff(
474
"""Location:
475
  branch root: %s
476
477
Format:
478
       control: Meta directory format 1
479
        branch: Branch format 5
480
    repository: %s
481
482
Branch history:
483
         0 revisions
484
485
Revision store:
486
         0 revisions
487
         0 KiB
488
""" % (branch.bzrdir.root_transport.base,
489
       repo._format.get_format_description(),
490
       ), out)
491
        self.assertEqual('', err)
492
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
493
    def test_info_shared_repository(self):
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
494
        old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
495
        bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
496
        transport = self.get_transport()
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
497
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
498
        # Create shared repository
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
499
        repo = self.make_repository('repo', shared=True)
500
        repo.set_make_working_trees(False)
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
501
        out, err = self.runbzr('info repo')
502
        self.assertEqualDiff(
503
"""Location:
1694.2.6 by Martin Pool
[merge] bzr.dev
504
  shared repository: %s
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
505
506
Format:
507
       control: Meta directory format 1
1666.1.6 by Robert Collins
Make knit the default format.
508
    repository: %s
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
509
510
Revision store:
511
         0 revisions
512
         0 KiB
1694.2.6 by Martin Pool
[merge] bzr.dev
513
""" % (repo.bzrdir.root_transport.base,
514
       repo._format.get_format_description(),
515
       ), out)
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
516
        self.assertEqual('', err)
517
518
        # Create branch inside shared repository
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
519
        repo.bzrdir.root_transport.mkdir('branch')
520
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch')
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
521
        out, err = self.runbzr('info repo/branch')
522
        self.assertEqualDiff(
523
"""Location:
1694.2.6 by Martin Pool
[merge] bzr.dev
524
  shared repository: %s
525
  repository branch: branch
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
526
527
Format:
528
       control: Meta directory format 1
529
        branch: Branch format 5
1666.1.6 by Robert Collins
Make knit the default format.
530
    repository: %s
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
531
532
Branch history:
533
         0 revisions
534
535
Revision store:
536
         0 revisions
537
         0 KiB
1694.2.6 by Martin Pool
[merge] bzr.dev
538
""" % (repo.bzrdir.root_transport.base,
1666.1.6 by Robert Collins
Make knit the default format.
539
       repo._format.get_format_description(),
540
       ), out)
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
541
        self.assertEqual('', err)
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
542
543
        # Create lightweight checkout
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
544
        transport.mkdir('tree')
545
        transport.mkdir('tree/lightcheckout')
546
        dir2 = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
547
        bzrlib.branch.BranchReferenceFormat().initialize(dir2, branch1)
548
        dir2.create_workingtree()
549
        tree2 = dir2.open_workingtree()
550
        branch2 = tree2.branch
1780.1.2 by Robert Collins
(robertc)Partial refactoring of info tests to be more robust to format changes.
551
        self.assertCheckoutStatusOutput('tree/lightcheckout', tree2, shared_repo=repo)
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
552
553
        # Create normal checkout
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
554
        branch3 = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout')
555
        branch3.bind(branch1)
556
        tree3 = branch3.bzrdir.open_workingtree()
557
        tree3.update()
1780.1.2 by Robert Collins
(robertc)Partial refactoring of info tests to be more robust to format changes.
558
        self.assertCheckoutStatusOutput('tree/checkout --verbose', tree3,
559
            verbose=True,
560
            light_checkout=False, repo_branch=branch1)
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
561
        # Update lightweight checkout
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
562
        self.build_tree(['tree/lightcheckout/a'])
563
        tree2.add('a')
564
        tree2.commit('commit one')
565
        rev = repo.get_revision(branch2.revision_history()[0])
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
566
        datestring_first = format_date(rev.timestamp, rev.timezone)
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
567
        out, err = self.runbzr('info tree/lightcheckout --verbose')
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
568
        self.assertEqualDiff(
569
"""Location:
1780.1.2 by Robert Collins
(robertc)Partial refactoring of info tests to be more robust to format changes.
570
 light checkout root: %s
571
   shared repository: %s
572
   repository branch: branch
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
573
574
Format:
1624.3.19 by Olaf Conradi
New call get_format_description to give a user-friendly description of a
575
       control: Meta directory format 1
576
  working tree: Working tree format 3
577
        branch: Branch format 5
1666.1.6 by Robert Collins
Make knit the default format.
578
    repository: %s
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
579
580
In the working tree:
581
         1 unchanged
582
         0 modified
583
         0 added
584
         0 removed
585
         0 renamed
586
         0 unknown
587
         0 ignored
588
         0 versioned subdirectories
589
590
Branch history:
591
         1 revision
592
         1 committer
593
         0 days old
594
   first revision: %s
595
  latest revision: %s
596
597
Revision store:
598
         1 revision
1666.1.6 by Robert Collins
Make knit the default format.
599
         %d KiB
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
600
""" % (tree2.bzrdir.root_transport.base,
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
601
       repo.bzrdir.root_transport.base,
1666.1.6 by Robert Collins
Make knit the default format.
602
       repo._format.get_format_description(),
603
       datestring_first, datestring_first,
604
       # poking at _revision_store isn't all that clean, but neither is
605
       # having the ui test dependent on the exact overhead of a given store.
606
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
607
       ), out)
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
608
        self.assertEqual('', err)
609
610
        # Out of date checkout
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
611
        out, err = self.runbzr('info tree/checkout')
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
612
        self.assertEqualDiff(
613
"""Location:
1694.2.6 by Martin Pool
[merge] bzr.dev
614
       checkout root: %s
615
  checkout of branch: %s
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
616
617
Format:
1624.3.19 by Olaf Conradi
New call get_format_description to give a user-friendly description of a
618
       control: Meta directory format 1
619
  working tree: Working tree format 3
620
        branch: Branch format 5
1666.1.6 by Robert Collins
Make knit the default format.
621
    repository: %s
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
622
623
Branch is out of date: missing 1 revision.
624
625
In the working tree:
626
         0 unchanged
627
         0 modified
628
         0 added
629
         0 removed
630
         0 renamed
631
         0 unknown
632
         0 ignored
633
         0 versioned subdirectories
634
635
Branch history:
636
         0 revisions
637
638
Revision store:
639
         0 revisions
1624.3.14 by Olaf Conradi
Move to using kibi for binary prefix as per standard IEEE 1541.
640
         0 KiB
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
641
""" % (tree3.bzrdir.root_transport.base,
1666.1.6 by Robert Collins
Make knit the default format.
642
       branch1.bzrdir.root_transport.base,
643
       repo._format.get_format_description(),
644
       ), out)
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
645
        self.assertEqual('', err)
646
647
        # Update checkout
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
648
        tree3.update()
649
        self.build_tree(['tree/checkout/b'])
650
        tree3.add('b')
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
651
        out, err = self.runbzr('info tree/checkout --verbose')
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
652
        self.assertEqualDiff(
653
"""Location:
1694.2.6 by Martin Pool
[merge] bzr.dev
654
       checkout root: %s
655
  checkout of branch: %s
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
656
657
Format:
1624.3.19 by Olaf Conradi
New call get_format_description to give a user-friendly description of a
658
       control: Meta directory format 1
659
  working tree: Working tree format 3
660
        branch: Branch format 5
1666.1.6 by Robert Collins
Make knit the default format.
661
    repository: %s
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
662
663
In the working tree:
664
         1 unchanged
665
         0 modified
666
         1 added
667
         0 removed
668
         0 renamed
669
         0 unknown
670
         0 ignored
671
         0 versioned subdirectories
672
673
Branch history:
674
         1 revision
675
         1 committer
676
         0 days old
677
   first revision: %s
678
  latest revision: %s
679
680
Revision store:
681
         1 revision
1666.1.6 by Robert Collins
Make knit the default format.
682
         %d KiB
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
683
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
1666.1.6 by Robert Collins
Make knit the default format.
684
       repo._format.get_format_description(),
685
       datestring_first, datestring_first,
686
       # poking at _revision_store isn't all that clean, but neither is
687
       # having the ui test dependent on the exact overhead of a given store.
688
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
689
       ), out)
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
690
        self.assertEqual('', err)
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
691
        tree3.commit('commit two')
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
692
693
        # Out of date lightweight checkout
1624.3.12 by Olaf Conradi
Fixed bug in test case where datestring_last returned the first.
694
        rev = repo.get_revision(branch1.revision_history()[-1])
695
        datestring_last = format_date(rev.timestamp, rev.timezone)
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
696
        out, err = self.runbzr('info tree/lightcheckout --verbose')
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
697
        self.assertEqualDiff(
698
"""Location:
1780.1.2 by Robert Collins
(robertc)Partial refactoring of info tests to be more robust to format changes.
699
 light checkout root: %s
700
   shared repository: %s
701
   repository branch: branch
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
702
703
Format:
1624.3.19 by Olaf Conradi
New call get_format_description to give a user-friendly description of a
704
       control: Meta directory format 1
705
  working tree: Working tree format 3
706
        branch: Branch format 5
1666.1.6 by Robert Collins
Make knit the default format.
707
    repository: %s
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
708
709
Working tree is out of date: missing 1 revision.
710
711
In the working tree:
712
         1 unchanged
713
         0 modified
714
         0 added
715
         0 removed
716
         0 renamed
717
         0 unknown
718
         0 ignored
719
         0 versioned subdirectories
720
721
Branch history:
722
         2 revisions
723
         1 committer
724
         0 days old
725
   first revision: %s
726
  latest revision: %s
727
728
Revision store:
729
         2 revisions
1666.1.6 by Robert Collins
Make knit the default format.
730
         %d KiB
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
731
""" % (tree2.bzrdir.root_transport.base,
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
732
       repo.bzrdir.root_transport.base,
1666.1.6 by Robert Collins
Make knit the default format.
733
       repo._format.get_format_description(),
734
       datestring_first, datestring_last,
735
       # poking at _revision_store isn't all that clean, but neither is
736
       # having the ui test dependent on the exact overhead of a given store.
737
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
738
       ), out)
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
739
        self.assertEqual('', err)
740
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
741
        # Show info about shared branch
742
        out, err = self.runbzr('info repo/branch --verbose')
743
        self.assertEqualDiff(
744
"""Location:
1694.2.6 by Martin Pool
[merge] bzr.dev
745
  shared repository: %s
746
  repository branch: branch
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
747
748
Format:
749
       control: Meta directory format 1
750
        branch: Branch format 5
1666.1.6 by Robert Collins
Make knit the default format.
751
    repository: %s
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
752
753
Branch history:
754
         2 revisions
755
         1 committer
756
         0 days old
757
   first revision: %s
758
  latest revision: %s
759
760
Revision store:
761
         2 revisions
1666.1.6 by Robert Collins
Make knit the default format.
762
         %d KiB
1694.2.6 by Martin Pool
[merge] bzr.dev
763
""" % (repo.bzrdir.root_transport.base,
1666.1.6 by Robert Collins
Make knit the default format.
764
       repo._format.get_format_description(),
765
       datestring_first, datestring_last,
766
       # poking at _revision_store isn't all that clean, but neither is
767
       # having the ui test dependent on the exact overhead of a given store.
768
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
769
       ), out)
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
770
        self.assertEqual('', err)
771
772
        # Show info about repository with revisions
773
        out, err = self.runbzr('info repo')
774
        self.assertEqualDiff(
775
"""Location:
1694.2.6 by Martin Pool
[merge] bzr.dev
776
  shared repository: %s
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
777
778
Format:
779
       control: Meta directory format 1
1666.1.6 by Robert Collins
Make knit the default format.
780
    repository: %s
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
781
782
Revision store:
783
         2 revisions
1666.1.6 by Robert Collins
Make knit the default format.
784
         %d KiB
785
""" % (repo.bzrdir.root_transport.base,
786
       repo._format.get_format_description(),
787
       # poking at _revision_store isn't all that clean, but neither is
788
       # having the ui test dependent on the exact overhead of a given store.
789
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1694.2.6 by Martin Pool
[merge] bzr.dev
790
       ), out)
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
791
        self.assertEqual('', err)
792
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
793
        bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
794
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
795
    def test_info_shared_repository_with_trees(self):
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
796
        old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
797
        bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
798
        transport = self.get_transport()
799
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
800
        # Create shared repository with working trees
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
801
        repo = self.make_repository('repo', shared=True)
802
        repo.set_make_working_trees(True)
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
803
        out, err = self.runbzr('info repo')
804
        self.assertEqualDiff(
805
"""Location:
1694.2.6 by Martin Pool
[merge] bzr.dev
806
  shared repository: %s
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
807
808
Format:
809
       control: Meta directory format 1
1666.1.6 by Robert Collins
Make knit the default format.
810
    repository: %s
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
811
812
Create working tree for new branches inside the repository.
813
814
Revision store:
815
         0 revisions
816
         0 KiB
1666.1.6 by Robert Collins
Make knit the default format.
817
""" % (repo.bzrdir.root_transport.base,
818
       repo._format.get_format_description(),
819
       ), out)
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
820
        self.assertEqual('', err)
821
822
        # Create two branches
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
823
        repo.bzrdir.root_transport.mkdir('branch1')
824
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch1')
825
        branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
826
827
        # Empty first branch
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
828
        out, err = self.runbzr('info repo/branch1 --verbose')
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
829
        self.assertEqualDiff(
830
"""Location:
1694.2.6 by Martin Pool
[merge] bzr.dev
831
    shared repository: %s
832
  repository checkout: branch1
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
833
834
Format:
1624.3.19 by Olaf Conradi
New call get_format_description to give a user-friendly description of a
835
       control: Meta directory format 1
836
  working tree: Working tree format 3
837
        branch: Branch format 5
1666.1.6 by Robert Collins
Make knit the default format.
838
    repository: %s
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
839
840
In the working tree:
841
         0 unchanged
842
         0 modified
843
         0 added
844
         0 removed
845
         0 renamed
846
         0 unknown
847
         0 ignored
848
         0 versioned subdirectories
849
850
Branch history:
851
         0 revisions
852
         0 committers
853
854
Revision store:
855
         0 revisions
1624.3.14 by Olaf Conradi
Move to using kibi for binary prefix as per standard IEEE 1541.
856
         0 KiB
1694.2.6 by Martin Pool
[merge] bzr.dev
857
""" % (repo.bzrdir.root_transport.base,
1666.1.6 by Robert Collins
Make knit the default format.
858
       repo._format.get_format_description(),
859
       ), out)
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
860
        self.assertEqual('', err)
861
862
        # Update first branch
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
863
        self.build_tree(['repo/branch1/a'])
864
        tree1 = branch1.bzrdir.open_workingtree()
865
        tree1.add('a')
866
        tree1.commit('commit one')
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
867
        rev = repo.get_revision(branch1.revision_history()[0])
868
        datestring_first = format_date(rev.timestamp, rev.timezone)
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
869
        out, err = self.runbzr('info repo/branch1')
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
870
        self.assertEqualDiff(
871
"""Location:
1694.2.6 by Martin Pool
[merge] bzr.dev
872
    shared repository: %s
873
  repository checkout: branch1
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
874
875
Format:
1624.3.19 by Olaf Conradi
New call get_format_description to give a user-friendly description of a
876
       control: Meta directory format 1
877
  working tree: Working tree format 3
878
        branch: Branch format 5
1666.1.6 by Robert Collins
Make knit the default format.
879
    repository: %s
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
880
881
In the working tree:
882
         1 unchanged
883
         0 modified
884
         0 added
885
         0 removed
886
         0 renamed
887
         0 unknown
888
         0 ignored
889
         0 versioned subdirectories
890
891
Branch history:
892
         1 revision
893
         0 days old
894
   first revision: %s
895
  latest revision: %s
896
897
Revision store:
898
         1 revision
1666.1.6 by Robert Collins
Make knit the default format.
899
         %d KiB
1694.2.6 by Martin Pool
[merge] bzr.dev
900
""" % (repo.bzrdir.root_transport.base,
1666.1.6 by Robert Collins
Make knit the default format.
901
       repo._format.get_format_description(),
902
       datestring_first, datestring_first,
903
       # poking at _revision_store isn't all that clean, but neither is
904
       # having the ui test dependent on the exact overhead of a given store.
905
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
906
       ), out)
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
907
        self.assertEqual('', err)
908
909
        # Out of date second branch
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
910
        out, err = self.runbzr('info repo/branch2 --verbose')
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
911
        self.assertEqualDiff(
912
"""Location:
1694.2.6 by Martin Pool
[merge] bzr.dev
913
    shared repository: %s
914
  repository checkout: branch2
915
916
Related branches:
917
  parent branch: %s
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
918
919
Format:
1624.3.19 by Olaf Conradi
New call get_format_description to give a user-friendly description of a
920
       control: Meta directory format 1
921
  working tree: Working tree format 3
922
        branch: Branch format 5
1666.1.6 by Robert Collins
Make knit the default format.
923
    repository: %s
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
924
925
In the working tree:
926
         0 unchanged
927
         0 modified
928
         0 added
929
         0 removed
930
         0 renamed
931
         0 unknown
932
         0 ignored
933
         0 versioned subdirectories
934
935
Branch history:
936
         0 revisions
937
         0 committers
938
939
Revision store:
940
         1 revision
1666.1.6 by Robert Collins
Make knit the default format.
941
         %d KiB
1694.2.6 by Martin Pool
[merge] bzr.dev
942
""" % (repo.bzrdir.root_transport.base,
1666.1.6 by Robert Collins
Make knit the default format.
943
       branch1.bzrdir.root_transport.base,
944
       repo._format.get_format_description(),
945
       # poking at _revision_store isn't all that clean, but neither is
946
       # having the ui test dependent on the exact overhead of a given store.
947
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
948
       ), out)
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
949
        self.assertEqual('', err)
950
951
        # Update second branch
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
952
        tree2 = branch2.bzrdir.open_workingtree()
953
        tree2.pull(branch1)
954
        out, err = self.runbzr('info repo/branch2')
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
955
        self.assertEqualDiff(
956
"""Location:
1694.2.6 by Martin Pool
[merge] bzr.dev
957
    shared repository: %s
958
  repository checkout: branch2
959
960
Related branches:
961
  parent branch: %s
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
962
963
Format:
1624.3.19 by Olaf Conradi
New call get_format_description to give a user-friendly description of a
964
       control: Meta directory format 1
965
  working tree: Working tree format 3
966
        branch: Branch format 5
1666.1.6 by Robert Collins
Make knit the default format.
967
    repository: %s
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
968
969
In the working tree:
970
         1 unchanged
971
         0 modified
972
         0 added
973
         0 removed
974
         0 renamed
975
         0 unknown
976
         0 ignored
977
         0 versioned subdirectories
978
979
Branch history:
980
         1 revision
981
         0 days old
982
   first revision: %s
983
  latest revision: %s
984
985
Revision store:
986
         1 revision
1666.1.6 by Robert Collins
Make knit the default format.
987
         %d KiB
1694.2.6 by Martin Pool
[merge] bzr.dev
988
""" % (repo.bzrdir.root_transport.base,
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
989
       branch1.bzrdir.root_transport.base,
1666.1.6 by Robert Collins
Make knit the default format.
990
       repo._format.get_format_description(),
991
       datestring_first, datestring_first,
992
       # poking at _revision_store isn't all that clean, but neither is
993
       # having the ui test dependent on the exact overhead of a given store.
994
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
995
       ), out)
1624.3.10 by Olaf Conradi
Add blackbox test case for command bzr info.
996
        self.assertEqual('', err)
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
997
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
998
        # Show info about repository with revisions
999
        out, err = self.runbzr('info repo')
1000
        self.assertEqualDiff(
1001
"""Location:
1694.2.6 by Martin Pool
[merge] bzr.dev
1002
  shared repository: %s
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
1003
1004
Format:
1005
       control: Meta directory format 1
1666.1.6 by Robert Collins
Make knit the default format.
1006
    repository: %s
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
1007
1008
Create working tree for new branches inside the repository.
1009
1010
Revision store:
1011
         1 revision
1666.1.6 by Robert Collins
Make knit the default format.
1012
         %d KiB
1013
""" % (repo.bzrdir.root_transport.base,
1014
       repo._format.get_format_description(),
1015
       # poking at _revision_store isn't all that clean, but neither is
1016
       # having the ui test dependent on the exact overhead of a given store.
1017
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1018
       ),
1019
       out)
1624.3.21 by Olaf Conradi
Make bzr info command work on both local and remote locations. Support
1020
        self.assertEqual('', err)
1021
1624.3.18 by Olaf Conradi
Move to using bzrlib API for blackbox test cases.
1022
        bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1694.2.6 by Martin Pool
[merge] bzr.dev
1023
    
1024
    def test_info_shared_repository_with_tree_in_root(self):
1025
        old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
1026
        bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrlib.bzrdir.BzrDirMetaFormat1())
1027
        transport = self.get_transport()
1028
1029
        # Create shared repository with working trees
1030
        repo = self.make_repository('repo', shared=True)
1031
        repo.set_make_working_trees(True)
1032
        out, err = self.runbzr('info repo')
1033
        self.assertEqualDiff(
1034
"""Location:
1035
  shared repository: %s
1036
1037
Format:
1038
       control: Meta directory format 1
1039
    repository: %s
1040
1041
Create working tree for new branches inside the repository.
1042
1043
Revision store:
1044
         0 revisions
1045
         0 KiB
1046
""" % (repo.bzrdir.root_transport.base,
1047
       repo._format.get_format_description(),
1048
       ), out)
1049
        self.assertEqual('', err)
1050
1051
        # Create branch in root of repository
1052
        control = repo.bzrdir
1053
        branch = control.create_branch()
1054
        control.create_workingtree()
1055
        out, err = self.runbzr('info repo')
1056
        self.assertEqualDiff(
1057
"""Location:
1058
    shared repository: %s
1059
  repository checkout: .
1060
1061
Format:
1062
       control: Meta directory format 1
1063
  working tree: Working tree format 3
1064
        branch: Branch format 5
1065
    repository: %s
1066
1067
In the working tree:
1068
         0 unchanged
1069
         0 modified
1070
         0 added
1071
         0 removed
1072
         0 renamed
1073
         0 unknown
1074
         0 ignored
1075
         0 versioned subdirectories
1076
1077
Branch history:
1078
         0 revisions
1079
1080
Revision store:
1081
         0 revisions
1082
         0 KiB
1083
""" % (repo.bzrdir.root_transport.base,
1084
       repo._format.get_format_description(),
1085
       ), out)
1086
        self.assertEqual('', err)
1087
1088
        bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
1089
1780.1.2 by Robert Collins
(robertc)Partial refactoring of info tests to be more robust to format changes.
1090
    def assertCheckoutStatusOutput(self, 
1091
        command_string, lco_tree, shared_repo=None,
1092
        repo_branch=None,
1093
        tree_locked=False,
1094
        branch_locked=False, repo_locked=False,
1095
        verbose=False,
1096
        light_checkout=True):
1097
        """Check the output of info in a light checkout tree.
1098
1099
        This is not quite a mirror of the info code: rather than using the
1100
        tree being examined to predict output, it uses a bunch of flags which
1101
        allow us, the test writers, to document what *should* be present in
1102
        the output. Removing this separation would remove the value of the
1103
        tests.
1104
        
1105
        :param path: the path to the light checkout.
1106
        :param lco_tree: the tree object for the light checkout.
1107
        :param shared_repo: A shared repository is in use, expect that in
1108
            the output.
1109
        :param repo_branch: A branch in a shared repository for non light
1110
            checkouts.
1111
        :param tree_locked: If true, expect the tree to be locked.
1112
        :param branch_locked: If true, expect the branch to be locked.
1113
        :param repo_locked: If true, expect the repository to be locked.
1114
        :param verbose: If true, expect verbose output
1115
        """
1116
        out, err = self.runbzr('info %s' % command_string)
1117
        if repo_locked or branch_locked or tree_locked:
1118
            def locked_message(a_bool):
1119
                if a_bool:
1120
                    return 'locked'
1121
                else:
1122
                    return 'unlocked'
1123
            expected_lock_output = (
1124
                "\n"
1125
                "Lock status:\n"
1126
                "  working tree: %s\n"
1127
                "        branch: %s\n"
1128
                "    repository: %s\n" % (
1129
                    locked_message(tree_locked),
1130
                    locked_message(branch_locked),
1131
                    locked_message(repo_locked)))
1132
        else:
1133
            expected_lock_output = ''
1134
        if light_checkout:
1135
            tree_data = (" light checkout root: %s" %
1136
                lco_tree.bzrdir.root_transport.base)
1137
        else:
1138
            tree_data = ("       checkout root: %s" %
1139
                lco_tree.bzrdir.root_transport.base)
1140
        if shared_repo is not None:
1141
            branch_data = (
1142
                "   shared repository: %s\n"
1143
                "   repository branch: branch\n" %
1144
                shared_repo.bzrdir.root_transport.base)
1145
        elif repo_branch is not None:
1146
            branch_data = (
1147
                "  checkout of branch: %s\n" % 
1148
                repo_branch.bzrdir.root_transport.base)
1149
        else:
1150
            branch_data = ("  checkout of branch: %s\n" % 
1151
                lco_tree.branch.bzrdir.root_transport.base)
1152
        
1153
        if verbose:
1154
            verbose_info = '         0 committers\n'
1155
        else:
1156
            verbose_info = ''
1157
            
1158
        self.assertEqualDiff(
1159
"""Location:
1160
%s
1161
%s
1162
Format:
1163
       control: Meta directory format 1
1164
  working tree: %s
1165
        branch: Branch format 5
1166
    repository: %s
1167
%s
1168
In the working tree:
1169
         0 unchanged
1170
         0 modified
1171
         0 added
1172
         0 removed
1173
         0 renamed
1174
         0 unknown
1175
         0 ignored
1176
         0 versioned subdirectories
1177
1178
Branch history:
1179
         0 revisions
1180
%s
1181
Revision store:
1182
         0 revisions
1183
         0 KiB
1184
""" %  (tree_data,
1185
        branch_data,
1186
        lco_tree._format.get_format_description(),
1187
        lco_tree.branch.repository._format.get_format_description(),
1188
        expected_lock_output,
1189
        verbose_info,
1190
        ), out)
1191
        self.assertEqual('', err)
1192
1694.2.6 by Martin Pool
[merge] bzr.dev
1193
    def test_info_locking(self):
1194
        transport = self.get_transport()
1195
        # Create shared repository with a branch
1196
        repo = self.make_repository('repo', shared=True,
1197
                                    format=bzrlib.bzrdir.BzrDirMetaFormat1())
1198
        repo.set_make_working_trees(False)
1199
        repo.bzrdir.root_transport.mkdir('branch')
1200
        repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1201
                                    format=bzrlib.bzrdir.BzrDirMetaFormat1())
1202
        # Do a heavy checkout
1203
        transport.mkdir('tree')
1204
        transport.mkdir('tree/checkout')
1205
        co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1206
                                    format=bzrlib.bzrdir.BzrDirMetaFormat1())
1207
        co_branch.bind(repo_branch)
1208
        # Do a light checkout of the heavy one
1209
        transport.mkdir('tree/lightcheckout')
1210
        lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1211
        bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1212
        lco_dir.create_workingtree()
1213
        lco_tree = lco_dir.open_workingtree()
1214
1215
        # Test all permutations of locking the working tree, branch and repository
1216
        # W B R
1217
1218
        # U U U
1780.1.2 by Robert Collins
(robertc)Partial refactoring of info tests to be more robust to format changes.
1219
        self.assertCheckoutStatusOutput('tree/lightcheckout', lco_tree)
1694.2.6 by Martin Pool
[merge] bzr.dev
1220
        # U U L
1221
        lco_tree.branch.repository.lock_write()
1780.1.2 by Robert Collins
(robertc)Partial refactoring of info tests to be more robust to format changes.
1222
        try:
1223
            self.assertCheckoutStatusOutput('tree/lightcheckout',
1224
            lco_tree,
1225
            repo_locked=True)
1226
        finally:
1227
            lco_tree.branch.repository.unlock()
1694.2.6 by Martin Pool
[merge] bzr.dev
1228
        # U L L
1229
        lco_tree.branch.lock_write()
1780.1.2 by Robert Collins
(robertc)Partial refactoring of info tests to be more robust to format changes.
1230
        try:
1231
            self.assertCheckoutStatusOutput('tree/lightcheckout',
1232
            lco_tree,
1233
            branch_locked=True,
1234
            repo_locked=True)
1235
        finally:
1236
            lco_tree.branch.unlock()
1694.2.6 by Martin Pool
[merge] bzr.dev
1237
        # L L L
1238
        lco_tree.lock_write()
1780.1.2 by Robert Collins
(robertc)Partial refactoring of info tests to be more robust to format changes.
1239
        try:
1240
            self.assertCheckoutStatusOutput('tree/lightcheckout',
1241
            lco_tree,
1242
            tree_locked=True,
1243
            branch_locked=True,
1244
            repo_locked=True)
1245
        finally:
1246
            lco_tree.unlock()
1694.2.6 by Martin Pool
[merge] bzr.dev
1247
        # L L U
1248
        lco_tree.lock_write()
1249
        lco_tree.branch.repository.unlock()
1780.1.2 by Robert Collins
(robertc)Partial refactoring of info tests to be more robust to format changes.
1250
        try:
1251
            self.assertCheckoutStatusOutput('tree/lightcheckout',
1252
            lco_tree,
1253
            tree_locked=True,
1254
            branch_locked=True)
1255
        finally:
1256
            lco_tree.branch.repository.lock_write()
1257
            lco_tree.unlock()
1694.2.6 by Martin Pool
[merge] bzr.dev
1258
        # L U U
1259
        lco_tree.lock_write()
1260
        lco_tree.branch.unlock()
1780.1.2 by Robert Collins
(robertc)Partial refactoring of info tests to be more robust to format changes.
1261
        try:
1262
            self.assertCheckoutStatusOutput('tree/lightcheckout',
1263
            lco_tree,
1264
            tree_locked=True)
1265
        finally:
1266
            lco_tree.branch.lock_write()
1267
            lco_tree.unlock()
1694.2.6 by Martin Pool
[merge] bzr.dev
1268
        # L U L
1269
        lco_tree.lock_write()
1270
        lco_tree.branch.unlock()
1271
        lco_tree.branch.repository.lock_write()
1780.1.2 by Robert Collins
(robertc)Partial refactoring of info tests to be more robust to format changes.
1272
        try:
1273
            self.assertCheckoutStatusOutput('tree/lightcheckout',
1274
            lco_tree,
1275
            tree_locked=True,
1276
            repo_locked=True)
1277
        finally:
1278
            lco_tree.branch.repository.unlock()
1279
            lco_tree.branch.lock_write()
1280
            lco_tree.unlock()
1694.2.6 by Martin Pool
[merge] bzr.dev
1281
        # U L U
1282
        lco_tree.branch.lock_write()
1283
        lco_tree.branch.repository.unlock()
1780.1.2 by Robert Collins
(robertc)Partial refactoring of info tests to be more robust to format changes.
1284
        try:
1285
            self.assertCheckoutStatusOutput('tree/lightcheckout',
1286
            lco_tree,
1287
            branch_locked=True)
1288
        finally:
1289
            lco_tree.branch.repository.lock_write()
1290
            lco_tree.branch.unlock()
1694.2.6 by Martin Pool
[merge] bzr.dev
1291
1292
    def test_info_locking_oslocks(self):
1769.2.2 by Alexander Belchenko
Test blackbox.test_info.TestInfo.test_info_locking_oslocks skipped on win32
1293
        if sys.platform == "win32":
1294
            raise TestSkipped("don't use oslocks on win32 in unix manner")
1295
1694.2.6 by Martin Pool
[merge] bzr.dev
1296
        tree = self.make_branch_and_tree('branch',
1297
                                         format=bzrlib.bzrdir.BzrDirFormat6())
1298
1299
        # Test all permutations of locking the working tree, branch and repository
1300
        # XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1301
        # implemented by raising NotImplementedError and get_physical_lock_status()
1302
        # always returns false. This makes bzr info hide the lock status.  (Olaf)
1303
        # W B R
1304
1305
        # U U U
1306
        out, err = self.runbzr('info branch')
1307
        self.assertEqualDiff(
1308
"""Location:
1309
  branch root: %s
1310
1311
Format:
1312
       control: All-in-one format 6
1313
  working tree: Working tree format 2
1314
        branch: Branch format 4
1315
    repository: %s
1316
1317
In the working tree:
1318
         0 unchanged
1319
         0 modified
1320
         0 added
1321
         0 removed
1322
         0 renamed
1323
         0 unknown
1324
         0 ignored
1325
         0 versioned subdirectories
1326
1327
Branch history:
1328
         0 revisions
1329
1330
Revision store:
1331
         0 revisions
1332
         0 KiB
1333
""" % (tree.bzrdir.root_transport.base,
1334
       tree.branch.repository._format.get_format_description(),
1335
       ), out)
1336
        self.assertEqual('', err)
1337
        # L L L
1338
        tree.lock_write()
1339
        out, err = self.runbzr('info branch')
1340
        self.assertEqualDiff(
1341
"""Location:
1342
  branch root: %s
1343
1344
Format:
1345
       control: All-in-one format 6
1346
  working tree: Working tree format 2
1347
        branch: Branch format 4
1348
    repository: %s
1349
1350
In the working tree:
1351
         0 unchanged
1352
         0 modified
1353
         0 added
1354
         0 removed
1355
         0 renamed
1356
         0 unknown
1357
         0 ignored
1358
         0 versioned subdirectories
1359
1360
Branch history:
1361
         0 revisions
1362
1363
Revision store:
1364
         0 revisions
1365
         0 KiB
1366
""" % (tree.bzrdir.root_transport.base,
1367
       tree.branch.repository._format.get_format_description(),
1368
       ), out)
1369
        self.assertEqual('', err)
1370
        tree.unlock()