~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2010-06-02 05:03:31 UTC
  • mto: This revision was merged to the branch mainline in revision 5279.
  • Revision ID: mbp@canonical.com-20100602050331-n2p1qt8hfsahspnv
Correct more sloppy use of the term 'Linux'

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""Tests for the info command of bzr."""
19
19
 
20
 
import shutil
21
20
import sys
22
21
 
23
22
from bzrlib import (
24
23
    branch,
25
24
    bzrdir,
26
 
    controldir,
27
25
    errors,
28
26
    info,
29
27
    osutils,
31
29
    upgrade,
32
30
    urlutils,
33
31
    )
34
 
from bzrlib.tests.matchers import ContainsNoVfsCalls
35
32
from bzrlib.transport import memory
36
33
 
37
34
 
48
45
        self.assertEqual(out, '')
49
46
        self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
50
47
 
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_dangling_branch_reference(self):
61
 
        br = self.make_branch('target')
62
 
        br.create_checkout('from', lightweight=True)
63
 
        shutil.rmtree('target')
64
 
        out, err = self.run_bzr('info from')
65
 
        self.assertEquals(out,
66
 
            'Dangling branch reference (format: 2a or pack-0.92)\n'
67
 
            'Location:\n'
68
 
            '   control directory: from\n'
69
 
            '  checkout of branch: target\n')
70
 
        self.assertEquals(err, '')
71
 
 
72
48
    def test_info_standalone(self):
73
49
        transport = self.get_transport()
74
50
 
75
51
        # Create initial standalone branch
76
 
        tree1 = self.make_branch_and_tree('standalone', 'knit')
 
52
        tree1 = self.make_branch_and_tree('standalone', 'weave')
77
53
        self.build_tree(['standalone/a'])
78
54
        tree1.add('a')
79
55
        branch1 = tree1.branch
80
56
 
81
57
        out, err = self.run_bzr('info standalone')
82
58
        self.assertEqualDiff(
83
 
"""Standalone tree (format: knit)
 
59
"""Standalone tree (format: weave)
84
60
Location:
85
61
  branch root: standalone
86
62
""", out)
89
65
        # Standalone branch - verbose mode
90
66
        out, err = self.run_bzr('info standalone -v')
