~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Andrew Bennetts
  • Date: 2009-04-02 05:53:12 UTC
  • mto: This revision was merged to the branch mainline in revision 4242.
  • Revision ID: andrew.bennetts@canonical.com-20090402055312-h7mvgumvm7e620mj
Fix nits in spelling and naming.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2008 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
25
25
    errors,
26
26
    info,
27
27
    osutils,
28
 
    tests,
29
28
    upgrade,
30
29
    urlutils,
31
30
    )
32
 
from bzrlib.transport import memory
33
 
 
34
 
 
35
 
class TestInfo(tests.TestCaseWithTransport):
36
 
 
37
 
    def setUp(self):
38
 
        super(TestInfo, self).setUp()
39
 
        self._repo_strings = "2a"
 
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):
40
37
 
41
38
    def test_info_non_existing(self):
42
 
        self.vfs_transport_factory = memory.MemoryServer
43
 
        location = self.get_url()
 
39
        if sys.platform == "win32":
 
40
            location = "C:/i/do/not/exist/"
 
41
        else:
 
42
            location = "/i/do/not/exist/"
44
43
        out, err = self.run_bzr('info '+location, retcode=3)
45
44
        self.assertEqual(out, '')
46
45
        self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
49
48
        transport = self.get_transport()
50
49
 
51
50
        # Create initial standalone branch
52
 
        tree1 = self.make_branch_and_tree('standalone', 'knit')
 
51
        tree1 = self.make_branch_and_tree('standalone', 'weave')
53
52
        self.build_tree(['standalone/a'])
54
53
        tree1.add('a')
55
54
        branch1 = tree1.branch
56
55
 
57
56
        out, err = self.run_bzr('info standalone')
58
57
        self.assertEqualDiff(
59
 
"""Standalone tree (format: knit)
 
58
"""Standalone tree (format: weave)
60
59
Location:
61
60
  branch root: standalone
62
61
""", out)
65
64
        # Standalone branch - verbose mode
66
65
        out, err = self.run_bzr('info standalone -v')
67
66
        self.assertEqualDiff(
68
 
"""Standalone tree (format: knit)
 
67
"""Standalone tree (format: weave)
69
68
Location:
70
69
  branch root: standalone
71
70
 
72
71
Format:
73
 
       control: Meta directory format 1
74
 
  working tree: Working tree format 3
75
 
        branch: Branch format 5
76
 
    repository: Knit repository format 1
 
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
77
76
 
78
77
In the working tree:
79
78
         0 unchanged
96
95
        # Standalone branch - really verbose mode
97
96
        out, err = self.run_bzr('info standalone -vv')
98
97
        self.assertEqualDiff(
99
 
"""Standalone tree (format: knit)
 
98
"""Standalone tree (format: weave)
100
99
Location:
101
100
  branch root: standalone
102
101
 
103
102
Format:
104
 
       control: Meta directory format 1
105
 
  working tree: Working tree format 3
106
 
        branch: Branch format 5
107
 
    repository: Knit repository format 1
 
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
108
107
 
109
108
In the working tree:
110
109
         0 unchanged
126
125
        self.assertEqual('', err)
127
126
        tree1.commit('commit one')
128
127
        rev = branch1.repository.get_revision(branch1.revision_history()[0])
129
 
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
 
128
        datestring_first = format_date(rev.timestamp, rev.timezone)
130
129
 
131
130
        # Branch standalone with push location
132
131
        branch2 = branch1.bzrdir.sprout('branch').open_branch()
134
133
 
135
134
        out, err = self.run_bzr('info branch')
136
135
        self.assertEqualDiff(
137
 
"""Standalone tree (format: knit)
 
136
"""Standalone tree (format: weave)
138
137
Location:
139
138
  branch root: branch
140
139
 
146
145
 
147
146
        out, err = self.run_bzr('info branch --verbose')
148
147
        self.assertEqualDiff(
149
 
"""Standalone tree (format: knit)
 
148
"""Standalone tree (format: weave)
150
149
Location:
151
150
  branch root: branch
152
151
 
155
154
  parent branch: standalone
156
155
 
157
156
Format:
158
 
       control: Meta directory format 1
159
 
  working tree: Working tree format 3
160
 
        branch: Branch format 5
161
 
    repository: Knit repository format 1
 
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
162
161
 
163
162
In the working tree:
164
163
         1 unchanged
212
211
         0 added
213
212
         0 removed
214
213
         0 renamed
215
 
         0 unknown
 
214
         1 unknown
216
215
         0 ignored
217
216
         0 versioned subdirectories
218
217
 
276
275
        tree5 = branch1.create_checkout('lightcheckout', lightweight=True)
277
276
        branch5 = tree5.branch
278
277
        out, err = self.run_bzr('info -v lightcheckout')
279
 
        if "metaweave" in bzrdir.format_registry:
280
 
            format_description = "knit or metaweave"
281
 
        else:
282
 
            format_description = "knit"
283
278
        self.assertEqualDiff(
284
 
"""Lightweight checkout (format: %s)
 
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
283
Location:
286
284
  light checkout root: lightcheckout
287
285
   checkout of branch: standalone
288
286
 
289
287
Format:
290
288
       control: Meta directory format 1
291
 
  working tree: Working tree format 3
292
 
        branch: Branch format 5
293
 
    repository: Knit repository format 1
 
289
  working tree: Working tree format 4
 
290
        branch: Branch format 4
 
291
    repository: Weave repository format 6
294
292
 
295
293
In the working tree:
296
294
         1 unchanged
310
308
 
311
309
Repository:
312
310
         1 revision
313
 
""" % (format_description, datestring_first, datestring_first,), out)
 
311
""" % (datestring_first, datestring_first,), out)
314
312
        self.assertEqual('', err)
