~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: 2009-01-13 03:11:04 UTC
  • mto: This revision was merged to the branch mainline in revision 3937.
  • Revision ID: mbp@sourcefrog.net-20090113031104-03my054s02i9l2pe
Bump version to 1.12 and add news template

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
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
 
18
18
"""Tests for the info command of bzr."""
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)
62
61
""", out)
63
62
        self.assertEqual('', err)
64
63
 
65
 
        # Standalone branch - verbose mode
66
64
        out, err = self.run_bzr('info standalone -v')
67
65
        self.assertEqualDiff(
68
66
"""Standalone tree (format: weave)
87
85
 
88
86
Branch history:
89
87
         0 revisions
90
 
 
91
 
Repository:
92
 
         0 revisions
93
 
""", out)
94
 
        self.assertEqual('', err)
95
 
 
96
 
        # Standalone branch - really verbose mode
97
 
        out, err = self.run_bzr('info standalone -vv')
98
 
        self.assertEqualDiff(
99
 
"""Standalone tree (format: weave)
100
 
Location:
101
 
  branch root: standalone
102
 
 
103
 
Format:
104
 
       control: All-in-one format 6
105
 
  working tree: Working tree format 2
106
 
        branch: Branch format 4
107
 
    repository: Weave repository format 6
108
 
 
109
 
In the working tree:
110
 
         0 unchanged
111
 
         0 modified
112
 
         1 added
113
 
         0 removed
114
 
         0 renamed
115
 
         0 unknown
116
 
         0 ignored
117
 
         0 versioned subdirectories
118
 
 
119
 
Branch history:
120
 
         0 revisions
121
88
         0 committers
122
89
 
123
90
Repository:
126
93
        self.assertEqual('', err)
127
94
        tree1.commit('commit one')
128
95
        rev = branch1.repository.get_revision(branch1.revision_history()[0])
129
 
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
 
96
        datestring_first = format_date(rev.timestamp, rev.timezone)
130
97
 
131
98
        # Branch standalone with push location
132
99
        branch2 = branch1.bzrdir.sprout('branch').open_branch()
172
139
 
173
140
Branch history:
174
141
         1 revision
 
142
         1 committer
175
143
         0 days old
176
144
   first revision: %s
177
145
  latest revision: %s
212
180
         0 added
213
181
         0 removed
214
182
         0 renamed
215
 
         0 unknown
216
 
         1 ignored
 
183
         1 unknown
 
184
         0 ignored
217
185
         0 versioned subdirectories
218
186
 
219
187
Branch history:
220
188
         1 revision
 
189
         1 committer
221
190
         0 days old
222
191
   first revision: %s
223
192
  latest revision: %s
261
230
 
262
231
Branch history:
263
232
         1 revision
 
233
         1 committer
264
234
         0 days old
265
235
   first revision: %s
266
236
  latest revision: %s
277
247
        branch5 = tree5.branch
278
248
        out, err = self.run_bzr('info -v lightcheckout')
279
249
        self.assertEqualDiff(
280
 
"""Lightweight checkout (format: %s)
 
250
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root \
 
251
or 1.9 or 1.9-rich-root \
 
252
or dirstate or dirstate-tags or \
 
253
pack-0.92 or rich-root or rich-root-pack)
281
254
Location:
282
255
  light checkout root: lightcheckout
283
256
   checkout of branch: standalone
284
257
 
285
258
Format:
286
259
       control: Meta directory format 1
287
 
  working tree: Working tree format 6
 
260
  working tree: Working tree format 4
288
261
        branch: Branch format 4
289
262
    repository: Weave repository format 6
290
263
 
300
273
 
301
274
Branch history:
302
275
         1 revision
 
276
         1 committer
303
277
         0 days old
304
278
   first revision: %s
305
279
  latest revision: %s
306
280
 
307
281
Repository:
308
282
         1 revision
309
 
""" % (self._repo_strings, datestring_first, datestring_first,), out)
 