91
67
        self.assertEqualDiff(
92
 
"""Standalone tree (format: knit)
 
68
"""Standalone tree (format: weave)
93
69
Location:
94
70
  branch root: standalone
95
71
 
96
72
Format:
97
 
       control: Meta directory format 1
98
 
  working tree: Working tree format 3
99
 
        branch: Branch format 5
100
 
    repository: Knit repository format 1
 
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
101
77
 
102
78
In the working tree:
103
79
         0 unchanged
120
96
        # Standalone branch - really verbose mode
121
97
        out, err = self.run_bzr('info standalone -vv')
122
98
        self.assertEqualDiff(
123
 
"""Standalone tree (format: knit)
 
99
"""Standalone tree (format: weave)
124
100
Location:
125
101
  branch root: standalone
126
102
 
127
103
Format:
128
 
       control: Meta directory format 1
129
 
  working tree: Working tree format 3
130
 
        branch: Branch format 5
131
 
    repository: Knit repository format 1
 
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
132
108
 
133
109
In the working tree:
134
110
         0 unchanged
149
125
""", out)
150
126
        self.assertEqual('', err)
151
127
        tree1.commit('commit one')
152
 
        rev = branch1.repository.get_revision(branch1.last_revision())
 
128
        rev = branch1.repository.get_revision(branch1.revision_history()[0])
153
129
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
154
130
 
155
131
        # Branch standalone with push location
158
134
 
159
135
        out, err = self.run_bzr('info branch')
160
136
        self.assertEqualDiff(
161
 
"""Standalone tree (format: knit)
 
137
"""Standalone tree (format: weave)
162
138
Location:
163
139
  branch root: branch
164
140
 
170
146
 
171
147
        out, err = self.run_bzr('info branch --verbose')
172
148
        self.assertEqualDiff(
173
 
"""Standalone tree (format: knit)
 
149
"""Standalone tree (format: weave)
174
150
Location:
175
151
  branch root: branch
176
152
 
179
155
  parent branch: standalone
180
156
 
181
157
Format:
182
 
       control: Meta directory format 1
183
 
  working tree: Working tree format 3
184
 
        branch: Branch format 5
185
 
    repository: Knit repository format 1
 
158
       control: All-in-one format 6
 
159
  working tree: Working tree format 2
 
160
        branch: Branch format 4
 
161
    repository: Weave repository format 6
186
162
 
187
163
In the working tree:
188
164
         1 unchanged
211
187
        branch1.bzrdir.sprout('bound')
212
188
        knit1_format = bzrdir.format_registry.make_bzrdir('knit')
213
189
        upgrade.upgrade('bound', knit1_format)
214
 
        branch3 = controldir.ControlDir.open('bound').open_branch()
 
190
        branch3 = bzrdir.BzrDir.open('bound').open_branch()
215
191
        branch3.bind(branch1)
216
192
        bound_tree = branch3.bzrdir.open_workingtree()
217
193
        out, err = self.run_bzr('info -v bound')
237
213
         0 removed
238
214
         0 renamed
239
215
         0 unknown
240
 
         0 ignored
 
216
         1 ignored
241
217
         0 versioned subdirectories
242
218
 
243
219
Branch history:
256
232
        self.assertEqual('', err)
257
233
 
258
234
        # Checkout standalone (same as above, but does not have parent set)
259
 
        branch4 = controldir.ControlDir.create_branch_convenience('checkout',
 
235
        branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
260
236
            format=knit1_format)
261
237
        branch4.bind(branch1)
262
238
        branch4.bzrdir.open_workingtree().update()
300
276
        tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
301
277
        branch5 = tree5.branch
302
278
        out, err = self.run_bzr('info -v lightcheckout')
303
 
        if "metaweave" in bzrdir.format_registry:
304
 
            format_description = "knit or metaweave"
305
 
        else:
306
 
            format_description = "knit"
307
279
        self.assertEqualDiff(
308
280
"""Lightweight checkout (format: %s)
309
281
Location:
312
284
 
313
285
Format:
314
286
       control: Meta directory format 1
315
 
  working tree: Working tree format 3
316
 
        branch: Branch format 5
317
 
    repository: Knit repository format 1
 
287
  working tree: Working tree format 6
 
288
        branch: Branch format 4
 
289
    repository: Weave repository format 6
318
290
 
319
291
In the working tree:
320
292
         1 unchanged
334
306
 
335
307
Repository:
336
308
         1 revision
337
 
""" % (format_description, datestring_first, datestring_first,), out)
 
309
""" % (self._repo_strings, datestring_first, datestring_first,), out)
338
310
        self.assertEqual('', err)
339
311
 
340
312
        # Update initial standalone branch
341
313
        self.build_tree(['standalone/b'])
342
314
        tree1.add('b')
343
315
        tree1.commit('commit two')
344
 
        rev = branch1.repository.get_revision(branch1.last_revision())
 
316
        rev = branch1.repository.get_revision(branch1.revision_history()[-1])
345
317
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
346
318
 
347
319
        # Out of date branched standalone branch will not be detected
348
320
        out, err = self.run_bzr('info -v branch')
349
321
        self.assertEqualDiff(
350
 
"""Standalone tree (format: knit)
 
322
"""Standalone tree (format: weave)
351
323
Location:
352
324
  branch root: branch
353
325
 
356
328
  parent branch: standalone
357
329
 
358
330
Format:
359
 
       control: Meta directory format 1
360
 
  working tree: Working tree format 3
361
 
        branch: Branch format 5
362
 
    repository: Knit repository format 1
 
331
       control: All-in-one format 6
 
332
  working tree: Working tree format 2
 
333
        branch: Branch format 4
 
334
    repository: Weave repository format 6
363
335
 
364
336
In the working tree:
365
337
         1 unchanged
409
381
         0 removed
410
382
         0 renamed
411
383
         0 unknown
412
 
         0 ignored
 
384
         1 ignored
413
385
         0 versioned subdirectories
414
386
 
415
387
Branch history:
474
446
 
475
447
Format:
476
448
       control: Meta directory format 1
477
 
  working tree: Working tree format 3
478
 
        branch: Branch format 5
479
 
    repository: Knit repository format 1
 
449
  working tree: Working tree format 6
 
450
        branch: Branch format 4
 
451
    repository: Weave repository format 6
480
452
 
481
453
Working tree is out of date: missing 1 revision.
482
454
 
498
470
 
499
471
Repository:
500
472
         2 revisions
501
 
""" % (format_description, datestring_first, datestring_last,), out)
 
473
""" % (self._repo_strings, datestring_first, datestring_last,), out)
502
474
        self.assertEqual('', err)
503
475
 
504
476
    def test_info_standalone_no_tree(self):
553
525
 
554
526
        # Create branch inside shared repository
555
527
        repo.bzrdir.root_transport.mkdir('branch')
556
 
        branch1 = controldir.ControlDir.create_branch_convenience(
557
 
            'repo/branch', format=format)
 
528
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
 
529
            format=format)
558
530
        out, err = self.run_bzr('info -v repo/branch')
