~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-04-08 06:17:41 UTC
  • mfrom: (4797.33.16 apport)
  • Revision ID: pqm@pqm.ubuntu.com-20100408061741-m7vl6z97vu33riv7
(robertc) Make sure ExecutablePath and InterpreterPath are set in
        Apport. (Martin Pool, James Westby, lp:528114)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007 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
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."""
25
25
    errors,
26
26
    info,
27
27
    osutils,
 
28
    tests,
28
29
    upgrade,
29
30
    urlutils,
30
31
    )
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):
 
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"
37
40
 
38
41
    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/"
 
42
        self.vfs_transport_factory = memory.MemoryServer
 
43
        location = self.get_url()
43
44
        out, err = self.run_bzr('info '+location, retcode=3)
44
45
        self.assertEqual(out, '')
45
46
        self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
61
62
""", out)
62
63
        self.assertEqual('', err)
63
64
 
 
65
        # Standalone branch - verbose mode
64
66
        out, err = self.run_bzr('info standalone -v')
65
67
        self.assertEqualDiff(
66
68
"""Standalone tree (format: weave)
85
87
 
86
88
Branch history:
87
89
         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
88
121
         0 committers
89
122
 
90
123
Repository:
93
126
        self.assertEqual('', err)
94
127
        tree1.commit('commit one')
95
128
        rev = branch1.repository.get_revision(branch1.revision_history()[0])
96
 
        datestring_first = format_date(rev.timestamp, rev.timezone)
 
129
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
97
130
 
98
131
        # Branch standalone with push location
99
132
        branch2 = branch1.bzrdir.sprout('branch').open_branch()
139
172
 
140
173
Branch history:
141
174
         1 revision
142
 
         1 committer
143
175
         0 days old
144
176
   first revision: %s
145
177
  latest revision: %s
180
212
         0 added
181
213
         0 removed
182
214
         0 renamed
183
 
         1 unknown
184
 
         0 ignored
 
215
         0 unknown
 
216
         1 ignored
185
217
         0 versioned subdirectories
186
218
 
187
219
Branch history:
188
220
         1 revision
189
 
         1 committer
190
221
         0 days old
191
222
   first revision: %s
192
223
  latest revision: %s
230
261
 
231
262
Branch history:
232
263
         1 revision
233
 
         1 committer
234
264
         0 days old
235
265
   first revision: %s
236
266
  latest revision: %s
247
277
        branch5 = tree5.branch
248
278
        out, err = self.run_bzr('info -v lightcheckout')
249
279
        self.assertEqualDiff(
250
 
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root \
251
 
or dirstate or dirstate-tags or \
252
 
pack-0.92 or rich-root or rich-root-pack)
 
280
"""Lightweight checkout (format: %s)
253
281
Location:
254
282
  light checkout root: lightcheckout
255
283
   checkout of branch: standalone
256
284
 
257
285
Format:
258
286
       control: Meta directory format 1
259
 
  working tree: Working tree format 4
 
287
  working tree: Working tree format 6
260
288
        branch: Branch format 4
261
289
    repository: Weave repository format 6
262
290
 
272
300
 
273
301
Branch history:
274
302
         1 revision
275
 
         1 committer
276
303
         0 days old
277
304
   first revision: %s
278
305
  latest revision: %s
279
306
 
280
307
Repository:
281
308
         1 revision
282
 
""" % (datestring_first, datestring_first,), out)
 
309
""" % (self._repo_strings, datestring_first, datestring_first,), out)
283
310
        self.assertEqual('', err)
284
311
 
285
312
        # Update initial standalone branch
287
314
        tree1.add('b')
288
315
        tree1.commit('commit two')
289
316
        rev = branch1.repository.get_revision(branch1.revision_history()[-1])
290
 
        datestring_last = format_date(rev.timestamp, rev.timezone)
 
317
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
291
318
 
292
319
        # Out of date branched standalone branch will not be detected
293
320
        out, err = self.run_bzr('info -v branch')
318
345
 
319
346
Branch history:
320
347
         1 revision
321
 
         1 committer
322
348
         0 days old
323
349
   first revision: %s
324
350
  latest revision: %s
354
380
         0 added
355
381
         0 removed
356
382
         0 renamed
357
 
         1 unknown
