~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Patch Queue Manager
  • Date: 2011-10-14 16:54:26 UTC
  • mfrom: (6216.1.1 remove-this-file)
  • Revision ID: pqm@pqm.ubuntu.com-20111014165426-tjix4e6idryf1r2z
(jelmer) Remove an accidentally committed .THIS file. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2008 Canonical Ltd
 
1
# Copyright (C) 2006-2010 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
22
22
from bzrlib import (
23
23
    branch,
24
24
    bzrdir,
 
25
    controldir,
25
26
    errors,
26
27
    info,
27
28
    osutils,
 
29
    tests,
28
30
    upgrade,
29
31
    urlutils,
30
32
    )
31
 
from bzrlib.osutils import format_date
32
 
from bzrlib.tests import TestSkipped
33
 
from bzrlib.tests.blackbox import ExternalBase
34
 
 
35
 
 
36
 
class TestInfo(ExternalBase):
 
33
from bzrlib.transport import memory
 
34
 
 
35
 
 
36
class TestInfo(tests.TestCaseWithTransport):
 
37
 
 
38
    def setUp(self):
 
39
        super(TestInfo, self).setUp()
 
40
        self._repo_strings = "2a"
37
41
 
38
42
    def test_info_non_existing(self):
39
 
        if sys.platform == "win32":
40
 
            location = "C:/i/do/not/exist/"
41
 
        else:
42
 
            location = "/i/do/not/exist/"
 
43
        self.vfs_transport_factory = memory.MemoryServer
 
44
        location = self.get_url()
43
45
        out, err = self.run_bzr('info '+location, retcode=3)
44
46
        self.assertEqual(out, '')
45
47
        self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
48
50
        transport = self.get_transport()
49
51
 
50
52
        # Create initial standalone branch
51
 
        tree1 = self.make_branch_and_tree('standalone', 'weave')
 
53
        tree1 = self.make_branch_and_tree('standalone', 'knit')
52
54
        self.build_tree(['standalone/a'])
53
55
        tree1.add('a')
54
56
        branch1 = tree1.branch
55
57
 
56
58
        out, err = self.run_bzr('info standalone')
57
59
        self.assertEqualDiff(
58
 
"""Standalone tree (format: weave)
 
60
"""Standalone tree (format: knit)
59
61
Location:
60
62
  branch root: standalone
61
63
""", out)
64
66
        # Standalone branch - verbose mode
65
67
        out, err = self.run_bzr('info standalone -v')
66
68
        self.assertEqualDiff(
67
 
"""Standalone tree (format: weave)
 
69
"""Standalone tree (format: knit)
68
70
Location:
69
71
  branch root: standalone
70
72
 
71
73
Format:
72
 
       control: All-in-one format 6
73
 
  working tree: Working tree format 2
74
 
        branch: Branch format 4
75
 
    repository: Weave repository format 6
 
74
       control: Meta directory format 1
 
75
  working tree: Working tree format 3
 
76
        branch: Branch format 5
 
77
    repository: Knit repository format 1
76
78
 
77
79
In the working tree:
78
80
         0 unchanged
95
97
        # Standalone branch - really verbose mode
96
98
        out, err = self.run_bzr('info standalone -vv')
97
99
        self.assertEqualDiff(
98
 
"""Standalone tree (format: weave)
 
100
"""Standalone tree (format: knit)
99
101
Location:
100
102
  branch root: standalone
101
103
 
102
104
Format:
103
 
       control: All-in-one format 6
104
 
  working tree: Working tree format 2
105
 
        branch: Branch format 4
106
 
    repository: Weave repository format 6
 
105
       control: Meta directory format 1
 
106
  working tree: Working tree format 3
 
107
        branch: Branch format 5
 
108
    repository: Knit repository format 1
107
109
 
108
110
In the working tree:
109
111
         0 unchanged
124
126
""", out)
125
127
        self.assertEqual('', err)
126
128
        tree1.commit('commit one')
127
 
        rev = branch1.repository.get_revision(branch1.revision_history()[0])
128
 
        datestring_first = format_date(rev.timestamp, rev.timezone)
 
129
        rev = branch1.repository.get_revision(branch1.last_revision())
 
130
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
129
131
 
130
132
        # Branch standalone with push location
131
133
        branch2 = branch1.bzrdir.sprout('branch').open_branch()
133
135
 
134
136
        out, err = self.run_bzr('info branch')