315
313
 
316
314
        # Update initial standalone branch
318
316
        tree1.add('b')
319
317
        tree1.commit('commit two')
320
318
        rev = branch1.repository.get_revision(branch1.revision_history()[-1])
321
 
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
 
319
        datestring_last = format_date(rev.timestamp, rev.timezone)
322
320
 
323
321
        # Out of date branched standalone branch will not be detected
324
322
        out, err = self.run_bzr('info -v branch')
325
323
        self.assertEqualDiff(
326
 
"""Standalone tree (format: knit)
 
324
"""Standalone tree (format: weave)
327
325
Location:
328
326
  branch root: branch
329
327
 
332
330
  parent branch: standalone
333
331
 
334
332
Format:
335
 
       control: Meta directory format 1
336
 
  working tree: Working tree format 3
337
 
        branch: Branch format 5
338
 
    repository: Knit repository format 1
 
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
339
337
 
340
338
In the working tree:
341
339
         1 unchanged
384
382
         0 added
385
383
         0 removed
386
384
         0 renamed
387
 
         0 unknown
 
385
         1 unknown
388
386
         0 ignored
389
387
         0 versioned subdirectories
390
388
 
443
441
        # Out of date lightweight checkout
444
442
        out, err = self.run_bzr('info lightcheckout --verbose')
445
443
        self.assertEqualDiff(
446
 
"""Lightweight checkout (format: %s)
 
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
448
Location:
448
449
  light checkout root: lightcheckout
449
450
   checkout of branch: standalone
450
451
 
451
452
Format:
452
453
       control: Meta directory format 1
453
 
  working tree: Working tree format 3
454
 
        branch: Branch format 5
455
 
    repository: Knit repository format 1
 
454
  working tree: Working tree format 4
 
455
        branch: Branch format 4
 
456
    repository: Weave repository format 6
456
457
 
457
458
Working tree is out of date: missing 1 revision.
458
459
 
474
475
 
475
476
Repository:
476
477
         2 revisions
477
 
""" % (format_description, datestring_first, datestring_last,), out)
 
478
""" % (datestring_first, datestring_last,), out)
478
479
        self.assertEqual('', err)
479
480
 
480
481
    def test_info_standalone_no_tree(self):
572
573
        tree2.add('a')
573
574
        tree2.commit('commit one')
574
575
        rev = repo.get_revision(branch2.revision_history()[0])
575
 
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
 
576
        datestring_first = format_date(rev.timestamp, rev.timezone)
576
577
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
577
578
        self.assertEqualDiff(
578
 
"""Lightweight checkout (format: %s)
 
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
583
Location:
580
584
  light checkout root: tree/lightcheckout
581
585
   checkout of branch: repo/branch
583
587
 
584
588
Format:
585
589
       control: Meta directory format 1
586
 
  working tree: Working tree format 6
 
590
  working tree: Working tree format 4
587
591
        branch: %s
588
592
    repository: %s
589
593
 
605
609
 
606
610
Repository:
607
611
         1 revision
608
 
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
 
612
""" % (format.get_branch_format().get_format_description(),
609
613
       format.repository_format.get_format_description(),
610
614
       datestring_first, datestring_first,
611
615
       ), out)
614
618
        # Out of date checkout
615
619
        out, err = self.run_bzr('info -v tree/checkout')
616
620
        self.assertEqualDiff(
617
 
"""Checkout (format: unnamed)
 
621
"""Checkout (format: dirstate)
618
622
Location:
619
623
       checkout root: tree/checkout
620
624
  checkout of branch: repo/branch
621
625
 
622
626
Format:
623
627
       control: Meta directory format 1
624
 
  working tree: Working tree format 6
 
628
  working tree: Working tree format 4
625
629
        branch: %s
626
630
    repository: %s
627
631
 
653
657
        tree3.add('b')
654
658
        out, err = self.run_bzr('info tree/checkout --verbose')
655
659
        self.assertEqualDiff(
656
 
"""Checkout (format: unnamed)
 
660
"""Checkout (format: dirstate)
657
661
Location:
658
662
       checkout root: tree/checkout
659
663
  checkout of branch: repo/branch
660
664
 
661
665
Format:
662
666
       control: Meta directory format 1
663
 
  working tree: Working tree format 6
 
667
  working tree: Working tree format 4
664
668
        branch: %s
665
669
    repository: %s
666
670
 
691
695
 
692
696
        # Out of date lightweight checkout
693
697
        rev = repo.get_revision(branch1.revision_history()[-1])
694
 
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
 
698
        datestring_last = format_date(rev.timestamp, rev.timezone)
695
699
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
696
700
        self.assertEqualDiff(
697
 
"""Lightweight checkout (format: %s)
 
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
705
Location:
699
706
  light checkout root: tree/lightcheckout
700
707
   checkout of branch: repo/branch
702
709
 
703
710
Format:
704
711
       control: Meta directory format 1
705
 
  working tree: Working tree format 6
 
712
  working tree: Working tree format 4
706
713
        branch: %s
707
714
    repository: %s
708
715
 
726
733
 
727
734
Repository:
728
735
         2 revisions
729
 
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
 
736
""" % (format.get_branch_format().get_format_description(),
730
737
       format.repository_format.get_format_description(),
731
738
       datestring_first, datestring_last,
732
739
       ), out)
847
854
        tree1.add('a')
848
855
        tree1.commit('commit one')
849
856
        rev = repo.get_revision(branch1.revision_history()[0])
850
 
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
 
857
        datestring_first = format_date(rev.timestamp, rev.timezone)
851
858
        out, err = self.run_bzr('info -v repo/branch1')
852
859
        self.assertEqualDiff(
853
860
"""Repository tree (format: knit)
1047
1054
       ), out)