358
 
         0 ignored
 
383
         0 unknown
 
384
         1 ignored
359
385
         0 versioned subdirectories
360
386
 
361
387
Branch history:
362
388
         1 revision
363
 
         1 committer
364
389
         0 days old
365
390
   first revision: %s
366
391
  latest revision: %s
400
425
 
401
426
Branch history:
402
427
         1 revision
403
 
         1 committer
404
428
         0 days old
405
429
   first revision: %s
406
430
  latest revision: %s
415
439
        # Out of date lightweight checkout
416
440
        out, err = self.run_bzr('info lightcheckout --verbose')
417
441
        self.assertEqualDiff(
418
 
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
419
 
dirstate or dirstate-tags or \
420
 
pack-0.92 or rich-root or rich-root-pack)
 
442
"""Lightweight checkout (format: %s)
421
443
Location:
422
444
  light checkout root: lightcheckout
423
445
   checkout of branch: standalone
424
446
 
425
447
Format:
426
448
       control: Meta directory format 1
427
 
  working tree: Working tree format 4
 
449
  working tree: Working tree format 6
428
450
        branch: Branch format 4
429
451
    repository: Weave repository format 6
430
452
 
442
464
 
443
465
Branch history:
444
466
         2 revisions
445
 
         1 committer
446
467
         0 days old
447
468
   first revision: %s
448
469
  latest revision: %s
449
470
 
450
471
Repository:
451
472
         2 revisions
452
 
""" % (datestring_first, datestring_last,), out)
 
473
""" % (self._repo_strings, datestring_first, datestring_last,), out)
453
474
        self.assertEqual('', err)
454
475
 
455
476
    def test_info_standalone_no_tree(self):
470
491
 
471
492
Branch history:
472
493
         0 revisions
473
 
         0 committers
474
494
 
475
495
Repository:
476
496
         0 revisions
521
541
 
522
542
Branch history:
523
543
         0 revisions
524
 
         0 committers
525
544
 
526
545
Repository:
527
546
         0 revisions
533
552
        # Create lightweight checkout
534
553
        transport.mkdir('tree')
535
554
        transport.mkdir('tree/lightcheckout')
536
 
        tree2 = branch1.create_checkout('tree/lightcheckout', 
 
555
        tree2 = branch1.create_checkout('tree/lightcheckout',
537
556
            lightweight=True)
538
557
        branch2 = tree2.branch
539
558
        self.assertCheckoutStatusOutput('-v tree/lightcheckout', tree2,
549
568
        tree2.add('a')
550
569
        tree2.commit('commit one')
551
570
        rev = repo.get_revision(branch2.revision_history()[0])
552
 
        datestring_first = format_date(rev.timestamp, rev.timezone)
 
571
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
553
572
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
554
573
        self.assertEqualDiff(
555
 
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
556
 
dirstate or dirstate-tags or \
557
 
pack-0.92 or rich-root or rich-root-pack)
 
574
"""Lightweight checkout (format: %s)
558
575
Location:
559
576
  light checkout root: tree/lightcheckout
560
577
   checkout of branch: repo/branch
562
579
 
563
580
Format:
564
581
       control: Meta directory format 1
565
 
  working tree: Working tree format 4
 
582
  working tree: Working tree format 6
566
583
        branch: %s
567
584
    repository: %s
568
585
 
578
595
 
579
596
Branch history:
580
597
         1 revision
581
 
         1 committer
582
598
         0 days old
583
599
   first revision: %s
584
600
  latest revision: %s
585
601
 
586
602
Repository:
587
603
         1 revision
588
 
""" % (format.get_branch_format().get_format_description(),
 
604
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
589
605
       format.repository_format.get_format_description(),
590
606
       datestring_first, datestring_first,
591
607
       ), out)
594
610
        # Out of date checkout
595
611
        out, err = self.run_bzr('info -v tree/checkout')
596
612
        self.assertEqualDiff(
597
 
"""Checkout (format: dirstate)
 