135
137
        self.assertEqualDiff(
136
 
"""Standalone tree (format: weave)
 
138
"""Standalone tree (format: knit)
137
139
Location:
138
140
  branch root: branch
139
141
 
145
147
 
146
148
        out, err = self.run_bzr('info branch --verbose')
147
149
        self.assertEqualDiff(
148
 
"""Standalone tree (format: weave)
 
150
"""Standalone tree (format: knit)
149
151
Location:
150
152
  branch root: branch
151
153
 
154
156
  parent branch: standalone
155
157
 
156
158
Format:
157
 
       control: All-in-one format 6
158
 
  working tree: Working tree format 2
159
 
        branch: Branch format 4
160
 
    repository: Weave repository format 6
 
159
       control: Meta directory format 1
 
160
  working tree: Working tree format 3
 
161
        branch: Branch format 5
 
162
    repository: Knit repository format 1
161
163
 
162
164
In the working tree:
163
165
         1 unchanged
186
188
        branch1.bzrdir.sprout('bound')
187
189
        knit1_format = bzrdir.format_registry.make_bzrdir('knit')
188
190
        upgrade.upgrade('bound', knit1_format)
189
 
        branch3 = bzrdir.BzrDir.open('bound').open_branch()
 
191
        branch3 = controldir.ControlDir.open('bound').open_branch()
190
192
        branch3.bind(branch1)
191
193
        bound_tree = branch3.bzrdir.open_workingtree()
192
194
        out, err = self.run_bzr('info -v bound')
211
213
         0 added
212
214
         0 removed
213
215
         0 renamed
214
 
         1 unknown
 
216
         0 unknown
215
217
         0 ignored
216
218
         0 versioned subdirectories
217
219
 
231
233
        self.assertEqual('', err)
232
234
 
233
235
        # Checkout standalone (same as above, but does not have parent set)
234
 
        branch4 = bzrdir.BzrDir.create_branch_convenience('checkout',
 
236
        branch4 = controldir.ControlDir.create_branch_convenience('checkout',
235
237
            format=knit1_format)
236
238
        branch4.bind(branch1)
237
239
        branch4.bzrdir.open_workingtree().update()
275
277
        tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
276
278
        branch5 = tree5.branch
277
279
        out, err = self.run_bzr('info -v lightcheckout')
 
280
        if "metaweave" in bzrdir.format_registry:
 
281
            format_description = "knit or metaweave"
 
282
        else:
 
283
            format_description = "knit"
278
284
        self.assertEqualDiff(
279
 
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root \
280
 
or 1.9 or 1.9-rich-root \
281
 
or dirstate or dirstate-tags or \
282
 
pack-0.92 or rich-root or rich-root-pack)
 
285
"""Lightweight checkout (format: %s)
283
286
Location:
284
287
  light checkout root: lightcheckout
285
288
   checkout of branch: standalone
286
289
 
287
290
Format:
288
291
       control: Meta directory format 1
289
 
  working tree: Working tree format 4
290
 
        branch: Branch format 4
291
 
    repository: Weave repository format 6
 
292
  working tree: Working tree format 3
 
293
        branch: Branch format 5
 
294
    repository: Knit repository format 1
292
295
 
293
296
In the working tree:
294
297
         1 unchanged
308
311
 
309
312
Repository:
310
313
         1 revision
311
 
""" % (datestring_first, datestring_first,), out)
 
314
""" % (format_description, datestring_first, datestring_first,), out)
312
315
        self.assertEqual('', err)
313
316
 
314
317
        # Update initial standalone branch
315
318
        self.build_tree(['standalone/b'])
316
319
        tree1.add('b')
317
320
        tree1.commit('commit two')
318
 
        rev = branch1.repository.get_revision(branch1.revision_history()[-1])
319
 
        datestring_last = format_date(rev.timestamp, rev.timezone)
 
321
        rev = branch1.repository.get_revision(branch1.last_revision())
 
322
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
320
323
 
321
324
        # Out of date branched standalone branch will not be detected
322
325
        out, err = self.run_bzr('info -v branch')
323
326
        self.assertEqualDiff(
324
 
"""Standalone tree (format: weave)
 
327
"""Standalone tree (format: knit)
325
328
Location:
326
329
  branch root: branch
327
330
 
330
333
  parent branch: standalone
331
334
 
332
335
Format:
333
 
       control: All-in-one format 6
334
 
  working tree: Working tree format 2
335
 
        branch: Branch format 4
336
 
    repository: Weave repository format 6
 
336
       control: Meta directory format 1
 
337
  working tree: Working tree format 3
 
338
        branch: Branch format 5
 
339
    repository: Knit repository format 1
337
340
 
338
341
In the working tree:
339
342
         1 unchanged
382
385
         0 added
383
386
         0 removed
384
387
         0 renamed
385
 
         1 unknown
 
388
         0 unknown
386
389
         0 ignored
387
390
         0 versioned subdirectories
388
391
 
441
444
        # Out of date lightweight checkout
442
445
        out, err = self.run_bzr('info lightcheckout --verbose')
443
446
        self.assertEqualDiff(
444
 
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
445
 
1.9 or 1.9-rich-root or \
446
 
dirstate or dirstate-tags or \
447
 
pack-0.92 or rich-root or rich-root-pack)
 
447
"""Lightweight checkout (format: %s)
448
448
Location:
449
449
  light checkout root: lightcheckout
450
450
   checkout of branch: standalone
451
451
 
452
452
Format:
453
453
       control: Meta directory format 1
454
 
  working tree: Working tree format 4
455
 
        branch: Branch format 4
456
 
    repository: Weave repository format 6
 
454
  working tree: Working tree format 3
 
455
        branch: Branch format 5
 
456
    repository: Knit repository format 1
457
457
 
458
458
Working tree is out of date: missing 1 revision.
459
459
 
475
475
 
476
476
Repository:
477
477
         2 revisions
478
 
""" % (datestring_first, datestring_last,), out)
 
478
""" % (format_description, datestring_first, datestring_last,), out)
479
479
        self.assertEqual('', err)
480
480
 
481
481
    def test_info_standalone_no_tree(self):
530
530
 
531
531
        # Create branch inside shared repository
532
532
        repo.bzrdir.root_transport.mkdir('branch')
533
 
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch',
534
 
            format=format)
 