1048
1055
        self.assertEqual('', err)
1049
1056
 
1050
 
    def test_info_repository_hook(self):
1051
 
        format = bzrdir.format_registry.make_bzrdir('knit')
1052
 
        def repo_info(repo, stats, outf):
1053
 
            outf.write("more info\n")
1054
 
        info.hooks.install_named_hook('repository', repo_info, None)
1055
 
        # Create shared repository with working trees
1056
 
        repo = self.make_repository('repo', shared=True, format=format)
1057
 
        out, err = self.run_bzr('info -v repo')
1058
 
        self.assertEqualDiff(
1059
 
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1060
 
Location:
1061
 
  shared repository: repo
1062
 
 
1063
 
Format:
1064
 
       control: Meta directory format 1
1065
 
    repository: %s
1066
 
 
1067
 
Create working tree for new branches inside the repository.
1068
 
 
1069
 
Repository:
1070
 
         0 revisions
1071
 
more info
1072
 
""" % (format.repository_format.get_format_description(),
1073
 
       ), out)
1074
 
        self.assertEqual('', err)
1075
 
 
1076
1057
    def assertCheckoutStatusOutput(self,
1077
1058
        command_string, lco_tree, shared_repo=None,
1078
1059
        repo_branch=None,
1127
1108
            (False, True): 'Lightweight checkout',
1128
1109
            (False, False): 'Checkout',
1129
1110
            }[(shared_repo is not None, light_checkout)]
1130
 
        format = {True: self._repo_strings,
1131
 
                  False: 'unnamed'}[light_checkout]
 
1111
        format = {True: '1.6 or 1.6.1-rich-root'
 
1112
                        ' or 1.9 or 1.9-rich-root'
 
1113
                        ' or dirstate or dirstate-tags or pack-0.92'
 
1114
                        ' or rich-root or rich-root-pack',
 
1115
                  False: 'dirstate'}[light_checkout]
1132
1116
        if repo_locked:
1133
1117
            repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1134
1118
        if repo_locked or branch_locked or tree_locked:
1232
1216
        # Do a light checkout of the heavy one
1233
1217
        transport.mkdir('tree/lightcheckout')
1234
1218
        lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1235
 
        branch.BranchReferenceFormat().initialize(lco_dir,
1236
 
            target_branch=co_branch)
 
1219
        branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1237
1220
        lco_dir.create_workingtree()
1238
1221
        lco_tree = lco_dir.open_workingtree()
1239
1222
 
1327
1310
            self.knownFailure('Win32 cannot run "bzr info"'
1328
1311
                              ' when the tree is locked.')
1329
1312
 
 
1313
    def test_info_locking_oslocks(self):
 
1314
        if sys.platform == "win32":
 
1315
            raise TestSkipped("don't use oslocks on win32 in unix manner")
 
1316
 
 
1317
        tree = self.make_branch_and_tree('branch',
 
1318
                                         format=bzrdir.BzrDirFormat6())
 
1319
 
 
1320
        # Test all permutations of locking the working tree, branch and repository
 
1321
        # XXX: Well not yet, as we can't query oslocks yet. Currently, it's
 
1322
        # implemented by raising NotImplementedError and get_physical_lock_status()
 
1323
        # always returns false. This makes bzr info hide the lock status.  (Olaf)
 
1324
        # W B R
 
1325
 
 
1326
        # U U U
 
1327
        out, err = self.run_bzr('info -v branch')
 
1328
        self.assertEqualDiff(
 
1329
"""Standalone tree (format: weave)
 
1330
Location:
 
1331
  branch root: %s
 
1332
 
 
1333
Format:
 
1334
       control: All-in-one format 6
 
1335
  working tree: Working tree format 2
 
1336
        branch: Branch format 4
 
1337
    repository: %s
 
1338
 
 
1339
In the working tree:
 
1340
         0 unchanged
 
1341
         0 modified
 
1342
         0 added
 
1343
         0 removed
 
1344
         0 renamed
 
1345
         0 unknown
 
1346
         0 ignored
 
1347
         0 versioned subdirectories
 
1348
 
 
1349
Branch history:
 
1350
         0 revisions
 
1351
 
 
1352
Repository:
 
1353
         0 revisions
 
1354
""" % ('branch', tree.branch.repository._format.get_format_description(),
 
1355
       ), out)
 
1356
        self.assertEqual('', err)
 
1357
        # L L L
 
1358
        tree.lock_write()
 
1359
        out, err = self.run_bzr('info -v branch')
 
1360
        self.assertEqualDiff(
 
1361
"""Standalone tree (format: weave)
 
1362
Location:
 
1363
  branch root: %s
 
1364
 
 
1365
Format:
 
1366
       control: All-in-one format 6
 
1367
  working tree: Working tree format 2
 
1368
        branch: Branch format 4
 
1369
    repository: %s
 
1370
 
 
1371
In the working tree:
 
1372
         0 unchanged
 
1373
         0 modified
 
1374
         0 added
 
1375
         0 removed
 
1376
         0 renamed
 
1377
         0 unknown
 
1378
         0 ignored
 
1379
         0 versioned subdirectories
 
1380
 
 
1381
Branch history:
 
1382
         0 revisions
 
1383
 
 
1384
Repository:
 
1385
         0 revisions
 
1386
""" % ('branch', tree.branch.repository._format.get_format_description(),
 
1387
       ), out)
 
1388
        self.assertEqual('', err)
 
1389
        tree.unlock()
 
1390
 
1330
1391
    def test_info_stacked(self):
1331
1392
        # We have a mainline
1332
1393
        trunk_tree = self.make_branch_and_tree('mainline',