559
531
        self.assertEqualDiff(
560
532
"""Repository branch (format: dirstate or knit)
595
567
        self.build_tree(['tree/lightcheckout/a'])
596
568
        tree2.add('a')
597
569
        tree2.commit('commit one')
598
 
        rev = repo.get_revision(branch2.last_revision())
 
570
        rev = repo.get_revision(branch2.revision_history()[0])
599
571
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
600
572
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
601
573
        self.assertEqualDiff(
714
686
        tree3.commit('commit two')
715
687
 
716
688
        # Out of date lightweight checkout
717
 
        rev = repo.get_revision(branch1.last_revision())
 
689
        rev = repo.get_revision(branch1.revision_history()[-1])
718
690
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
719
691
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
720
692
        self.assertEqualDiff(
827
799
 
828
800
        # Create two branches
829
801
        repo.bzrdir.root_transport.mkdir('branch1')
830
 
        branch1 = controldir.ControlDir.create_branch_convenience('repo/branch1',
 
802
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
831
803
            format=format)
832
804
        branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
833
805
 
870
842
        tree1 = branch1.bzrdir.open_workingtree()
871
843
        tree1.add('a')
872
844
        tree1.commit('commit one')
873
 
        rev = repo.get_revision(branch1.last_revision())
 
845
        rev = repo.get_revision(branch1.revision_history()[0])
874
846
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
875
847
        out, err = self.run_bzr('info -v repo/branch1')
876
848
        self.assertEqualDiff(
1245
1217
                                    format=bzrdir.BzrDirMetaFormat1())
1246
1218
        repo.set_make_working_trees(False)
1247
1219
        repo.bzrdir.root_transport.mkdir('branch')
1248
 
        repo_branch = controldir.ControlDir.create_branch_convenience(
1249
 
            'repo/branch', format=bzrdir.BzrDirMetaFormat1())
 
1220
        repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
 
1221
                                    format=bzrdir.BzrDirMetaFormat1())
1250
1222
        # Do a heavy checkout
1251
1223
        transport.mkdir('tree')
1252
1224
        transport.mkdir('tree/checkout')
1253
 
        co_branch = controldir.ControlDir.create_branch_convenience(
1254
 
            'tree/checkout', format=bzrdir.BzrDirMetaFormat1())
 
1225
        co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
 
1226
            format=bzrdir.BzrDirMetaFormat1())
1255
1227
        co_branch.bind(repo_branch)
1256
1228
        # Do a light checkout of the heavy one
1257
1229
        transport.mkdir('tree/lightcheckout')
1351
1323
            self.knownFailure('Win32 cannot run "bzr info"'
1352
1324
                              ' when the tree is locked.')
1353
1325
 
 
1326
    def test_info_locking_oslocks(self):
 
1327
        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()
 
1334
 
 
1335
        tree = self.make_branch_and_tree('branch',
 
1336
                                         format=bzrdir.BzrDirFormat6())
 
1337
 
 
1338
        # Test all permutations of locking the working tree, branch and repository
 
1339
        # XXX: Well not yet, as we can't query oslocks yet. Currently, it's
 
1340
        # implemented by raising NotImplementedError and get_physical_lock_status()
 
1341
        # always returns false. This makes bzr info hide the lock status.  (Olaf)
 
1342
        # W B R
 
1343
 
 
1344
        # U U U
 
1345
        out, err = self.run_bzr('info -v branch')
 
1346
        self.assertEqualDiff(
 
1347
"""Standalone tree (format: weave)
 
1348
Location:
 
1349
  branch root: %s
 
1350
 
 
1351
Format:
 
1352
       control: All-in-one format 6
 
1353
  working tree: Working tree format 2
 
1354
        branch: Branch format 4
 
1355
    repository: %s
 
1356
 
 
1357
In the working tree:
 
1358
         0 unchanged
 
1359
         0 modified
 
1360
         0 added
 
1361
         0 removed
 
1362
         0 renamed
 
1363
         0 unknown
 
1364
         0 ignored
 
1365
         0 versioned subdirectories
 
1366
 
 
1367
Branch history:
 
1368
         0 revisions
 
1369
 
 
1370
Repository:
 
1371
         0 revisions
 
1372
""" % ('branch', tree.branch.repository._format.get_format_description(),
 
1373
       ), out)
 
1374
        self.assertEqual('', err)
 
1375
        # L L L
 
1376
        tree.lock_write()
 
1377
        out, err = self.run_bzr('info -v branch')
 
1378
        self.assertEqualDiff(
 
1379
"""Standalone tree (format: weave)
 
1380
Location:
 
1381
  branch root: %s
 
1382
 
 
1383
Format:
 
1384
       control: All-in-one format 6
 
1385
  working tree: Working tree format 2
 
1386
        branch: Branch format 4
 
1387
    repository: %s
 
1388
 
 
1389
In the working tree:
 
1390
         0 unchanged
 
1391
         0 modified
 
1392
         0 added
 
1393
         0 removed
 
1394
         0 renamed
 
1395
         0 unknown
 
1396
         0 ignored
 
1397
         0 versioned subdirectories
 
1398
 
 
1399
Branch history:
 
1400
         0 revisions
 
1401
 
 
1402
Repository:
 
1403
         0 revisions
 
1404
""" % ('branch', tree.branch.repository._format.get_format_description(),
 
1405
       ), out)
 
1406
        self.assertEqual('', err)
 
1407
        tree.unlock()
 
1408
 
1354
1409
    def test_info_stacked(self):
1355
1410
        # We have a mainline
1356
1411
        trunk_tree = self.make_branch_and_tree('mainline',
1369
1424
     stacked on: mainline
1370
1425
""", out)
1371
1426
        self.assertEqual("", err)