613
"""Checkout (format: unnamed)
598
614
Location:
599
615
       checkout root: tree/checkout
600
616
  checkout of branch: repo/branch
601
617
 
602
618
Format:
603
619
       control: Meta directory format 1
604
 
  working tree: Working tree format 4
 
620
  working tree: Working tree format 6
605
621
        branch: %s
606
622
    repository: %s
607
623
 
619
635
 
620
636
Branch history:
621
637
         0 revisions
622
 
         0 committers
623
638
 
624
639
Repository:
625
640
         0 revisions
634
649
        tree3.add('b')
635
650
        out, err = self.run_bzr('info tree/checkout --verbose')
636
651
        self.assertEqualDiff(
637
 
"""Checkout (format: dirstate)
 
652
"""Checkout (format: unnamed)
638
653
Location:
639
654
       checkout root: tree/checkout
640
655
  checkout of branch: repo/branch
641
656
 
642
657
Format:
643
658
       control: Meta directory format 1
644
 
  working tree: Working tree format 4
 
659
  working tree: Working tree format 6
645
660
        branch: %s
646
661
    repository: %s
647
662
 
657
672
 
658
673
Branch history:
659
674
         1 revision
660
 
         1 committer
661
675
         0 days old
662
676
   first revision: %s
663
677
  latest revision: %s
673
687
 
674
688
        # Out of date lightweight checkout
675
689
        rev = repo.get_revision(branch1.revision_history()[-1])
676
 
        datestring_last = format_date(rev.timestamp, rev.timezone)
 
690
        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
677
691
        out, err = self.run_bzr('info tree/lightcheckout --verbose')
678
692
        self.assertEqualDiff(
679
 
"""Lightweight checkout (format: 1.6 or 1.6.1-rich-root or \
680
 
dirstate or dirstate-tags or \
681
 
pack-0.92 or rich-root or rich-root-pack)
 
693
"""Lightweight checkout (format: %s)
682
694
Location:
683
695
  light checkout root: tree/lightcheckout
684
696
   checkout of branch: repo/branch
686
698
 
687
699
Format:
688
700
       control: Meta directory format 1
689
 
  working tree: Working tree format 4
 
701
  working tree: Working tree format 6
690
702
        branch: %s
691
703
    repository: %s
692
704
 
704
716
 
705
717
Branch history:
706
718
         2 revisions
707
 
         1 committer
708
719
         0 days old
709
720
   first revision: %s
710
721
  latest revision: %s
711
722
 
712
723
Repository:
713
724
         2 revisions
714
 
""" % (format.get_branch_format().get_format_description(),
 
725
""" % (self._repo_strings, format.get_branch_format().get_format_description(),
715
726
       format.repository_format.get_format_description(),
716
727
       datestring_first, datestring_last,
717
728
       ), out)
732
743
 
733
744
Branch history:
734
745
         2 revisions
735
 
         1 committer
736
746
         0 days old
737
747
   first revision: %s
738
748
  latest revision: %s
819
829
 
820
830
Branch history:
821
831
         0 revisions
822
 
         0 committers
823
832
 
824
833
Repository:
825
834
         0 revisions
834
843
        tree1.add('a')
835
844
        tree1.commit('commit one')
836
845
        rev = repo.get_revision(branch1.revision_history()[0])
837
 
        datestring_first = format_date(rev.timestamp, rev.timezone)
 
846
        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
838
847
        out, err = self.run_bzr('info -v repo/branch1')
839
848
        self.assertEqualDiff(
840
849
"""Repository tree (format: knit)
860
869
 
861
870
Branch history:
862
871
         1 revision
863
 
         1 committer
864
872
         0 days old
865
873
   first revision: %s
866
874
  latest revision: %s
902
910
 
903
911
Branch history:
904
912
         0 revisions
905
 
         0 committers
906
913
 
907
914
Repository:
908
915
         1 revision
942
949
 
943
950
Branch history:
944
951
         1 revision
945
 
         1 committer
946
952
         0 days old
947
953
   first revision: %s
948
954
  latest revision: %s
974
980
       ),
975
981
       out)
976
982
        self.assertEqual('', err)
977
 
    
 
983
 
978
984
    def test_info_shared_repository_with_tree_in_root(self):
979
985
        format = bzrdir.format_registry.make_bzrdir('knit')
980
986
        transport = self.get_transport()
1029
1035
 
1030
1036
Branch history:
1031
1037
         0 revisions
1032
 
         0 committers
1033
1038
 
