~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_info.py

  • Committer: Alexander Belchenko
  • Date: 2006-07-30 16:43:12 UTC
  • mto: (1711.2.111 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1906.
  • Revision ID: bialix@ukr.net-20060730164312-b025fd3ff0cee59e
rename  gpl.txt => COPYING.txt

Show diffs side-by-side

added added

removed removed

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