283
""" % (datestring_first, datestring_first,), out)
310
284
        self.assertEqual('', err)
311
285
 
312
286
        # Update initial standalone branch
314
288
        tree1.add('b')
315
289
        tree1.commit('commit two')
316
290
        rev = branch1.repository.get_revision(branch1.revision_history()[-1])
317
 
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
 
291
        datestring_last = format_date(rev.timestamp, rev.timezone)
318
292
 
319
293
        # Out of date branched standalone branch will not be detected
320
294
        out, err = self.run_bzr('info -v branch')
345
319
 
346
320
Branch history:
347
321
         1 revision
 
322
         1 committer
348
323
         0 days old
349
324
   first revision: %s
350
325
  latest revision: %s
380
355
         0 added
381
356
         0 removed
382
357
         0 renamed
383
 
         0 unknown
384
 
         1 ignored
 
358
         1 unknown
 
359
         0 ignored
385
360
         0 versioned subdirectories
386
361
 
387
362
Branch history:
388
363
         1 revision
 
364
         1 committer
389
365
         0 days old
390
366
   first revision: %s
391
367
  latest revision: %s
425
401
 
426
402
Branch history:
427
403
         1 revision
 
404
         1 committer
428
405
         0 days old
429
406
   first revision: %s
430
407
  latest revision: %s
439
416
        # Out of date lightweight checkout
440
417
        out, err = self.run_bzr('info lightcheckout --verbose')
441
418
        self.assertEqualDiff(
442
 
"""Lightweight checkout (format: %s)
 
419
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
 
420
1.9 or 1.9-rich-root or \
 
421
dirstate or dirstate-tags or \
 
422
pack-0.92 or rich-root or rich-root-pack)
443
423
Location:
444
424
  light checkout root: lightcheckout
445
425
   checkout of branch: standalone
446
426
 
447
427
Format:
448
428
       control: Meta directory format 1
449
 
  working tree: Working tree format 6
 
429
  working tree: Working tree format 4
450
430
        branch: Branch format 4
451
431
    repository: Weave repository format 6
452
432
 
464
444
 
465
445
Branch history:
466
446
         2 revisions
 
447
         1 committer
467
448
         0 days old
468
449
   first revision: %s
469
450
  latest revision: %s
470
451
 
471
452
Repository:
472
453
         2 revisions
473
 
""" % (self._repo_strings, datestring_first, datestring_last,), out)
 
454
""" % (datestring_first, datestring_last,), out)
474
455
        self.assertEqual('', err)
475
456
 
476
457
    def test_info_standalone_no_tree(self):
491
472
 
492
473
Branch history:
493
474
         0 revisions
 
475
         0 committers
494
476
 
495
477
Repository:
496
478
         0 revisions
541
523
 
542
524
Branch history:
543
525
         0 revisions
 
526
         0 committers
544
527
 
545
528
Repository:
546
529
         0 revisions
552
535
        # Create lightweight checkout
553
536
        transport.mkdir('tree')
554
537
        transport.mkdir('tree/lightcheckout')