1372
 
 
1373
 
    def test_info_revinfo_optional(self):
1374
 
        tree = self.make_branch_and_tree('.')
1375
 
        def last_revision_info(self):
1376
 
            raise errors.UnsupportedOperation(last_revision_info, self)
1377
 
        self.overrideAttr(
1378
 
            branch.Branch, "last_revision_info", last_revision_info)
1379
 
        out, err = self.run_bzr('info -v .')
1380
 
        self.assertEqual(
1381
 
"""Standalone tree (format: 2a)
1382
 
Location:
1383
 
  branch root: .
1384
 
 
1385
 
Format:
1386
 
       control: Meta directory format 1
1387
 
  working tree: Working tree format 6
1388
 
        branch: Branch format 7
1389
 
    repository: Repository format 2a - rich roots, group compression and chk inventories
1390
 
 
1391
 
In the working tree:
1392
 
         0 unchanged
1393
 
         0 modified
1394
 
         0 added
1395
 
         0 removed
1396
 
         0 renamed
1397
 
         0 unknown
1398
 
         0 ignored
1399
 
         0 versioned subdirectories
1400
 
""", out)
1401
 
        self.assertEqual("", err)
1402
 
 
1403
 
    def test_info_shows_colocated_branches(self):
1404
 
        bzrdir = self.make_branch('.', format='development-colo').bzrdir
1405
 
        bzrdir.create_branch(name="colo1")
1406
 
        bzrdir.create_branch(name="colo2")
1407
 
        bzrdir.create_branch(name="colo3")
1408
 
        out, err = self.run_bzr('info -v .')
1409
 
        self.assertEqualDiff(
1410
 
"""Standalone branch (format: development-colo)
1411
 
Location:
1412
 
  branch root: .
1413
 
 
1414
 
Format:
1415
 
       control: Meta directory format 1 with support for colocated branches
1416
 
        branch: Branch format 7
1417
 
    repository: Repository format 2a - rich roots, group compression and chk inventories
1418
 
 
1419
 
Control directory:
1420
 
         4 branches
1421
 
 
1422
 
Branch history:
1423
 
         0 revisions
1424
 
 
1425
 
Repository:
1426
 
         0 revisions
1427
 
""", out)
1428
 
        self.assertEqual("", err)
1429
 
 
1430
 
 
1431
 
class TestSmartServerInfo(tests.TestCaseWithTransport):
1432
 
 
1433
 
    def test_simple_branch_info(self):
1434
 
        self.setup_smart_server_with_call_log()
1435
 
        t = self.make_branch_and_tree('branch')
1436
 
        self.build_tree_contents([('branch/foo', 'thecontents')])
1437
 
        t.add("foo")
1438
 
        t.commit("message")
1439
 
        self.reset_smart_call_log()
1440
 
        out, err = self.run_bzr(['info', self.get_url('branch')])
1441
 
        # This figure represent the amount of work to perform this use case. It
1442
 
        # is entirely ok to reduce this number if a test fails due to rpc_count
1443
 
        # being too low. If rpc_count increases, more network roundtrips have
1444
 
        # become necessary for this use case. Please do not adjust this number
1445
 
        # upwards without agreement from bzr's network support maintainers.
1446
 
        self.assertLength(12, self.hpss_calls)
1447
 
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
1448
 
 
1449
 
    def test_verbose_branch_info(self):
1450
 
        self.setup_smart_server_with_call_log()
1451
 
        t = self.make_branch_and_tree('branch')
1452
 
        self.build_tree_contents([('branch/foo', 'thecontents')])
1453
 
        t.add("foo")
1454
 
        t.commit("message")
1455
 
        self.reset_smart_call_log()
1456
 
        out, err = self.run_bzr(['info', '-v', self.get_url('branch')])
1457
 
        # This figure represent the amount of work to perform this use case. It
1458
 
        # is entirely ok to reduce this number if a test fails due to rpc_count
1459
 
        # being too low. If rpc_count increases, more network roundtrips have
1460
 
        # become necessary for this use case. Please do not adjust this number
1461
 
        # upwards without agreement from bzr's network support maintainers.
1462
 
        self.assertLength(16, self.hpss_calls)
1463
 
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)