533
        branch1 = controldir.ControlDir.create_branch_convenience(
 
534
            'repo/branch', format=format)
535
535
        out, err = self.run_bzr('info -v repo/branch')
536
536
        self.assertEqualDiff(
537
537
"""Repository branch (format: dirstate or knit)
572
572
        self.build_tree(['tree/lightcheckout/a'])
573
573
        tree2.add('a')
574
574
        tree2.commit('commit one')
575
 
        rev = repo.get_revision(branch2.revision_history()[0])
576
 
        datestring_first = format_date(rev.timestamp, rev.timezone)
 
575
        rev = repo.get_revision(branch2.last_revision())
 
576
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
577
577
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
578
578
        self.assertEqualDiff(
579
 
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
580
 
1.9 or 1.9-rich-root or \
581
 
dirstate or dirstate-tags or \
582
 
pack-0.92 or rich-root or rich-root-pack)
 
579
"""Lightweight checkout (format: %s)
583
580
Location:
584
581
  light checkout root: tree/lightcheckout
585
582
   checkout of branch: repo/branch
587
584
 
588
585
Format:
589
586
       control: Meta directory format 1
590
 
  working tree: Working tree format 4
 
587
  working tree: Working tree format 6
591
588
        branch: %s
592
589
    repository: %s
593
590
 
609
606
 
610
607
Repository:
611
608
         1 revision
612
 
""" % (format.get_branch_format().get_format_description(),
 
609
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
613
610
       format.repository_format.get_format_description(),
614
611
       datestring_first, datestring_first,
615
612
       ), out)
618
615
        # Out of date checkout
619
616
        out, err = self.run_bzr('info -v tree/checkout')
620
617
        self.assertEqualDiff(
621
 
"""Checkout (format: dirstate)
 
618
"""Checkout (format: unnamed)
622
619
Location:
623
620
       checkout root: tree/checkout
624
621
  checkout of branch: repo/branch
625
622
 
626
623
Format:
627
624
       control: Meta directory format 1
628
 
  working tree: Working tree format 4
 
625
  working tree: Working tree format 6
629
626
        branch: %s
630
627
    repository: %s
631
628
 
657
654
        tree3.add('b')
658
655
        out, err = self.run_bzr('info tree/checkout --verbose')
659
656
        self.assertEqualDiff(
660
 
"""Checkout (format: dirstate)
 
657
"""Checkout (format: unnamed)
661
658
Location:
662
659
       checkout root: tree/checkout
663
660
  checkout of branch: repo/branch
664
661
 
665
662
Format:
666
663
       control: Meta directory format 1
667
 
  working tree: Working tree format 4
 
664
  working tree: Working tree format 6
668
665
        branch: %s
669
666
    repository: %s
670
667
 
694
691
        tree3.commit('commit two')
695
692
 
696
693
        # Out of date lightweight checkout
697
 
        rev = repo.get_revision(branch1.revision_history()[-1])
698
 
        datestring_last = format_date(rev.timestamp, rev.timezone)
 
694
        rev = repo.get_revision(branch1.last_revision())
 
695
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
699
696
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
700
697
        self.assertEqualDiff(
701
 
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
702
 
1.9 or 1.9-rich-root or \
703
 
dirstate or dirstate-tags or \
704
 
pack-0.92 or rich-root or rich-root-pack)
 
698
"""Lightweight checkout (format: %s)
705
699
Location:
706
700
  light checkout root: tree/lightcheckout
707
701
   checkout of branch: repo/branch
709
703
 
710
704
Format:
711
705
       control: Meta directory format 1
712
 
  working tree: Working tree format 4
 
706
  working tree: Working tree format 6
713
707
        branch: %s
714
708
    repository: %s
715
709
 
733
727
 
734
728
Repository:
735
729
         2 revisions
736
 
""" % (format.get_branch_format().get_format_description(),
 
730
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
737
731
       format.repository_format.get_format_description(),
738
732
       datestring_first, datestring_last,
739
733
       ), out)
810
804
 
811
805
        # Create two branches
812
806
        repo.bzrdir.root_transport.mkdir('branch1')
813
 
        branch1 = repo.bzrdir.create_branch_convenience('repo/branch1',
 
807
        branch1 = controldir.ControlDir.create_branch_convenience('repo/branch1',
814
808
            format=format)
815
809
        branch2 = branch1.bzrdir.sprout('repo/branch2').open_branch()
816
810
 
853
847
        tree1 = branch1.bzrdir.open_workingtree()
854
848
        tree1.add('a')
855
849
        tree1.commit('commit one')
856
 
        rev = repo.get_revision(branch1.revision_history()[0])
857
 
        datestring_first = format_date(rev.timestamp, rev.timezone)
 
850
        rev = repo.get_revision(branch1.last_revision())
 
851
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
858
852
        out, err = self.run_bzr('info -v repo/branch1')
859
853
        self.assertEqualDiff(
860
854
"""Repository tree (format: knit)
1134
1128
            (False, True): 'Lightweight checkout',
1135
1129
            (False, False): 'Checkout',
1136
1130
            }[(shared_repo is not None, light_checkout)]