1034
1039
Repository:
1035
1040
         0 revisions
1038
1043
       ), out)
1039
1044
        self.assertEqual('', err)
1040
1045
 
 
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
 
1041
1072
    def assertCheckoutStatusOutput(self,
1042
1073
        command_string, lco_tree, shared_repo=None,
1043
1074
        repo_branch=None,
1053
1084
        allow us, the test writers, to document what *should* be present in
1054
1085
        the output. Removing this separation would remove the value of the
1055
1086
        tests.
1056
 
        
 
1087
 
1057
1088
        :param path: the path to the light checkout.
1058
1089
        :param lco_tree: the tree object for the light checkout.
1059
1090
        :param shared_repo: A shared repository is in use, expect that in
1067
1098
            actually locked then this parameter is overridden. This is because
1068
1099
            pack repositories do not have any public API for obtaining an
1069
1100
            exclusive repository wide lock.
1070
 
        :param verbose: If true, expect verbose output
 
1101
        :param verbose: verbosity level: 2 or higher to show committers
1071
1102
        """
1072
1103
        def friendly_location(url):
1073
1104
            path = urlutils.unescape_for_display(url, 'ascii')
1092
1123
            (False, True): 'Lightweight checkout',
1093
1124
            (False, False): 'Checkout',
1094
1125
            }[(shared_repo is not None, light_checkout)]
1095
 
        format = {True: '1.6 or 1.6.1-rich-root'
1096
 
                        ' or dirstate or dirstate-tags or pack-0.92'
1097
 
                        ' or rich-root or rich-root-pack',
1098
 
                  False: 'dirstate'}[light_checkout]
 
1126
        format = {True: self._repo_strings,
 
1127
                  False: 'unnamed'}[light_checkout]
1099
1128
        if repo_locked:
1100
1129
            repo_locked = lco_tree.branch.repository.get_physical_lock_status()
1101
1130
        if repo_locked or branch_locked or tree_locked:
1138
1167
        else:
1139
1168
            branch_data = ("   checkout of branch: %s\n" %
1140
1169
                lco_tree.branch.bzrdir.root_transport.base)
1141
 
        
1142
 
        if verbose:
 
1170
 
 
1171
        if verbose >= 2:
1143
1172
            verbose_info = '         0 committers\n'
1144
1173
        else:
1145
1174
            verbose_info = ''
1146
 
            
 
1175
 
1147
1176
        self.assertEqualDiff(
1148
1177
"""%s (format: %s)
1149
1178
Location:
1199
1228
        # Do a light checkout of the heavy one
1200
1229
        transport.mkdir('tree/lightcheckout')
1201
1230
        lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
1202
 
        branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
 
1231
        branch.BranchReferenceFormat().initialize(lco_dir,
 
1232
            target_branch=co_branch)
1203
1233
        lco_dir.create_workingtree()
1204
1234
        lco_tree = lco_dir.open_workingtree()
1205
1235
 
1296
1326
    def test_info_locking_oslocks(self):
1297
1327
        if sys.platform == "win32":
1298
1328
            raise TestSkipped("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()
1299
1334
 
1300
1335
        tree = self.make_branch_and_tree('branch',
1301
1336
                                         format=bzrdir.BzrDirFormat6())
1331
1366
 
1332
1367
Branch history:
1333
1368
         0 revisions
1334
 
         0 committers
1335
1369
 
1336
1370
Repository:
1337
1371
         0 revisions
1364
1398
 
1365
1399
Branch history:
1366
1400
         0 revisions
1367
 
         0 committers
1368
1401
 
1369
1402
Repository:
1370
1403
         0 revisions
1376
1409
    def test_info_stacked(self):
1377
1410
        # We have a mainline
1378
1411
        trunk_tree = self.make_branch_and_tree('mainline',
1379
 
            format='development1')
 
1412
            format='1.6')
1380
1413
        trunk_tree.commit('mainline')
1381
1414
        # and a branch from it which is stacked
1382
1415
        new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
1383
1416
        out, err = self.run_bzr('info newbranch')
1384
1417
        self.assertEqual(
1385
 
"""Standalone tree (format: development1)
 
1418
"""Standalone tree (format: 1.6)
1386
1419
Location:
1387
1420
  branch root: newbranch
1388
1421