555
 
        tree2 = branch1.create_checkout('tree/lightcheckout',
 
538
        tree2 = branch1.create_checkout('tree/lightcheckout', 
556
539
            lightweight=True)
557
540
        branch2 = tree2.branch
558
541
        self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
568
551
        tree2.add('a')
569
552
        tree2.commit('commit one')
570
553
        rev = repo.get_revision(branch2.revision_history()[0])
571
 
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
 
554
        datestring_first = format_date(rev.timestamp, rev.timezone)
572
555
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
573
556
        self.assertEqualDiff(
574
 
"""Lightweight checkout (format: %s)
 
557
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
 
558
1.9 or 1.9-rich-root or \
 
559
dirstate or dirstate-tags or \
 
560
pack-0.92 or rich-root or rich-root-pack)
575
561
Location:
576
562
  light checkout root: tree/lightcheckout
577
563
   checkout of branch: repo/branch
579
565
 
580
566
Format:
581
567
       control: Meta directory format 1
582
 
  working tree: Working tree format 6
 
568
  working tree: Working tree format 4
583
569
        branch: %s
584
570
    repository: %s
585
571
 
595
581
 
596
582
Branch history:
597
583
         1 revision
 
584
         1 committer
598
585
         0 days old
599
586
   first revision: %s
600
587
  latest revision: %s
601
588
 
602
589
Repository:
603
590
         1 revision
604
 
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
 
591
""" % (format.get_branch_format().get_format_description(),
605
592
       format.repository_format.get_format_description(),
606
593
       datestring_first, datestring_first,
607
594
       ), out)
610
597
        # Out of date checkout
611
598
        out, err = self.run_bzr('info -v tree/checkout')
612
599
        self.assertEqualDiff(
613
 
"""Checkout (format: unnamed)
 
600
"""Checkout (format: dirstate)
614
601
Location:
615
602
       checkout root: tree/checkout
616
603
  checkout of branch: repo/branch
617
604
 
618
605
Format:
619
606
       control: Meta directory format 1
620
 
  working tree: Working tree format 6
 
607
  working tree: Working tree format 4
621
608
        branch: %s
622
609
    repository: %s
623
610
 
635
622
 
636
623
Branch history:
637
624
         0 revisions
 
625
         0 committers
638
626
 
639
627
Repository:
640
628
         0 revisions
649
637
        tree3.add('b')
650
638
        out, err = self.run_bzr('info tree/checkout --verbose')
651
639
        self.assertEqualDiff(
652
 
"""Checkout (format: unnamed)
 
640
"""Checkout (format: dirstate)
653
641
Location:
654
642
       checkout root: tree/checkout
655
643
  checkout of branch: repo/branch
656
644
 
657
645
Format:
658
646
       control: Meta directory format 1
659
 
  working tree: Working tree format 6
 
647
  working tree: Working tree format 4
660
648
        branch: %s
661
649
    repository: %s
662
650
 
672
660
 
673
661
Branch history:
674
662
         1 revision
 
663
         1 committer
675
664
         0 days old
676
665
   first revision: %s
677
666
  latest revision: %s
687
676
 
688
677
        # Out of date lightweight checkout
689
678
        rev = repo.get_revision(branch1.revision_history()[-1])
690
 
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
 
679
        datestring_last = format_date(rev.timestamp, rev.timezone)
691
680
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
692
681
        self.assertEqualDiff(
693
 
"""Lightweight checkout (format: %s)
 
682
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
 
683
1.9 or 1.9-rich-root or \
 
684
dirstate or dirstate-tags or \
 
685
pack-0.92 or rich-root or rich-root-pack)
694
686
Location:
695
687
  light checkout root: tree/lightcheckout
696
688
   checkout of branch: repo/branch
698
690
 
699
691
Format:
700
692
       control: Meta directory format 1
701
 
  working tree: Working tree format 6
 
693
  working tree: Working tree format 4
702
694
        branch: %s
703
695
    repository: %s
704
696
 
716
708
 
717
709
Branch history:
718
710
         2 revisions
 
711
         1 committer
719
712
         0 days old
720
713
   first revision: %s
721
714
  latest revision: %s
722
715
 
723
716
Repository:
724
717
         2 revisions
725
 
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
 
718
""" % (format.get_branch_format().get_format_description(),
726
719
       format.repository_format.get_format_description(),
727
720
       datestring_first, datestring_last,
728
721
       ), out)
743
736
 
744
737
Branch history:
745
738
         2 revisions
 
739
         1 committer
746
740
         0 days old
747
741
   first revision: %s
748
742
  latest revision: %s
829
823
 
830
824
Branch history:
831
825
         0 revisions
 
826
         0 committers
832
827
 
833
828
Repository:
834
829
         0 revisions
843
838
        tree1.add('a')
844
839
        tree1.commit('commit one')
845
840
        rev = repo.get_revision(branch1.revision_history()[0])
846
 
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
 
841
        datestring_first = format_date(rev.timestamp, rev.timezone)
847
842
        out, err = self.run_bzr('info -v repo/branch1')
848
843
        self.assertEqualDiff(
849
844
"""Repository tree (format: knit)
869
864
 
870
865
Branch history:
871
866
         1 revision
 
867
         1 committer
872
868
         0 days old
873
869
   first revision: %s
874
870
  latest revision: %s
910
906
 
911
907
Branch history:
912
908
         0 revisions
 
909
         0 committers
913
910
 
914
911
Repository:
915
912
         1 revision
949
946
 
950
947
Branch history:
951
948
         1 revision
 
949
         1 committer
952
950
         0 days old
953
951
   first revision: %s
954
952
  latest revision: %s
980
978
       ),
981
979
       out)
982
980
        self.assertEqual('', err)
983
 
 
 
981
    
984
982
    def test_info_shared_repository_with_tree_in_root(self):
985
983
        format = bzrdir.format_registry.make_bzrdir('knit')
986
984
        transport = self.get_transport()
1035
1033
 
1036
1034
Branch history:
1037
1035
         0 revisions
 
1036
         0 committers
1038
1037
 
1039
1038
Repository:
1040
1039
         0 revisions
1043
1042
       ), out)
1044
1043
        self.assertEqual('', err)
1045
1044
 
1046
 
    def test_info_repository_hook(self):
1047
 
        format = bzrdir.format_registry.make_bzrdir('knit')
1048
 
        def repo_info(repo, stats, outf):
1049
 
            outf.write("more info\n")
1050
 
        info.hooks.install_named_hook('repository', repo_info, None)
1051
 
        # Create shared repository with working trees
1052
 
        repo = self.make_repository('repo', shared=True, format=format)
1053
 
        out, err = self.run_bzr('info -v repo')
1054
 
        self.assertEqualDiff(
1055
 
"""Shared repository with trees (format: dirstate or dirstate-tags or knit)
1056
 
Location:
1057
 
  shared repository: repo
1058
 
 
1059
 
Format:
1060
 
       control: Meta directory format 1
1061
 
    repository: %s
1062
 
 
1063
 
Create working tree for new branches inside the repository.
1064
 
 
1065
 
Repository:
1066
 
         0 revisions
1067
 
more info
1068
 
""" % (format.repository_format.get_format_description(),
1069
 
       ), out)
1070
 
        self.assertEqual('', err)
1071
 
 
1072
1045
    def assertCheckoutStatusOutput(self,
1073
1046
        command_string, lco_tree, shared_repo=None,
1074
1047
        repo_branch=None,
1084
1057
        allow us, the test writers, to document what *should* be present in
1085
1058
        the output. Removing this separation would remove the value of the
1086
1059
        tests.
1087
 
 
 
1060
        
1088
1061
        :param path: the path to the light checkout.
1089
1062
        :param lco_tree: the tree object for the light checkout.
1090
1063
        :param shared_repo: A shared repository is in use, expect that in
1098
1071
            actually locked then this parameter is overridden. This is because
1099
1072
            pack repositories do not have any public API for obtaining an
1100
1073
            exclusive repository wide lock.
1101
 
        :param verbose: verbosity level: 2 or higher to show committers
 
1074
        :param verbose: If true, expect verbose output
1102
1075
        """
1103
1076
        def friendly_location(url):
1104
1077
            path = urlutils.unescape_for_display(url, 'ascii')
1123
1096
            (False, True): 'Lightweight checkout',
1124
1097
            (False, False): 'Checkout',
1125
1098
            }[(shared_repo is not None, light_checkout)]
1126
 
        format = {True: self._repo_strings,
1127
 
                  False: 'unnamed'}[light_checkout]
 
1099
        format = {True: '1.6 or 1.6.1-rich-root'
 
1100
                        ' or 1.9 or 1.9-rich-root'
 
1101
                        ' or dirstate or dirstate-tags or pack-0.92'
 
1102
                        ' or rich-root or rich-root-pack',
 
1103
                  False: 'dirstate'}[light_checkout]
1128
1104
        if repo_locked:
1129
1105
            repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1130
1106
        if repo_locked or branch_locked or tree_locked:
1167
1143
        else:
1168
1144
            branch_data = ("   checkout of branch: %s\n" %
1169
1145
                lco_tree.branch.bzrdir.root_transport.base)
1170
 
 
1171
 
        if verbose >= 2:
 
1146
        
 
1147
        if verbose:
1172
1148
            verbose_info = '         0 committers\n'
1173
1149
        else:
1174
1150
            verbose_info = ''
1175
 
 
 
1151
            
1176
1152
        self.assertEqualDiff(
1177
1153
"""%s (format: %s)
1178
1154
Location:
1228
1204
        # Do a light checkout of the heavy one
1229
1205
        transport.mkdir('tree/lightcheckout')
1230
1206
        lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1231
 
        branch.BranchReferenceFormat().initialize(lco_dir,
1232
 
            target_branch=co_branch)
 
1207
        branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
1233
1208
        lco_dir.create_workingtree()
1234
1209
        lco_tree = lco_dir.open_workingtree()
1235
1210
 
1325
1300
 
1326
1301
    def test_info_locking_oslocks(self):
1327
1302
        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()
 
1303
            raise TestSkipped("don't use oslocks on win32 in unix manner")
1334
1304
 
1335
1305
        tree = self.make_branch_and_tree('branch',
1336
1306
                                         format=bzrdir.BzrDirFormat6())
1366
1336
 
1367
1337
Branch history:
1368
1338
         0 revisions
 
1339
         0 committers
1369
1340
 
1370
1341
Repository:
1371
1342
         0 revisions
1398
1369
 
1399
1370
Branch history:
1400
1371
         0 revisions
 
1372
         0 committers
1401
1373
 
1402
1374
Repository:
1403
1375
         0 revisions