1137
 
        format = {True: '1.6 or 1.6.1-rich-root'
1138
 
                        ' or 1.9 or 1.9-rich-root'
1139
 
                        ' or dirstate or dirstate-tags or pack-0.92'
1140
 
                        ' or rich-root or rich-root-pack',
1141
 
                  False: 'dirstate'}[light_checkout]
 
1131
        format = {True: self._repo_strings,
 
1132
                  False: 'unnamed'}[light_checkout]
1142
1133
        if repo_locked:
1143
1134
            repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1144
1135
        if repo_locked or branch_locked or tree_locked:
1231
1222
                                    format=bzrdir.BzrDirMetaFormat1())
1232
1223
        repo.set_make_working_trees(False)
1233
1224
        repo.bzrdir.root_transport.mkdir('branch')
1234
 
        repo_branch = repo.bzrdir.create_branch_convenience('repo/branch',
1235
 
                                    format=bzrdir.BzrDirMetaFormat1())
 
1225
        repo_branch = controldir.ControlDir.create_branch_convenience(
 
1226
            'repo/branch', format=bzrdir.BzrDirMetaFormat1())
1236
1227
        # Do a heavy checkout
1237
1228
        transport.mkdir('tree')
1238
1229
        transport.mkdir('tree/checkout')
1239
 
        co_branch = bzrdir.BzrDir.create_branch_convenience('tree/checkout',
1240
 
            format=bzrdir.BzrDirMetaFormat1())
 
1230
        co_branch = controldir.ControlDir.create_branch_convenience(
 
1231
            'tree/checkout', format=bzrdir.BzrDirMetaFormat1())
1241
1232
        co_branch.bind(repo_branch)
1242
1233
        # Do a light checkout of the heavy one
1243
1234
        transport.mkdir('tree/lightcheckout')
1244
1235
        lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1245
 
        branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
 
1236
        branch.BranchReferenceFormat().initialize(lco_dir,
 
1237
            target_branch=co_branch)
1246
1238
        lco_dir.create_workingtree()
1247
1239
        lco_tree = lco_dir.open_workingtree()
1248
1240
 
