~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Launchpad Translations on behalf of bzr-core
  • Date: 2012-11-25 04:30:35 UTC
  • mto: (6581.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6582.
  • Revision ID: launchpad_translations_on_behalf_of_bzr-core-20121125043035-9abma98g1j6p5uox
Launchpad automatic translations update.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2006-2012 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
18
"""Tests for the info command of bzr."""
19
19
 
 
20
import shutil
20
21
import sys
21
22
 
22
 
import bzrlib
23
23
from bzrlib import (
 
24
    branch,
24
25
    bzrdir,
25
 
    repository,
 
26
    controldir,
 
27
    errors,
 
28
    info,
 
29
    osutils,
 
30
    tests,
 
31
    upgrade,
 
32
    urlutils,
26
33
    )
27
 
from bzrlib.osutils import format_date
28
 
from bzrlib.tests import TestSkipped
29
 
from bzrlib.tests.blackbox import ExternalBase
30
 
 
31
 
 
32
 
class TestInfo(ExternalBase):
 
34
from bzrlib.tests.matchers import ContainsNoVfsCalls
 
35
from bzrlib.transport import memory
 
36
 
 
37
 
 
38
class TestInfo(tests.TestCaseWithTransport):
 
39
 
 
40
    def setUp(self):
 
41
        super(TestInfo, self).setUp()
 
42
        self._repo_strings = "2a"
33
43
 
34
44
    def test_info_non_existing(self):
35
 
        if sys.platform == "win32":
36
 
            location = "C:/i/do/not/exist/"
37
 
        else:
38
 
            location = "/i/do/not/exist/"
 
45
        self.vfs_transport_factory = memory.MemoryServer
 
46
        location = self.get_url()
39
47
        out, err = self.run_bzr('info '+location, retcode=3)
40
48
        self.assertEqual(out, '')
41
 
        self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
 
49
        self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
 
50
 
 
51
    def test_info_empty_controldir(self):
 
52
        self.make_bzrdir('ctrl')
 
53
        out, err = self.run_bzr('info ctrl')
 
54
        self.assertEquals(out,
 
55
            'Empty control directory (format: 2a or pack-0.92)\n'
 
56
            'Location:\n'
 
57
            '  control directory: ctrl\n')
 
58
        self.assertEquals(err, '')
 
59
 
 
60
    def test_info_empty_controldir_verbose(self):
 
61
        self.make_bzrdir('ctrl')
 
62
        out, err = self.run_bzr('info -v ctrl')
 
63
        self.assertEqualDiff(out,
 
64
            'Empty control directory (format: 2a or pack-0.92)\n'
 
65
            'Location:\n'
 
66
            '  control directory: ctrl\n\n'
 
67
            'Format:\n'
 
68
            '       control: Meta directory format 1\n\n'
 
69
            'Control directory:\n'
 
70
            '         0 branches\n')
 
71
        self.assertEquals(err, '')
 
72
 
 
73
    def test_info_dangling_branch_reference(self):
 
74
        br = self.make_branch('target')
 
75
        br.create_checkout('from', lightweight=True)
 
76
        shutil.rmtree('target')
 
77
        out, err = self.run_bzr('info from')
 
78
        self.assertEquals(out,
 
79
            'Dangling branch reference (format: 2a or pack-0.92)\n'
 
80
            'Location:\n'
 
81
            '   control directory: from\n'
 
82
            '  checkout of branch: target\n')
 
83
        self.assertEquals(err, '')
42
84
 
43
85
    def test_info_standalone(self):
44
86
        transport = self.get_transport()
45
87
 
46
88
        # Create initial standalone branch
47
 
        tree1 = self.make_branch_and_tree('standalone', 'weave')
 
89
        tree1 = self.make_branch_and_tree('standalone', 'knit')
48
90
        self.build_tree(['standalone/a'])
49
91
        tree1.add('a')
50
92
        branch1 = tree1.branch
 
93
 
 
94
        out, err = self.run_bzr('info standalone')
 
95
        self.assertEqualDiff(
 
96
"""Standalone tree (format: knit)
 
97
Location:
 
98
  branch root: standalone
 
99
""", out)
 
100
        self.assertEqual('', err)
 
101
 
 
102
        # Standalone branch - verbose mode
51
103
        out, err = self.run_bzr('info standalone -v')
52
104
        self.assertEqualDiff(
53
 
"""Standalone tree (format: weave)
54
 
Location:
55
 
  branch root: %s
56
 
 
57
 
Format:
58
 
       control: All-in-one format 6
59
 
  working tree: Working tree format 2
60
 
        branch: Branch format 4
61
 
    repository: Weave repository format 6
 
105
"""Standalone tree (format: knit)
 
106
Location:
 
107
  branch root: standalone
 
108
 
 
109
Format:
 
110
       control: Meta directory format 1
 
111
  working tree: Working tree format 3
 
112
        branch: Branch format 5
 
113
    repository: Knit repository format 1
 
114
 
 
115
Control directory:
 
116
         1 branches
 
117
 
 
118
In the working tree:
 
119
         0 unchanged
 
120
         0 modified
 
121
         1 added
 
122
         0 removed
 
123
         0 renamed
 
124
         0 unknown
 
125
         0 ignored
 
126
         0 versioned subdirectories
 
127
 
 
128
Branch history:
 
129
         0 revisions
 
130
 
 
131
Repository:
 
132
         0 revisions
 
133
""", out)
 
134
        self.assertEqual('', err)
 
135
 
 
136
        # Standalone branch - really verbose mode
 
137
        out, err = self.run_bzr('info standalone -vv')
 
138
        self.assertEqualDiff(
 
139
"""Standalone tree (format: knit)
 
140
Location:
 
141
  branch root: standalone
 
142
 
 
143
Format:
 
144
       control: Meta directory format 1
 
145
  working tree: Working tree format 3
 
146
        branch: Branch format 5
 
147
    repository: Knit repository format 1
 
148
 
 
149
Control directory:
 
150
         1 branches
62
151
 
63
152
In the working tree:
64
153
         0 unchanged
76
165
 
77
166
Repository:
78
167
         0 revisions
79
 
         0 KiB
80
 
""" % branch1.bzrdir.root_transport.base, out)
 
168
""", out)
81
169
        self.assertEqual('', err)
82
170
        tree1.commit('commit one')
83
 
        rev = branch1.repository.get_revision(branch1.revision_history()[0])
84
 
        datestring_first = format_date(rev.timestamp, rev.timezone)
 
171
        rev = branch1.repository.get_revision(branch1.last_revision())
 
172
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
85
173
 
86
174
        # Branch standalone with push location
87
175
        branch2 = branch1.bzrdir.sprout('branch').open_branch()
88
176
        branch2.set_push_location(branch1.bzrdir.root_transport.base)
 
177
 
 
178
        out, err = self.run_bzr('info branch')
 
179
        self.assertEqualDiff(
 
180
"""Standalone tree (format: knit)
 
181
Location:
 
182
  branch root: branch
 
183
 
 
184
Related branches:
 
185
    push branch: standalone
 
186
  parent branch: standalone
 
187
""", out)
 
188
        self.assertEqual('', err)
 
189
 
89
190
        out, err = self.run_bzr('info branch --verbose')
90
191
        self.assertEqualDiff(
91
 
"""Standalone tree (format: weave)
 
192
"""Standalone tree (format: knit)
92
193
Location:
93
 
  branch root: %s
 
194
  branch root: branch
94
195
 
95
196
Related branches:
96
 
      parent branch: %s
97
 
  publish to branch: %s
 
197
    push branch: standalone
 
198
  parent branch: standalone
98
199
 
99
200
Format:
100
 
       control: All-in-one format 6
101
 
  working tree: Working tree format 2
102
 
        branch: Branch format 4
103
 
    repository: Weave repository format 6
 
201
       control: Meta directory format 1
 
202
  working tree: Working tree format 3
 
203
        branch: Branch format 5
 
204
    repository: Knit repository format 1
 
205
 
 
206
Control directory:
 
207
         1 branches
104
208
 
105
209
In the working tree:
106
210
         1 unchanged
114
218
 
115
219
Branch history:
116
220
         1 revision
117
 
         1 committer
118
221
         0 days old
119
222
   first revision: %s
120
223
  latest revision: %s
121
224
 
122
225
Repository:
123
226
         1 revision
124
 
         %d KiB
125
 
""" % (branch2.bzrdir.root_transport.base,
126
 
       branch1.bzrdir.root_transport.base,
127
 
       branch1.bzrdir.root_transport.base,
128
 
       datestring_first, datestring_first,
129
 
       # poking at _revision_store isn't all that clean, but neither is
130
 
       # having the ui test dependent on the exact overhead of a given store.
131
 
       branch2.repository._revision_store.total_size(
132
 
        branch2.repository.get_transaction())[1] / 1024,
 
227
""" % (datestring_first, datestring_first,
133
228
       ), out)
134
229
        self.assertEqual('', err)
135
230
 
136
231
        # Branch and bind to standalone, needs upgrade to metadir
137
232
        # (creates backup as unknown)
138
233
        branch1.bzrdir.sprout('bound')
139
 
        knit1_format = bzrdir.format_registry.make_bzrdir('knit')
140
 
        bzrlib.upgrade.upgrade('bound', knit1_format)
141
 
        branch3 = bzrlib.bzrdir.BzrDir.open('bound').open_branch()
 
234
        knit1_format = controldir.format_registry.make_bzrdir('knit')
 
235
        upgrade.upgrade('bound', knit1_format)
 
236
        branch3 = controldir.ControlDir.open('bound').open_branch()
142
237
        branch3.bind(branch1)
143
238
        bound_tree = branch3.bzrdir.open_workingtree()
144
239
        out, err = self.run_bzr('info -v bound')
145
240
        self.assertEqualDiff(
146
241
"""Checkout (format: knit)
147
242
Location:
148
 
       checkout root: %s
149
 
  checkout of branch: %s
 
243
       checkout root: bound
 
244
  checkout of branch: standalone
150
245
 
151
246
Related branches:
152
 
  parent branch: %s
 
247
  parent branch: standalone
153
248
 
154
249
Format:
155
250
       control: Meta directory format 1
157
252
        branch: %s
158
253
    repository: %s
159
254
 
 
255
Control directory:
 
256
         1 branches
 
257
 
160
258
In the working tree:
161
259
         1 unchanged
162
260
         0 modified
163
261
         0 added
164
262
         0 removed
165
263
         0 renamed
166
 
         1 unknown
 
264
         0 unknown
167
265
         0 ignored
168
266
         0 versioned subdirectories
169
267
 
170
268
Branch history:
171
269
         1 revision
172
 
         1 committer
173
270
         0 days old
174
271
   first revision: %s
175
272
  latest revision: %s
176
273
 
177
274
Repository:
178
275
         1 revision
179
 
         %d KiB
180
 
""" % (branch3.bzrdir.root_transport.base,
181
 
       branch1.bzrdir.root_transport.base,
182
 
       branch1.bzrdir.root_transport.base,
183
 
       bound_tree._format.get_format_description(),      
 
276
""" % (bound_tree._format.get_format_description(),
184
277
       branch3._format.get_format_description(),
185
278
       branch3.repository._format.get_format_description(),
186
279
       datestring_first, datestring_first,
187
 
       # poking at _revision_store isn't all that clean, but neither is
188
 
       # having the ui test dependent on the exact overhead of a given store.
189
 
       branch3.repository._revision_store.total_size(
190
 
        branch3.repository.get_transaction())[1] / 1024,
191
280
       ), out)
192
281
        self.assertEqual('', err)
193
282
 
194
283
        # Checkout standalone (same as above, but does not have parent set)
195
 
        branch4 = bzrlib.bzrdir.BzrDir.create_branch_convenience('checkout',
 
284
        branch4 = controldir.ControlDir.create_branch_convenience('checkout',
196
285
            format=knit1_format)
197
286
        branch4.bind(branch1)
198
287
        branch4.bzrdir.open_workingtree().update()
200
289
        self.assertEqualDiff(
201
290
"""Checkout (format: knit)
202
291
Location:
203
 
       checkout root: %s
204
 
  checkout of branch: %s
 
292
       checkout root: checkout
 
293
  checkout of branch: standalone
205
294
 
206
295
Format:
207
296
       control: Meta directory format 1
209
298
        branch: Branch format 5
210
299
    repository: %s
211
300
 
 
301
Control directory:
 
302
         1 branches
 
303
 
212
304
In the working tree:
213
305
         1 unchanged
214
306
         0 modified
221
313
 
222
314
Branch history:
223
315
         1 revision
224
 
         1 committer
225
316
         0 days old
226
317
   first revision: %s
227
318
  latest revision: %s
228
319
 
229
320
Repository:
230
321
         1 revision
231
 
         %d KiB
232
 
""" % (branch4.bzrdir.root_transport.base,
233
 
       branch1.bzrdir.root_transport.base,
234
 
       branch4.repository._format.get_format_description(),
 
322
""" % (branch4.repository._format.get_format_description(),
235
323
       datestring_first, datestring_first,
236
 
       # poking at _revision_store isn't all that clean, but neither is
237
 
       # having the ui test dependent on the exact overhead of a given store.
238
 
       branch4.repository._revision_store.total_size(
239
 
        branch4.repository.get_transaction())[1] / 1024,
240
324
       ), out)
241
325
        self.assertEqual('', err)
242
326
 
244
328
        tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
245
329
        branch5 = tree5.branch
246
330
        out, err = self.run_bzr('info -v lightcheckout')
 
331
        if "metaweave" in controldir.format_registry:
 
332
            format_description = "knit or metaweave"
 
333
        else:
 
334
            format_description = "knit"
247
335
        self.assertEqualDiff(
248
 
"""Lightweight checkout (format: dirstate or dirstate-tags)
 
336
"""Lightweight checkout (format: %s)
249
337
Location:
250
 
  light checkout root: %s
251
 
   checkout of branch: %s
 
338
  light checkout root: lightcheckout
 
339
   checkout of branch: standalone
252
340
 
253
341
Format:
254
342
       control: Meta directory format 1
255
 
  working tree: Working tree format 4
256
 
        branch: Branch format 4
257
 
    repository: Weave repository format 6
 
343
  working tree: Working tree format 3
 
344
        branch: Branch format 5
 
345
    repository: Knit repository format 1
 
346
 
 
347
Control directory:
 
348
         1 branches
258
349
 
259
350
In the working tree:
260
351
         1 unchanged
268
359
 
269
360
Branch history:
270
361
         1 revision
271
 
         1 committer
272
362
         0 days old
273
363
   first revision: %s
274
364
  latest revision: %s
275
365
 
276
366
Repository:
277
367
         1 revision
278
 
         0 KiB
279
 
""" % (tree5.bzrdir.root_transport.base,
280
 
       branch1.bzrdir.root_transport.base,
281
 
       datestring_first, datestring_first,
282
 
       ), out)
 
368
""" % (format_description, datestring_first, datestring_first,), out)
283
369
        self.assertEqual('', err)
284
370
 
285
371
        # Update initial standalone branch
286
372
        self.build_tree(['standalone/b'])
287
373
        tree1.add('b')
288
374
        tree1.commit('commit two')
289
 
        rev = branch1.repository.get_revision(branch1.revision_history()[-1])
290
 
        datestring_last = format_date(rev.timestamp, rev.timezone)
 
375
        rev = branch1.repository.get_revision(branch1.last_revision())
 
376
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
291
377
 
292
378
        # Out of date branched standalone branch will not be detected
293
379
        out, err = self.run_bzr('info -v branch')
294
380
        self.assertEqualDiff(
295
 
"""Standalone tree (format: weave)
 
381
"""Standalone tree (format: knit)
296
382
Location:
297
 
  branch root: %s
 
383
  branch root: branch
298
384
 
299
385
Related branches:
300
 
      parent branch: %s
301
 
  publish to branch: %s
 
386
    push branch: standalone
 
387
  parent branch: standalone
302
388
 
303
389
Format:
304
 
       control: All-in-one format 6
305
 
  working tree: Working tree format 2
306
 
        branch: Branch format 4
307
 
    repository: Weave repository format 6
 
390
       control: Meta directory format 1
 
391
  working tree: Working tree format 3
 
392
        branch: Branch format 5
 
393
    repository: Knit repository format 1
 
394
 
 
395
Control directory:
 
396
         1 branches
308
397
 
309
398
In the working tree:
310
399
         1 unchanged
318
407
 
319
408
Branch history:
320
409
         1 revision
321
 
         1 committer
322
410
         0 days old
323
411
   first revision: %s
324
412
  latest revision: %s
325
413
 
326
414
Repository:
327
415
         1 revision
328
 
         0 KiB
329
 
""" % (branch2.bzrdir.root_transport.base,
330
 
       branch1.bzrdir.root_transport.base,
331
 
       branch1.bzrdir.root_transport.base,
332
 
       datestring_first, datestring_first,
 
416
""" % (datestring_first, datestring_first,
333
417
       ), out)
334
418
        self.assertEqual('', err)
335
419
 
338
422
        self.assertEqualDiff(
339
423
"""Checkout (format: knit)
340
424
Location:
341
 
       checkout root: %s
342
 
  checkout of branch: %s
 
425
       checkout root: bound
 
426
  checkout of branch: standalone
343
427
 
344
428
Related branches:
345
 
  parent branch: %s
 
429
  parent branch: standalone
346
430
 
347
431
Format:
348
432
       control: Meta directory format 1
350
434
        branch: Branch format 5
351
435
    repository: %s
352
436
 
 
437
Control directory:
 
438
         1 branches
 
439
 
353
440
Branch is out of date: missing 1 revision.
354
441
 
355
442
In the working tree:
358
445
         0 added
359
446
         0 removed
360
447
         0 renamed
361
 
         1 unknown
 
448
         0 unknown
362
449
         0 ignored
363
450
         0 versioned subdirectories
364
451
 
365
452
Branch history:
366
453
         1 revision
367
 
         1 committer
368
454
         0 days old
369
455
   first revision: %s
370
456
  latest revision: %s
371
457
 
372
458
Repository:
373
459
         1 revision
374
 
         %d KiB
375
 
""" % (branch3.bzrdir.root_transport.base,
376
 
       branch1.bzrdir.root_transport.base,
377
 
       branch1.bzrdir.root_transport.base,
378
 
       branch3.repository._format.get_format_description(),
 
460
""" % (branch3.repository._format.get_format_description(),
379
461
       datestring_first, datestring_first,
380
 
       # poking at _revision_store isn't all that clean, but neither is
381
 
       # having the ui test dependent on the exact overhead of a given store.
382
 
       branch3.repository._revision_store.total_size(
383
 
        branch3.repository.get_transaction())[1] / 1024,
384
462
       ), out)
385
463
        self.assertEqual('', err)
386
464
 
389
467
        self.assertEqualDiff(
390
468
"""Checkout (format: knit)
391
469
Location:
392
 
       checkout root: %s
393
 
  checkout of branch: %s
 
470
       checkout root: checkout
 
471
  checkout of branch: standalone
394
472
 
395
473
Format:
396
474
       control: Meta directory format 1
398
476
        branch: Branch format 5
399
477
    repository: %s
400
478
 
 
479
Control directory:
 
480
         1 branches
 
481
 
401
482
Branch is out of date: missing 1 revision.
402
483
 
403
484
In the working tree:
412
493
 
413
494
Branch history:
414
495
         1 revision
415
 
         1 committer
416
496
         0 days old
417
497
   first revision: %s
418
498
  latest revision: %s
419
499
 
420
500
Repository:
421
501
         1 revision
422
 
         %d KiB
423
 
""" % (branch4.bzrdir.root_transport.base,
424
 
       branch1.bzrdir.root_transport.base,
425
 
       branch4.repository._format.get_format_description(),
 
502
""" % (branch4.repository._format.get_format_description(),
426
503
       datestring_first, datestring_first,
427
 
       # poking at _revision_store isn't all that clean, but neither is
428
 
       # having the ui test dependent on the exact overhead of a given store.
429
 
       branch4.repository._revision_store.total_size(
430
 
        branch4.repository.get_transaction())[1] / 1024,
431
504
       ), out)
432
505
        self.assertEqual('', err)
433
506
 
434
507
        # Out of date lightweight checkout
435
508
        out, err = self.run_bzr('info lightcheckout --verbose')
436
509
        self.assertEqualDiff(
437
 
"""Lightweight checkout (format: dirstate or dirstate-tags)
 
510
"""Lightweight checkout (format: %s)
438
511
Location:
439
 
  light checkout root: %s
440
 
   checkout of branch: %s
 
512
  light checkout root: lightcheckout
 
513
   checkout of branch: standalone
441
514
 
442
515
Format:
443
516
       control: Meta directory format 1
444
 
  working tree: Working tree format 4
445
 
        branch: Branch format 4
446
 
    repository: Weave repository format 6
 
517
  working tree: Working tree format 3
 
518
        branch: Branch format 5
 
519
    repository: Knit repository format 1
 
520
 
 
521
Control directory:
 
522
         1 branches
447
523
 
448
524
Working tree is out of date: missing 1 revision.
449
525
 
459
535
 
460
536
Branch history:
461
537
         2 revisions
462
 
         1 committer
463
538
         0 days old
464
539
   first revision: %s
465
540
  latest revision: %s
466
541
 
467
542
Repository:
468
543
         2 revisions
469
 
         0 KiB
470
 
""" % (tree5.bzrdir.root_transport.base,
471
 
       branch1.bzrdir.root_transport.base,
472
 
       datestring_first, datestring_last,
473
 
       ), out)
 
544
""" % (format_description, datestring_first, datestring_last,), out)
474
545
        self.assertEqual('', err)
475
546
 
476
547
    def test_info_standalone_no_tree(self):
477
548
        # create standalone branch without a working tree
478
 
        format = bzrdir.format_registry.make_bzrdir('default')
 
549
        format = controldir.format_registry.make_bzrdir('default')
479
550
        branch = self.make_branch('branch')
480
551
        repo = branch.repository
481
552
        out, err = self.run_bzr('info branch -v')
482
553
        self.assertEqualDiff(
483
 
"""Standalone branch (format: dirstate or knit)
 
554
"""Standalone branch (format: %s)
484
555
Location:
485
 
  branch root: %s
 
556
  branch root: branch
486
557
 
487
558
Format:
488
559
       control: Meta directory format 1
489
560
        branch: %s
490
561
    repository: %s
491
562
 
 
563
Control directory:
 
564
         1 branches
 
565
 
492
566
Branch history:
493
567
         0 revisions
494
 
         0 committers
495
568
 
496
569
Repository:
497
570
         0 revisions
498
 
         0 KiB
499
 
""" % (branch.bzrdir.root_transport.base,
 
571
""" % (info.describe_format(repo.bzrdir, repo, branch, None),
500
572
       format.get_branch_format().get_format_description(),
501
573
       format.repository_format.get_format_description(),
502
574
       ), out)
503
575
        self.assertEqual('', err)
504
576
 
505
577
    def test_info_shared_repository(self):
506
 
        format = bzrdir.format_registry.make_bzrdir('knit')
 
578
        format = controldir.format_registry.make_bzrdir('knit')
507
579
        transport = self.get_transport()
508
580
 
509
581
        # Create shared repository
519
591
       control: Meta directory format 1
520
592
    repository: %s
521
593
 
 
594
Control directory:
 
595
         0 branches
 
596
 
522
597
Repository:
523
598
         0 revisions
524
 
         0 KiB
525
 
""" % (repo.bzrdir.root_transport.base,
526
 
       format.repository_format.get_format_description(),
 
599
""" % ('repo', format.repository_format.get_format_description(),
527
600
       ), out)
528
601
        self.assertEqual('', err)
529
602
 
530
603
        # Create branch inside shared repository
531
604
        repo.bzrdir.root_transport.mkdir('branch')
532
 
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
533
 
            format=format)
 
605
        branch1 = controldir.ControlDir.create_branch_convenience(
 
606
            'repo/branch', format=format)
534
607
        out, err = self.run_bzr('info -v repo/branch')
535
608
        self.assertEqualDiff(
536
609
"""Repository branch (format: dirstate or knit)
537
610
Location:
538
 
  shared repository: %s
539
 
  repository branch: branch
 
611
  shared repository: repo
 
612
  repository branch: repo/branch
540
613
 
541
614
Format:
542
615
       control: Meta directory format 1
543
616
        branch: %s
544
617
    repository: %s
545
618
 
 
619
Control directory:
 
620
         1 branches
 
621
 
546
622
Branch history:
547
623
         0 revisions
548
 
         0 committers
549
624
 
550
625
Repository:
551
626
         0 revisions
552
 
         0 KiB
553
 
""" % (repo.bzrdir.root_transport.base,
554
 
       format.get_branch_format().get_format_description(),
 
627
""" % (format.get_branch_format().get_format_description(),
555
628
       format.repository_format.get_format_description(),
556
629
       ), out)
557
630
        self.assertEqual('', err)
559
632
        # Create lightweight checkout
560
633
        transport.mkdir('tree')
561
634
        transport.mkdir('tree/lightcheckout')
562
 
        tree2 = branch1.create_checkout('tree/lightcheckout', 
 
635
        tree2 = branch1.create_checkout('tree/lightcheckout',
563
636
            lightweight=True)
564
637
        branch2 = tree2.branch
565
638
        self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
574
647
        self.build_tree(['tree/lightcheckout/a'])
575
648
        tree2.add('a')
576
649
        tree2.commit('commit one')
577
 
        rev = repo.get_revision(branch2.revision_history()[0])
578
 
        datestring_first = format_date(rev.timestamp, rev.timezone)
 
650
        rev = repo.get_revision(branch2.last_revision())
 
651
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
579
652
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
580
653
        self.assertEqualDiff(
581
 
"""Lightweight checkout (format: dirstate or dirstate-tags)
 
654
"""Lightweight checkout (format: %s)
582
655
Location:
583
 
  light checkout root: %s
584
 
   checkout of branch: %s
585
 
    shared repository: %s
 
656
  light checkout root: tree/lightcheckout
 
657
   checkout of branch: repo/branch
 
658
    shared repository: repo
586
659
 
587
660
Format:
588
661
       control: Meta directory format 1
589
 
  working tree: Working tree format 4
 
662
  working tree: Working tree format 6
590
663
        branch: %s
591
664
    repository: %s
592
665
 
 
666
Control directory:
 
667
         1 branches
 
668
 
593
669
In the working tree:
594
670
         1 unchanged
595
671
         0 modified
602
678
 
603
679
Branch history:
604
680
         1 revision
605
 
         1 committer
606
681
         0 days old
607
682
   first revision: %s
608
683
  latest revision: %s
609
684
 
610
685
Repository:
611
686
         1 revision
612
 
         %d KiB
613
 
""" % (tree2.bzrdir.root_transport.base,
614
 
       tree2.branch.bzrdir.root_transport.base,
615
 
       repo.bzrdir.root_transport.base,
616
 
       format.get_branch_format().get_format_description(),
 
687
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
617
688
       format.repository_format.get_format_description(),
618
689
       datestring_first, datestring_first,
619
 
       # poking at _revision_store isn't all that clean, but neither is
620
 
       # having the ui test dependent on the exact overhead of a given store.
621
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
622
690
       ), out)
623
691
        self.assertEqual('', err)
624
692
 
625
693
        # Out of date checkout
626
694
        out, err = self.run_bzr('info -v tree/checkout')
627
695
        self.assertEqualDiff(
628
 
"""Checkout (format: dirstate)
 
696
"""Checkout (format: unnamed)
629
697
Location:
630
 
       checkout root: %s
631
 
  checkout of branch: %s
 
698
       checkout root: tree/checkout
 
699
  checkout of branch: repo/branch
632
700
 
633
701
Format:
634
702
       control: Meta directory format 1
635
 
  working tree: Working tree format 4
 
703
  working tree: Working tree format 6
636
704
        branch: %s
637
705
    repository: %s
638
706
 
 
707
Control directory:
 
708
         1 branches
 
709
 
639
710
Branch is out of date: missing 1 revision.
640
711
 
641
712
In the working tree:
650
721
 
651
722
Branch history:
652
723
         0 revisions
653
 
         0 committers
654
724
 
655
725
Repository:
656
726
         0 revisions
657
 
         0 KiB
658
 
""" % (tree3.bzrdir.root_transport.base,
659
 
       branch1.bzrdir.root_transport.base,
660
 
       format.get_branch_format().get_format_description(),
 
727
""" % (format.get_branch_format().get_format_description(),
661
728
       format.repository_format.get_format_description(),
662
729
       ), out)
663
730
        self.assertEqual('', err)
668
735
        tree3.add('b')
669
736
        out, err = self.run_bzr('info tree/checkout --verbose')
670
737
        self.assertEqualDiff(
671
 
"""Checkout (format: dirstate)
 
738
"""Checkout (format: unnamed)
672
739
Location:
673
 
       checkout root: %s
674
 
  checkout of branch: %s
 
740
       checkout root: tree/checkout
 
741
  checkout of branch: repo/branch
675
742
 
676
743
Format:
677
744
       control: Meta directory format 1
678
 
  working tree: Working tree format 4
 
745
  working tree: Working tree format 6
679
746
        branch: %s
680
747
    repository: %s
681
748
 
 
749
Control directory:
 
750
         1 branches
 
751
 
682
752
In the working tree:
683
753
         1 unchanged
684
754
         0 modified
691
761
 
692
762
Branch history:
693
763
         1 revision
694
 
         1 committer
695
764
         0 days old
696
765
   first revision: %s
697
766
  latest revision: %s
698
767
 
699
768
Repository:
700
769
         1 revision
701
 
         %d KiB
702
 
""" % (tree3.bzrdir.root_transport.base, branch1.bzrdir.root_transport.base,
703
 
       format.get_branch_format().get_format_description(),
 
770
""" % (format.get_branch_format().get_format_description(),
704
771
       format.repository_format.get_format_description(),
705
772
       datestring_first, datestring_first,
706
 
       # poking at _revision_store isn't all that clean, but neither is
707
 
       # having the ui test dependent on the exact overhead of a given store.
708
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
709
773
       ), out)
710
774
        self.assertEqual('', err)
711
775
        tree3.commit('commit two')
712
776
 
713
777
        # Out of date lightweight checkout
714
 
        rev = repo.get_revision(branch1.revision_history()[-1])
715
 
        datestring_last = format_date(rev.timestamp, rev.timezone)
 
778
        rev = repo.get_revision(branch1.last_revision())
 
779
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
716
780
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
717
781
        self.assertEqualDiff(
718
 
"""Lightweight checkout (format: dirstate or dirstate-tags)
 
782
"""Lightweight checkout (format: %s)
719
783
Location:
720
 
  light checkout root: %s
721
 
   checkout of branch: %s
722
 
    shared repository: %s
 
784
  light checkout root: tree/lightcheckout
 
785
   checkout of branch: repo/branch
 
786
    shared repository: repo
723
787
 
724
788
Format:
725
789
       control: Meta directory format 1
726
 
  working tree: Working tree format 4
 
790
  working tree: Working tree format 6
727
791
        branch: %s
728
792
    repository: %s
729
793
 
 
794
Control directory:
 
795
         1 branches
 
796
 
730
797
Working tree is out of date: missing 1 revision.
731
798
 
732
799
In the working tree:
741
808
 
742
809
Branch history:
743
810
         2 revisions
744
 
         1 committer
745
811
         0 days old
746
812
   first revision: %s
747
813
  latest revision: %s
748
814
 
749
815
Repository:
750
816
         2 revisions
751
 
         %d KiB
752
 
""" % (tree2.bzrdir.root_transport.base,
753
 
       tree2.branch.bzrdir.root_transport.base,
754
 
       repo.bzrdir.root_transport.base,
755
 
       format.get_branch_format().get_format_description(),
 
817
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
756
818
       format.repository_format.get_format_description(),
757
819
       datestring_first, datestring_last,
758
 
       # poking at _revision_store isn't all that clean, but neither is
759
 
       # having the ui test dependent on the exact overhead of a given store.
760
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
761
820
       ), out)
762
821
        self.assertEqual('', err)
763
822
 
766
825
        self.assertEqualDiff(
767
826
"""Repository branch (format: dirstate or knit)
768
827
Location:
769
 
  shared repository: %s
770
 
  repository branch: branch
 
828
  shared repository: repo
 
829
  repository branch: repo/branch
771
830
 
772
831
Format:
773
832
       control: Meta directory format 1
774
833
        branch: %s
775
834
    repository: %s
776
835
 
 
836
Control directory:
 
837
         1 branches
 
838
 
777
839
Branch history:
778
840
         2 revisions
779
 
         1 committer
780
841
         0 days old
781
842
   first revision: %s
782
843
  latest revision: %s
783
844
 
784
845
Repository:
785
846
         2 revisions
786
 
         %d KiB
787
 
""" % (repo.bzrdir.root_transport.base,
788
 
       format.get_branch_format().get_format_description(),
 
847
""" % (format.get_branch_format().get_format_description(),
789
848
       format.repository_format.get_format_description(),
790
849
       datestring_first, datestring_last,
791
 
       # poking at _revision_store isn't all that clean, but neither is
792
 
       # having the ui test dependent on the exact overhead of a given store.
793
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
794
850
       ), out)
795
851
        self.assertEqual('', err)
796
852
 
799
855
        self.assertEqualDiff(
800
856
"""Shared repository (format: dirstate or dirstate-tags or knit)
801
857
Location:
802
 
  shared repository: %s
 
858
  shared repository: repo
803
859
 
804
860
Format:
805
861
       control: Meta directory format 1
806
862
    repository: %s
807
863
 
 
864
Control directory:
 
865
         0 branches
 
866
 
808
867
Repository:
809
868
         2 revisions
810
 
         %d KiB
811
 
""" % (repo.bzrdir.root_transport.base,
812
 
       format.repository_format.get_format_description(),
813
 
       # poking at _revision_store isn't all that clean, but neither is
814
 
       # having the ui test dependent on the exact overhead of a given store.
815
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
 
869
""" % (format.repository_format.get_format_description(),
816
870
       ), out)
817
871
        self.assertEqual('', err)
818
872
 
819
873
    def test_info_shared_repository_with_trees(self):
820
 
        format = bzrdir.format_registry.make_bzrdir('knit')
 
874
        format = controldir.format_registry.make_bzrdir('knit')
821
875
        transport = self.get_transport()
822
876
 
823
877
        # Create shared repository with working trees
827
881
        self.assertEqualDiff(
828
882
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
829
883
Location:
830
 
  shared repository: %s
 
884
  shared repository: repo
831
885
 
832
886
Format:
833
887
       control: Meta directory format 1
834
888
    repository: %s
835
889
 
 
890
Control directory:
 
891
         0 branches
 
892
 
836
893
Create working tree for new branches inside the repository.
837
894
 
838
895
Repository:
839
896
         0 revisions
840
 
         0 KiB
841
 
""" % (repo.bzrdir.root_transport.base,
842
 
       format.repository_format.get_format_description(),
 
897
""" % (format.repository_format.get_format_description(),
843
898
       ), out)
844
899
        self.assertEqual('', err)
845
900
 
846
901
        # Create two branches
847
902
        repo.bzrdir.root_transport.mkdir('branch1')
848
 
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
 
903
        branch1 = controldir.ControlDir.create_branch_convenience('repo/branch1',
849
904
            format=format)
850
905
        branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
851
906
 
854
909
        self.assertEqualDiff(
855
910
"""Repository tree (format: knit)
856
911
Location:
857
 
  shared repository: %s
858
 
  repository branch: branch1
 
912
  shared repository: repo
 
913
  repository branch: repo/branch1
859
914
 
860
915
Format:
861
916
       control: Meta directory format 1
863
918
        branch: %s
864
919
    repository: %s
865
920
 
 
921
Control directory:
 
922
         1 branches
 
923
 
866
924
In the working tree:
867
925
         0 unchanged
868
926
         0 modified
875
933
 
876
934
Branch history:
877
935
         0 revisions
878
 
         0 committers
879
936
 
880
937
Repository:
881
938
         0 revisions
882
 
         0 KiB
883
 
""" % (repo.bzrdir.root_transport.base,
884
 
       format.get_branch_format().get_format_description(),
 
939
""" % (format.get_branch_format().get_format_description(),
885
940
       format.repository_format.get_format_description(),
886
941
       ), out)
887
942
        self.assertEqual('', err)
891
946
        tree1 = branch1.bzrdir.open_workingtree()
892
947
        tree1.add('a')
893
948
        tree1.commit('commit one')
894
 
        rev = repo.get_revision(branch1.revision_history()[0])
895
 
        datestring_first = format_date(rev.timestamp, rev.timezone)
 
949
        rev = repo.get_revision(branch1.last_revision())
 
950
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
896
951
        out, err = self.run_bzr('info -v repo/branch1')
897
952
        self.assertEqualDiff(
898
953
"""Repository tree (format: knit)
899
954
Location:
900
 
  shared repository: %s
901
 
  repository branch: branch1
 
955
  shared repository: repo
 
956
  repository branch: repo/branch1
902
957
 
903
958
Format:
904
959
       control: Meta directory format 1
906
961
        branch: %s
907
962
    repository: %s
908
963
 
 
964
Control directory:
 
965
         1 branches
 
966
 
909
967
In the working tree:
910
968
         1 unchanged
911
969
         0 modified
918
976
 
919
977
Branch history:
920
978
         1 revision
921
 
         1 committer
922
979
         0 days old
923
980
   first revision: %s
924
981
  latest revision: %s
925
982
 
926
983
Repository:
927
984
         1 revision
928
 
         %d KiB
929
 
""" % (repo.bzrdir.root_transport.base,
930
 
       format.get_branch_format().get_format_description(),
 
985
""" % (format.get_branch_format().get_format_description(),
931
986
       format.repository_format.get_format_description(),
932
987
       datestring_first, datestring_first,
933
 
       # poking at _revision_store isn't all that clean, but neither is
934
 
       # having the ui test dependent on the exact overhead of a given store.
935
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
936
988
       ), out)
937
989
        self.assertEqual('', err)
938
990
 
941
993
        self.assertEqualDiff(
942
994
"""Repository tree (format: knit)
943
995
Location:
944
 
  shared repository: %s
945
 
  repository branch: branch2
 
996
  shared repository: repo
 
997
  repository branch: repo/branch2
946
998
 
947
999
Related branches:
948
 
  parent branch: %s
 
1000
  parent branch: repo/branch1
949
1001
 
950
1002
Format:
951
1003
       control: Meta directory format 1
953
1005
        branch: %s
954
1006
    repository: %s
955
1007
 
 
1008
Control directory:
 
1009
         1 branches
 
1010
 
956
1011
In the working tree:
957
1012
         0 unchanged
958
1013
         0 modified
965
1020
 
966
1021
Branch history:
967
1022
         0 revisions
968
 
         0 committers
969
1023
 
970
1024
Repository:
971
1025
         1 revision
972
 
         %d KiB
973
 
""" % (repo.bzrdir.root_transport.base,
974
 
       branch1.bzrdir.root_transport.base,
975
 
       format.get_branch_format().get_format_description(),
 
1026
""" % (format.get_branch_format().get_format_description(),
976
1027
       format.repository_format.get_format_description(),
977
 
       # poking at _revision_store isn't all that clean, but neither is
978
 
       # having the ui test dependent on the exact overhead of a given store.
979
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
980
1028
       ), out)
981
1029
        self.assertEqual('', err)
982
1030
 
987
1035
        self.assertEqualDiff(
988
1036
"""Repository tree (format: knit)
989
1037
Location:
990
 
  shared repository: %s
991
 
  repository branch: branch2
 
1038
  shared repository: repo
 
1039
  repository branch: repo/branch2
992
1040
 
993
1041
Related branches:
994
 
  parent branch: %s
 
1042
  parent branch: repo/branch1
995
1043
 
996
1044
Format:
997
1045
       control: Meta directory format 1
999
1047
        branch: %s
1000
1048
    repository: %s
1001
1049
 
 
1050
Control directory:
 
1051
         1 branches
 
1052
 
1002
1053
In the working tree:
1003
1054
         1 unchanged
1004
1055
         0 modified
1011
1062
 
1012
1063
Branch history:
1013
1064
         1 revision
1014
 
         1 committer
1015
1065
         0 days old
1016
1066
   first revision: %s
1017
1067
  latest revision: %s
1018
1068
 
1019
1069
Repository:
1020
1070
         1 revision
1021
 
         %d KiB
1022
 
""" % (repo.bzrdir.root_transport.base,
1023
 
       branch1.bzrdir.root_transport.base,
1024
 
       format.get_branch_format().get_format_description(),
 
1071
""" % (format.get_branch_format().get_format_description(),
1025
1072
       format.repository_format.get_format_description(),
1026
1073
       datestring_first, datestring_first,
1027
 
       # poking at _revision_store isn't all that clean, but neither is
1028
 
       # having the ui test dependent on the exact overhead of a given store.
1029
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
1030
1074
       ), out)
1031
1075
        self.assertEqual('', err)
1032
1076
 
1035
1079
        self.assertEqualDiff(
1036
1080
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1037
1081
Location:
1038
 
  shared repository: %s
 
1082
  shared repository: repo
1039
1083
 
1040
1084
Format:
1041
1085
       control: Meta directory format 1
1042
1086
    repository: %s
1043
1087
 
 
1088
Control directory:
 
1089
         0 branches
 
1090
 
1044
1091
Create working tree for new branches inside the repository.
1045
1092
 
1046
1093
Repository:
1047
1094
         1 revision
1048
 
         %d KiB
1049
 
""" % (repo.bzrdir.root_transport.base,
1050
 
       format.repository_format.get_format_description(),
1051
 
       # poking at _revision_store isn't all that clean, but neither is
1052
 
       # having the ui test dependent on the exact overhead of a given store.
1053
 
       repo._revision_store.total_size(repo.get_transaction())[1] / 1024,
 
1095
""" % (format.repository_format.get_format_description(),
1054
1096
       ),
1055
1097
       out)
1056
1098
        self.assertEqual('', err)
1057
 
    
 
1099
 
1058
1100
    def test_info_shared_repository_with_tree_in_root(self):
1059
 
        format = bzrdir.format_registry.make_bzrdir('knit')
 
1101
        format = controldir.format_registry.make_bzrdir('knit')
1060
1102
        transport = self.get_transport()
1061
1103
 
1062
1104
        # Create shared repository with working trees
1066
1108
        self.assertEqualDiff(
1067
1109
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1068
1110
Location:
1069
 
  shared repository: %s
 
1111
  shared repository: repo
1070
1112
 
1071
1113
Format:
1072
1114
       control: Meta directory format 1
1073
1115
    repository: %s
1074
1116
 
 
1117
Control directory:
 
1118
         0 branches
 
1119
 
1075
1120
Create working tree for new branches inside the repository.
1076
1121
 
1077
1122
Repository:
1078
1123
         0 revisions
1079
 
         0 KiB
1080
 
""" % (repo.bzrdir.root_transport.base,
1081
 
       format.repository_format.get_format_description(),
 
1124
""" % (format.repository_format.get_format_description(),
1082
1125
       ), out)
1083
1126
        self.assertEqual('', err)
1084
1127
 
1090
1133
        self.assertEqualDiff(
1091
1134
"""Repository tree (format: knit)
1092
1135
Location:
1093
 
  shared repository: %s
1094
 
  repository branch: .
 
1136
  shared repository: repo
 
1137
  repository branch: repo
1095
1138
 
1096
1139
Format:
1097
1140
       control: Meta directory format 1
1099
1142
        branch: %s
1100
1143
    repository: %s
1101
1144
 
 
1145
Control directory:
 
1146
         1 branches
 
1147
 
1102
1148
In the working tree:
1103
1149
         0 unchanged
1104
1150
         0 modified
1111
1157
 
1112
1158
Branch history:
1113
1159
         0 revisions
1114
 
         0 committers
1115
1160
 
1116
1161
Repository:
1117
1162
         0 revisions
1118
 
         0 KiB
1119
 
""" % (repo.bzrdir.root_transport.base,
1120
 
       format.get_branch_format().get_format_description(),
 
1163
""" % (format.get_branch_format().get_format_description(),
1121
1164
       format.repository_format.get_format_description(),
1122
1165
       ), out)
1123
1166
        self.assertEqual('', err)
1124
1167
 
1125
 
    def assertCheckoutStatusOutput(self, 
 
1168
    def test_info_repository_hook(self):
 
1169
        format = controldir.format_registry.make_bzrdir('knit')
 
1170
        def repo_info(repo, stats, outf):
 
1171
            outf.write("more info\n")
 
1172
        info.hooks.install_named_hook('repository', repo_info, None)
 
1173
        # Create shared repository with working trees
 
1174
        repo = self.make_repository('repo', shared=True, format=format)
 
1175
        out, err = self.run_bzr('info -v repo')
 
1176
        self.assertEqualDiff(
 
1177
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
 
1178
Location:
 
1179
  shared repository: repo
 
1180
 
 
1181
Format:
 
1182
       control: Meta directory format 1
 
1183
    repository: %s
 
1184
 
 
1185
Control directory:
 
1186
         0 branches
 
1187
 
 
1188
Create working tree for new branches inside the repository.
 
1189
 
 
1190
Repository:
 
1191
         0 revisions
 
1192
more info
 
1193
""" % (format.repository_format.get_format_description(),
 
1194
       ), out)
 
1195
        self.assertEqual('', err)
 
1196
 
 
1197
    def test_info_unshared_repository_with_colocated_branches(self):
 
1198
        format = controldir.format_registry.make_bzrdir('development-colo')
 
1199
        transport = self.get_transport()
 
1200
 
 
1201
        # Create unshared repository
 
1202
        repo = self.make_repository('repo', shared=False, format=format)
 
1203
        repo.set_make_working_trees(True)
 
1204
        repo.bzrdir.create_branch(name='foo')
 
1205
        out, err = self.run_bzr('info repo')
 
1206
        self.assertEqualDiff(
 
1207
"""Unshared repository with trees and colocated branches (format: development-colo)
 
1208
Location:
 
1209
  repository: repo
 
1210
""", out)
 
1211
        self.assertEqual('', err)
 
1212
 
 
1213
    def assertCheckoutStatusOutput(self,
1126
1214
        command_string, lco_tree, shared_repo=None,
1127
1215
        repo_branch=None,
1128
1216
        tree_locked=False,
1137
1225
        allow us, the test writers, to document what *should* be present in
1138
1226
        the output. Removing this separation would remove the value of the
1139
1227
        tests.
1140
 
        
 
1228
 
1141
1229
        :param path: the path to the light checkout.
1142
1230
        :param lco_tree: the tree object for the light checkout.
1143
1231
        :param shared_repo: A shared repository is in use, expect that in
1147
1235
        :param tree_locked: If true, expect the tree to be locked.
1148
1236
        :param branch_locked: If true, expect the branch to be locked.
1149
1237
        :param repo_locked: If true, expect the repository to be locked.
1150
 
        :param verbose: If true, expect verbose output
 
1238
            Note that the lco_tree.branch.repository is inspected, and if is not
 
1239
            actually locked then this parameter is overridden. This is because
 
1240
            pack repositories do not have any public API for obtaining an
 
1241
            exclusive repository wide lock.
 
1242
        :param verbose: verbosity level: 2 or higher to show committers
1151
1243
        """
1152
 
        if tree_locked and sys.platform == 'win32':
1153
 
            # We expect this to fail because of locking errors. (A write-locked
1154
 
            # file cannot be read-locked in the same process).
 
1244
        def friendly_location(url):
 
1245
            path = urlutils.unescape_for_display(url, 'ascii')
 
1246
            try:
 
1247
                return osutils.relpath(osutils.getcwd(), path)
 
1248
            except errors.PathNotChild:
 
1249
                return path
 
1250
 
 
1251
        if tree_locked:
 
1252
            # We expect this to fail because of locking errors.
 
1253
            # (A write-locked file cannot be read-locked
 
1254
            # in the different process -- either on win32 or on linux).
1155
1255
            # This should be removed when the locking errors are fixed.
1156
 
            args = command_string.split(' ')
1157
 
            self.run_bzr_error([], 'info', *args)
1158
 
            return
 
1256
            self.expectFailure('OS locks are exclusive '
 
1257
                'for different processes (Bug #174055)',
 
1258
                self.run_bzr_subprocess,
 
1259
                'info ' + command_string)
1159
1260
        out, err = self.run_bzr('info %s' % command_string)
1160
1261
        description = {
1161
1262
            (True, True): 'Lightweight checkout',
1163
1264
            (False, True): 'Lightweight checkout',
1164
1265
            (False, False): 'Checkout',
1165
1266
            }[(shared_repo is not None, light_checkout)]
1166
 
        format = {True: 'dirstate or dirstate-tags',
1167
 
                  False: 'dirstate'}[light_checkout]
 
1267
        format = {True: self._repo_strings,
 
1268
                  False: 'unnamed'}[light_checkout]
 
1269
        if repo_locked:
 
1270
            repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1168
1271
        if repo_locked or branch_locked or tree_locked:
1169
1272
            def locked_message(a_bool):
1170
1273
                if a_bool:
1186
1289
        extra_space = ''
1187
1290
        if light_checkout:
1188
1291
            tree_data = ("  light checkout root: %s\n" %
1189
 
                lco_tree.bzrdir.root_transport.base)
 
1292
                friendly_location(lco_tree.bzrdir.root_transport.base))
1190
1293
            extra_space = ' '
1191
1294
        if lco_tree.branch.get_bound_location() is not None:
1192
1295
            tree_data += ("%s       checkout root: %s\n" % (extra_space,
1193
 
                lco_tree.branch.bzrdir.root_transport.base))
 
1296
                friendly_location(lco_tree.branch.bzrdir.root_transport.base)))
1194
1297
        if shared_repo is not None:
1195
1298
            branch_data = (
1196
1299
                "   checkout of branch: %s\n"
1197
1300
                "    shared repository: %s\n" %
1198
 
                (repo_branch.bzrdir.root_transport.base,
1199
 
                 shared_repo.bzrdir.root_transport.base))
 
1301
                (friendly_location(repo_branch.bzrdir.root_transport.base),
 
1302
                 friendly_location(shared_repo.bzrdir.root_transport.base)))
1200
1303
        elif repo_branch is not None:
1201
1304
            branch_data = (
1202
1305
                "%s  checkout of branch: %s\n" %
1203
1306
                (extra_space,
1204
 
                 repo_branch.bzrdir.root_transport.base))
 
1307
                 friendly_location(repo_branch.bzrdir.root_transport.base)))
1205
1308
        else:
1206
1309
            branch_data = ("   checkout of branch: %s\n" %
1207
1310
                lco_tree.branch.bzrdir.root_transport.base)
1208
 
        
1209
 
        if verbose:
 
1311
 
 
1312
        if verbose >= 2:
1210
1313
            verbose_info = '         0 committers\n'
1211
1314
        else:
1212
1315
            verbose_info = ''
1213
 
            
 
1316
 
1214
1317
        self.assertEqualDiff(
1215
1318
"""%s (format: %s)
1216
1319
Location:
1221
1324
        branch: %s
1222
1325
    repository: %s
1223
1326
%s
 
1327
Control directory:
 
1328
         1 branches
 
1329
 
1224
1330
In the working tree:
1225
1331
         0 unchanged
1226
1332
         0 modified
1236
1342
%s
1237
1343
Repository:
1238
1344
         0 revisions
1239
 
         0 KiB
1240
1345
""" %  (description,
1241
1346
        format,
1242
1347
        tree_data,
1253
1358
        transport = self.get_transport()
1254
1359
        # Create shared repository with a branch
1255
1360
        repo = self.make_repository('repo', shared=True,
1256
 
                                    format=bzrlib.bzrdir.BzrDirMetaFormat1())
 
1361
                                    format=bzrdir.BzrDirMetaFormat1())
1257
1362
        repo.set_make_working_trees(False)
1258
1363
        repo.bzrdir.root_transport.mkdir('branch')
1259
 
        repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1260
 
                                    format=bzrlib.bzrdir.BzrDirMetaFormat1())
 
1364
        repo_branch = controldir.ControlDir.create_branch_convenience(
 
1365
            'repo/branch', format=bzrdir.BzrDirMetaFormat1())
1261
1366
        # Do a heavy checkout
1262
1367
        transport.mkdir('tree')
1263
1368
        transport.mkdir('tree/checkout')
1264
 
        co_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1265
 
            format=bzrlib.bzrdir.BzrDirMetaFormat1())
 
1369
        co_branch = controldir.ControlDir.create_branch_convenience(
 
1370
            'tree/checkout', format=bzrdir.BzrDirMetaFormat1())
1266
1371
        co_branch.bind(repo_branch)
1267
1372
        # Do a light checkout of the heavy one
1268
1373
        transport.mkdir('tree/lightcheckout')
1269
 
        lco_dir = bzrlib.bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1270
 
        bzrlib.branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
 
1374
        lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
 
1375
        lco_dir.set_branch_reference(co_branch)
1271
1376
        lco_dir.create_workingtree()
1272
1377
        lco_tree = lco_dir.open_workingtree()
1273
1378
 
1361
1466
            self.knownFailure('Win32 cannot run "bzr info"'
1362
1467
                              ' when the tree is locked.')
1363
1468
 
1364
 
    def test_info_locking_oslocks(self):
1365
 
        if sys.platform == "win32":
1366
 
            raise TestSkipped("don't use oslocks on win32 in unix manner")
1367
 
 
1368
 
        tree = self.make_branch_and_tree('branch',
1369
 
                                         format=bzrlib.bzrdir.BzrDirFormat6())
1370
 
 
1371
 
        # Test all permutations of locking the working tree, branch and repository
1372
 
        # XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1373
 
        # implemented by raising NotImplementedError and get_physical_lock_status()
1374
 
        # always returns false. This makes bzr info hide the lock status.  (Olaf)
1375
 
        # W B R
1376
 
 
1377
 
        # U U U
1378
 
        out, err = self.run_bzr('info -v branch')
1379
 
        self.assertEqualDiff(
1380
 
"""Standalone tree (format: weave)
1381
 
Location:
1382
 
  branch root: %s
1383
 
 
1384
 
Format:
1385
 
       control: All-in-one format 6
1386
 
  working tree: Working tree format 2
1387
 
        branch: Branch format 4
1388
 
    repository: %s
1389
 
 
1390
 
In the working tree:
1391
 
         0 unchanged
1392
 
         0 modified
1393
 
         0 added
1394
 
         0 removed
1395
 
         0 renamed
1396
 
         0 unknown
1397
 
         0 ignored
1398
 
         0 versioned subdirectories
1399
 
 
1400
 
Branch history:
1401
 
         0 revisions
1402
 
         0 committers
1403
 
 
1404
 
Repository:
1405
 
         0 revisions
1406
 
         0 KiB
1407
 
""" % (tree.bzrdir.root_transport.base,
1408
 
       tree.branch.repository._format.get_format_description(),
1409
 
       ), out)
1410
 
        self.assertEqual('', err)
1411
 
        # L L L
1412
 
        tree.lock_write()
1413
 
        out, err = self.run_bzr('info -v branch')
1414
 
        self.assertEqualDiff(
1415
 
"""Standalone tree (format: weave)
1416
 
Location:
1417
 
  branch root: %s
1418
 
 
1419
 
Format:
1420
 
       control: All-in-one format 6
1421
 
  working tree: Working tree format 2
1422
 
        branch: Branch format 4
1423
 
    repository: %s
1424
 
 
1425
 
In the working tree:
1426
 
         0 unchanged
1427
 
         0 modified
1428
 
         0 added
1429
 
         0 removed
1430
 
         0 renamed
1431
 
         0 unknown
1432
 
         0 ignored
1433
 
         0 versioned subdirectories
1434
 
 
1435
 
Branch history:
1436
 
         0 revisions
1437
 
         0 committers
1438
 
 
1439
 
Repository:
1440
 
         0 revisions
1441
 
         0 KiB
1442
 
""" % (tree.bzrdir.root_transport.base,
1443
 
       tree.branch.repository._format.get_format_description(),
1444
 
       ), out)
1445
 
        self.assertEqual('', err)
1446
 
        tree.unlock()
 
1469
    def test_info_stacked(self):
 
1470
        # We have a mainline
 
1471
        trunk_tree = self.make_branch_and_tree('mainline',
 
1472
            format='1.6')
 
1473
        trunk_tree.commit('mainline')
 
1474
        # and a branch from it which is stacked
 
1475
        new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
 
1476
        out, err = self.run_bzr('info newbranch')
 
1477
        self.assertEqual(
 
1478
"""Standalone tree (format: 1.6)
 
1479
Location:
 
1480
  branch root: newbranch
 
1481
 
 
1482
Related branches:
 
1483
  parent branch: mainline
 
1484
     stacked on: mainline
 
1485
""", out)
 
1486
        self.assertEqual("", err)
 
1487
 
 
1488
    def test_info_revinfo_optional(self):
 
1489
        tree = self.make_branch_and_tree('.')
 
1490
        def last_revision_info(self):
 
1491
            raise errors.UnsupportedOperation(last_revision_info, self)
 
1492
        self.overrideAttr(
 
1493
            branch.Branch, "last_revision_info", last_revision_info)
 
1494
        out, err = self.run_bzr('info -v .')
 
1495
        self.assertEqual(
 
1496
"""Standalone tree (format: 2a)
 
1497
Location:
 
1498
  branch root: .
 
1499
 
 
1500
Format:
 
1501
       control: Meta directory format 1
 
1502
  working tree: Working tree format 6
 
1503
        branch: Branch format 7
 
1504
    repository: Repository format 2a - rich roots, group compression and chk inventories
 
1505
 
 
1506
Control directory:
 
1507
         1 branches
 
1508
 
 
1509
In the working tree:
 
1510
         0 unchanged
 
1511
         0 modified
 
1512
         0 added
 
1513
         0 removed
 
1514
         0 renamed
 
1515
         0 unknown
 
1516
         0 ignored
 
1517
         0 versioned subdirectories
 
1518
""", out)
 
1519
        self.assertEqual("", err)
 
1520
 
 
1521
    def test_info_shows_colocated_branches(self):
 
1522
        bzrdir = self.make_branch('.', format='development-colo').bzrdir
 
1523
        bzrdir.create_branch(name="colo1")
 
1524
        bzrdir.create_branch(name="colo2")
 
1525
        bzrdir.create_branch(name="colo3")
 
1526
        out, err = self.run_bzr('info -v .')
 
1527
        self.assertEqualDiff(
 
1528
"""Standalone branch (format: development-colo)
 
1529
Location:
 
1530
  branch root: .
 
1531
 
 
1532
Format:
 
1533
       control: Meta directory format 1 with support for colocated branches
 
1534
        branch: Branch format 7
 
1535
    repository: Repository format 2a - rich roots, group compression and chk inventories
 
1536
 
 
1537
Control directory:
 
1538
         4 branches
 
1539
 
 
1540
Branch history:
 
1541
         0 revisions
 
1542
 
 
1543
Repository:
 
1544
         0 revisions
 
1545
""", out)
 
1546
        self.assertEqual("", err)
 
1547
 
 
1548
 
 
1549
class TestSmartServerInfo(tests.TestCaseWithTransport):
 
1550
 
 
1551
    def test_simple_branch_info(self):
 
1552
        self.setup_smart_server_with_call_log()
 
1553
        t = self.make_branch_and_tree('branch')
 
1554
        self.build_tree_contents([('branch/foo', 'thecontents')])
 
1555
        t.add("foo")
 
1556
        t.commit("message")
 
1557
        self.reset_smart_call_log()
 
1558
        out, err = self.run_bzr(['info', self.get_url('branch')])
 
1559
        # This figure represent the amount of work to perform this use case. It
 
1560
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
1561
        # being too low. If rpc_count increases, more network roundtrips have
 
1562
        # become necessary for this use case. Please do not adjust this number
 
1563
        # upwards without agreement from bzr's network support maintainers.
 
1564
        self.assertLength(10, self.hpss_calls)
 
1565
        self.assertLength(1, self.hpss_connections)
 
1566
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
 
1567
 
 
1568
    def test_verbose_branch_info(self):
 
1569
        self.setup_smart_server_with_call_log()
 
1570
        t = self.make_branch_and_tree('branch')
 
1571
        self.build_tree_contents([('branch/foo', 'thecontents')])
 
1572
        t.add("foo")
 
1573
        t.commit("message")
 
1574
        self.reset_smart_call_log()
 
1575
        out, err = self.run_bzr(['info', '-v', self.get_url('branch')])
 
1576
        # This figure represent the amount of work to perform this use case. It
 
1577
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
1578
        # being too low. If rpc_count increases, more network roundtrips have
 
1579
        # become necessary for this use case. Please do not adjust this number
 
1580
        # upwards without agreement from bzr's network support maintainers.
 
1581
        self.assertLength(14, self.hpss_calls)
 
1582
        self.assertLength(1, self.hpss_connections)
 
1583
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)