1336
1328
            self.knownFailure('Win32 cannot run "bzr info"'
1337
1329
                              ' when the tree is locked.')
1338
1330
 
1339
 
    def test_info_locking_oslocks(self):
1340
 
        if sys.platform == "win32":
1341
 
            raise TestSkipped("don't use oslocks on win32 in unix manner")
1342
 
 
1343
 
        tree = self.make_branch_and_tree('branch',
1344
 
                                         format=bzrdir.BzrDirFormat6())
1345
 
 
1346
 
        # Test all permutations of locking the working tree, branch and repository
1347
 
        # XXX: Well not yet, as we can't query oslocks yet. Currently, it's
1348
 
        # implemented by raising NotImplementedError and get_physical_lock_status()
1349
 
        # always returns false. This makes bzr info hide the lock status.  (Olaf)
1350
 
        # W B R
1351
 
 
1352
 
        # U U U
1353
 
        out, err = self.run_bzr('info -v branch')
1354
 
        self.assertEqualDiff(
1355
 
"""Standalone tree (format: weave)
1356
 
Location:
1357
 
  branch root: %s
1358
 
 
1359
 
Format:
1360
 
       control: All-in-one format 6
1361
 
  working tree: Working tree format 2
1362
 
        branch: Branch format 4
1363
 
    repository: %s
1364
 
 
1365
 
In the working tree:
1366
 
         0 unchanged
1367
 
         0 modified
1368
 
         0 added
1369
 
         0 removed
1370
 
         0 renamed
1371
 
         0 unknown
1372
 
         0 ignored
1373
 
         0 versioned subdirectories
1374
 
 
1375
 
Branch history:
1376
 
         0 revisions
1377
 
 
1378
 
Repository:
1379
 
         0 revisions
1380
 
""" % ('branch', tree.branch.repository._format.get_format_description(),
1381
 
       ), out)
1382
 
        self.assertEqual('', err)
1383
 
        # L L L
1384
 
        tree.lock_write()
1385
 
        out, err = self.run_bzr('info -v branch')
1386
 
        self.assertEqualDiff(
1387
 
"""Standalone tree (format: weave)
1388
 
Location:
1389
 
  branch root: %s
1390
 
 
1391
 
Format:
1392
 
       control: All-in-one format 6
1393
 
  working tree: Working tree format 2
1394
 
        branch: Branch format 4
1395
 
    repository: %s
1396
 
 
1397
 
In the working tree:
1398
 
         0 unchanged
1399
 
         0 modified
1400
 
         0 added
1401
 
         0 removed
1402
 
         0 renamed
1403
 
         0 unknown
1404
 
         0 ignored
1405
 
         0 versioned subdirectories
1406
 
 
1407
 
Branch history:
1408
 
         0 revisions
1409
 
 
1410
 
Repository:
1411
 
         0 revisions
1412
 
""" % ('branch', tree.branch.repository._format.get_format_description(),
1413
 
       ), out)
1414
 
        self.assertEqual('', err)
1415
 
        tree.unlock()
1416
 
 
1417
1331
    def test_info_stacked(self):
1418
1332
        # We have a mainline
1419
1333
        trunk_tree = self.make_branch_and_tree('mainline',
1432
1346
     stacked on: mainline
1433
1347
""", out)
1434
1348
        self.assertEqual("", err)
 
1349
 
 
1350
    def test_info_revinfo_optional(self):
 
1351
        tree = self.make_branch_and_tree('.')
 
1352
        def last_revision_info(self):
 
1353
            raise errors.UnsupportedOperation(last_revision_info, self)
 
1354
        self.overrideAttr(
 
1355
            branch.Branch, "last_revision_info", last_revision_info)
 
1356
        out, err = self.run_bzr('info -v .')
 
1357
        self.assertEqual(
 
1358
"""Standalone tree (format: 2a)
 
1359
Location:
 
1360
  branch root: .
 
1361
 
 
1362
Format:
 
1363
       control: Meta directory format 1
 
1364
  working tree: Working tree format 6
 
1365
        branch: Branch format 7
 
1366
    repository: Repository format 2a - rich roots, group compression and chk inventories
 
1367
 
 
1368
In the working tree:
 
1369
         0 unchanged
 
1370
         0 modified
 
1371
         0 added
 
1372
         0 removed
 
1373
         0 renamed
 
1374
         0 unknown
 
1375
         0 ignored
 
1376
         0 versioned subdirectories
 
1377
""", out)
 
1378
        self.assertEqual("", err)