~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_controldir/test_controldir.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-09-10 11:13:02 UTC
  • mfrom: (5363.2.31 controldir-2)
  • Revision ID: pqm@pqm.ubuntu.com-20100910111302-xbneyohu4we926bl
(jelmer) More work allowing the per_controldir tests to run against foreign
 formats. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
"""Tests for bzrdir implementations - tests a bzrdir format."""
 
17
"""Tests for control directory implementations - tests a controldir format."""
18
18
 
19
 
import errno
20
19
from itertools import izip
21
20
import os
22
 
from stat import S_ISDIR
23
21
 
24
22
import bzrlib.branch
25
23
from bzrlib import (
29
27
    errors,
30
28
    gpg,
31
29
    osutils,
32
 
    revision as _mod_revision,
33
30
    transport,
34
31
    ui,
35
32
    urlutils,
36
33
    workingtree,
37
34
    )
38
 
from bzrlib.errors import (NoSuchRevision,
39
 
                           NotBranchError,
40
 
                           )
41
35
import bzrlib.revision
42
36
from bzrlib.tests import (
43
37
                          ChrootedTestCase,
54
48
 
55
49
 
56
50
class TestControlDir(TestCaseWithControlDir):
57
 
    # Many of these tests test for disk equality rather than checking
58
 
    # for semantic equivalence. This works well for some tests but
59
 
    # is not good at handling changes in representation or the addition
60
 
    # or removal of control data. It would be nice to for instance:
61
 
    # sprout a new branch, check that the nickname has been reset by hand
62
 
    # and then set the nickname to match the source branch, at which point
63
 
    # a semantic equivalence should pass
64
 
 
65
 
    def assertDirectoriesEqual(self, source, target, ignore_list=[]):
66
 
        """Assert that the content of source and target are identical.
67
 
 
68
 
        paths in ignore list will be completely ignored.
69
 
 
70
 
        We ignore paths that represent data which is allowed to change during
71
 
        a clone or sprout: for instance, inventory.knit contains gzip fragements
72
 
        which have timestamps in them, and as we have read the inventory from
73
 
        the source knit, the already-read data is recompressed rather than
74
 
        reading it again, which leads to changed timestamps. This is ok though,
75
 
        because the inventory.kndx file is not ignored, and the integrity of
76
 
        knit joins is tested by test_knit and test_versionedfile.
77
 
 
78
 
        :seealso: Additionally, assertRepositoryHasSameItems provides value
79
 
            rather than representation checking of repositories for
80
 
            equivalence.
81
 
        """
82
 
        files = []
83
 
        directories = ['.']
84
 
        while directories:
85
 
            dir = directories.pop()
86
 
            for path in set(source.list_dir(dir) + target.list_dir(dir)):
87
 
                path = dir + '/' + path
88
 
                if path in ignore_list:
89
 
                    continue
90
 
                try:
91
 
                    stat = source.stat(path)
92
 
                except errors.NoSuchFile:
93
 
                    self.fail('%s not in source' % path)
94
 
                if S_ISDIR(stat.st_mode):
95
 
                    self.assertTrue(S_ISDIR(target.stat(path).st_mode))
96
 
                    directories.append(path)
97
 
                else:
98
 
                    self.assertEqualDiff(source.get(path).read(),
99
 
                                         target.get(path).read(),
100
 
                                         "text for file %r differs:\n" % path)
101
 
 
102
 
    def assertRepositoryHasSameItems(self, left_repo, right_repo):
103
 
        """require left_repo and right_repo to contain the same data."""
104
 
        # XXX: TODO: Doesn't work yet, because we need to be able to compare
105
 
        # local repositories to remote ones...  but this is an as-yet unsolved
106
 
        # aspect of format management and the Remote protocols...
107
 
        # self.assertEqual(left_repo._format.__class__,
108
 
        #     right_repo._format.__class__)
109
 
        left_repo.lock_read()
110
 
        try:
111
 
            right_repo.lock_read()
112
 
            try:
113
 
                # revs
114
 
                all_revs = left_repo.all_revision_ids()
115
 
                self.assertEqual(left_repo.all_revision_ids(),
116
 
                    right_repo.all_revision_ids())
117
 
                for rev_id in left_repo.all_revision_ids():
118
 
                    self.assertEqual(left_repo.get_revision(rev_id),
119
 
                        right_repo.get_revision(rev_id))
120
 
                # Assert the revision trees (and thus the inventories) are equal
121
 
                sort_key = lambda rev_tree: rev_tree.get_revision_id()
122
 
                rev_trees_a = sorted(
123
 
                    left_repo.revision_trees(all_revs), key=sort_key)
124
 
                rev_trees_b = sorted(
125
 
                    right_repo.revision_trees(all_revs), key=sort_key)
126
 
                for tree_a, tree_b in zip(rev_trees_a, rev_trees_b):
127
 
                    self.assertEqual([], list(tree_a.iter_changes(tree_b)))
128
 
                # texts
129
 
                text_index = left_repo._generate_text_key_index()
130
 
                self.assertEqual(text_index,
131
 
                    right_repo._generate_text_key_index())
132
 
                desired_files = []
133
 
                for file_id, revision_id in text_index.iterkeys():
134
 
                    desired_files.append(
135
 
                        (file_id, revision_id, (file_id, revision_id)))
136
 
                left_texts = list(left_repo.iter_files_bytes(desired_files))
137
 
                right_texts = list(right_repo.iter_files_bytes(desired_files))
138
 
                left_texts.sort()
139
 
                right_texts.sort()
140
 
                self.assertEqual(left_texts, right_texts)
141
 
                # signatures
142
 
                for rev_id in all_revs:
143
 
                    try:
144
 
                        left_text = left_repo.get_signature_text(rev_id)
145
 
                    except NoSuchRevision:
146
 
                        continue
147
 
                    right_text = right_repo.get_signature_text(rev_id)
148
 
                    self.assertEqual(left_text, right_text)
149
 
            finally:
150
 
                right_repo.unlock()
151
 
        finally:
152
 
            left_repo.unlock()
153
51
 
154
52
    def skipIfNoWorkingTree(self, a_bzrdir):
155
53
        """Raises TestSkipped if a_bzrdir doesn't have a working tree.
264
162
            return
265
163
        self.assertRaises(errors.NoWorkingTree, dir.open_workingtree)
266
164
 
267
 
    def test_clone_on_transport(self):
268
 
        a_dir = self.make_bzrdir('source')
269
 
        target_transport = a_dir.root_transport.clone('..').clone('target')
270
 
        target = a_dir.clone_on_transport(target_transport)
271
 
        self.assertNotEqual(a_dir.transport.base, target.transport.base)
272
 
        self.assertDirectoriesEqual(a_dir.root_transport, target.root_transport,
273
 
                                    ['./.bzr/merge-hashes'])
274
 
 
275
 
    def test_clone_bzrdir_empty(self):
276
 
        dir = self.make_bzrdir('source')
277
 
        target = dir.clone(self.get_url('target'))
278
 
        self.assertNotEqual(dir.transport.base, target.transport.base)
279
 
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport,
280
 
                                    ['./.bzr/merge-hashes'])
281
 
 
282
 
    def test_clone_bzrdir_empty_force_new_ignored(self):
283
 
        # the force_new_repo parameter should have no effect on an empty
284
 
        # bzrdir's clone logic
285
 
        dir = self.make_bzrdir('source')
286
 
        target = dir.clone(self.get_url('target'), force_new_repo=True)
287
 
        self.assertNotEqual(dir.transport.base, target.transport.base)
288
 
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport,
289
 
                                    ['./.bzr/merge-hashes'])
290
 
 
291
 
    def test_clone_bzrdir_repository(self):
292
 
        tree = self.make_branch_and_tree('commit_tree')
293
 
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
294
 
        tree.add('foo')
295
 
        tree.commit('revision 1', rev_id='1')
296
 
        dir = self.make_bzrdir('source')
297
 
        repo = dir.create_repository()
298
 
        repo.fetch(tree.branch.repository)
299
 
        self.assertTrue(repo.has_revision('1'))
300
 
        target = dir.clone(self.get_url('target'))
301
 
        self.assertNotEqual(dir.transport.base, target.transport.base)
302
 
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport,
303
 
                                    [
304
 
                                     './.bzr/merge-hashes',
305
 
                                     './.bzr/repository',
306
 
                                     ])
307
 
        self.assertRepositoryHasSameItems(tree.branch.repository,
308
 
            target.open_repository())
309
 
 
310
165
    def test_clone_bzrdir_repository_under_shared(self):
311
166
        tree = self.make_branch_and_tree('commit_tree')
312
167
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
382
237
        self.assertFalse(branch.repository.make_working_trees())
383
238
        self.assertTrue(branch.repository.is_shared())
384
239
 
385
 
    def test_clone_bzrdir_repository_under_shared_force_new_repo(self):
386
 
        tree = self.make_branch_and_tree('commit_tree')
387
 
        self.build_tree(['commit_tree/foo'])
388
 
        tree.add('foo')
389
 
        tree.commit('revision 1', rev_id='1')
390
 
        dir = self.make_bzrdir('source')
391
 
        repo = dir.create_repository()
392
 
        repo.fetch(tree.branch.repository)
393
 
        self.assertTrue(repo.has_revision('1'))
394
 
        try:
395
 
            self.make_repository('target', shared=True)
396
 
        except errors.IncompatibleFormat:
397
 
            return
398
 
        target = dir.clone(self.get_url('target/child'), force_new_repo=True)
399
 
        self.assertNotEqual(dir.transport.base, target.transport.base)
400
 
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport,
401
 
                                    ['./.bzr/repository',
402
 
                                     ])
403
 
        self.assertRepositoryHasSameItems(tree.branch.repository, repo)
404
 
 
405
240
    def test_clone_bzrdir_repository_revision(self):
406
241
        # test for revision limiting, [smoke test, not corner case checks].
407
242
        # make a repository with some revisions,
441
276
            tree_repo.get_signature_text(rev1),
442
277
            target.repository.get_signature_text(rev1))
443
278
 
444
 
    def test_clone_bzrdir_branch_and_repo(self):
445
 
        tree = self.make_branch_and_tree('commit_tree')
446
 
        self.build_tree(['commit_tree/foo'])
447
 
        tree.add('foo')
448
 
        tree.commit('revision 1')
449
 
        source = self.make_branch('source')
450
 
        tree.branch.repository.copy_content_into(source.repository)
451
 
        tree.branch.copy_content_into(source)
452
 
        dir = source.bzrdir
453
 
        target = dir.clone(self.get_url('target'))
454
 
        self.assertNotEqual(dir.transport.base, target.transport.base)
455
 
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport,
456
 
                                    [
457
 
                                     './.bzr/basis-inventory-cache',
458
 
                                     './.bzr/checkout/stat-cache',
459
 
                                     './.bzr/merge-hashes',
460
 
                                     './.bzr/repository',
461
 
                                     './.bzr/stat-cache',
462
 
                                    ])
463
 
        self.assertRepositoryHasSameItems(
464
 
            tree.branch.repository, target.open_repository())
465
 
 
466
279
    def test_clone_bzrdir_branch_and_repo_into_shared_repo(self):
467
280
        # by default cloning into a shared repo uses the shared repo.
468
281
        tree = self.make_branch_and_tree('commit_tree')
483
296
        self.assertEqual(source.revision_history(),
484
297
                         target.open_branch().revision_history())
485
298
 
486
 
    def test_clone_bzrdir_branch_and_repo_into_shared_repo_force_new_repo(self):
487
 
        # by default cloning into a shared repo uses the shared repo.
488
 
        tree = self.make_branch_and_tree('commit_tree')
489
 
        self.build_tree(['commit_tree/foo'])
490
 
        tree.add('foo')
491
 
        tree.commit('revision 1')
492
 
        source = self.make_branch('source')
493
 
        tree.branch.repository.copy_content_into(source.repository)
494
 
        tree.branch.copy_content_into(source)
495
 
        try:
496
 
            self.make_repository('target', shared=True)
497
 
        except errors.IncompatibleFormat:
498
 
            return
499
 
        dir = source.bzrdir
500
 
        target = dir.clone(self.get_url('target/child'), force_new_repo=True)
501
 
        self.assertNotEqual(dir.transport.base, target.transport.base)
502
 
        repo = target.open_repository()
503
 
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport,
504
 
                                    ['./.bzr/repository',
505
 
                                     ])
506
 
        self.assertRepositoryHasSameItems(tree.branch.repository, repo)
507
 
 
508
 
    def test_clone_bzrdir_branch_reference(self):
509
 
        # cloning should preserve the reference status of the branch in a bzrdir
510
 
        referenced_branch = self.make_branch('referencced')
511
 
        dir = self.make_bzrdir('source')
512
 
        try:
513
 
            reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
514
 
                target_branch=referenced_branch)
515
 
        except errors.IncompatibleFormat:
516
 
            # this is ok too, not all formats have to support references.
517
 
            return
518
 
        target = dir.clone(self.get_url('target'))
519
 
        self.assertNotEqual(dir.transport.base, target.transport.base)
520
 
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport)
521
 
 
522
299
    def test_clone_bzrdir_branch_revision(self):
523
300
        # test for revision limiting, [smoke test, not corner case checks].
524
301
        # make a branch with some revisions,
536
313
        target = dir.clone(self.get_url('target'), revision_id='1')
537
314
        self.assertEqual('1', target.open_branch().last_revision())
538
315
 
539
 
    def test_clone_bzrdir_tree_branch_repo(self):
540
 
        tree = self.make_branch_and_tree('source')
541
 
        self.build_tree(['source/foo'])
542
 
        tree.add('foo')
543
 
        tree.commit('revision 1')
544
 
        dir = tree.bzrdir
545
 
        target = dir.clone(self.get_url('target'))
546
 
        self.skipIfNoWorkingTree(target)
547
 
        self.assertNotEqual(dir.transport.base, target.transport.base)
548
 
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport,
549
 
                                    ['./.bzr/stat-cache',
550
 
                                     './.bzr/checkout/dirstate',
551
 
                                     './.bzr/checkout/stat-cache',
552
 
                                     './.bzr/checkout/merge-hashes',
553
 
                                     './.bzr/merge-hashes',
554
 
                                     './.bzr/repository',
555
 
                                     ])
556
 
        self.assertRepositoryHasSameItems(tree.branch.repository,
557
 
            target.open_repository())
558
 
        target.open_workingtree().revert()
559
 
 
560
316
    def test_clone_on_transport_preserves_repo_format(self):
561
317
        if self.bzrdir_format == bzrdir.format_registry.make_bzrdir('default'):
562
318
            format = 'knit'
576
332
            target_repo = target_repo._real_repository
577
333
        self.assertEqual(target_repo._format, source_branch.repository._format)
578
334
 
579
 
    def test_revert_inventory(self):
580
 
        tree = self.make_branch_and_tree('source')
581
 
        self.build_tree(['source/foo'])
582
 
        tree.add('foo')
583
 
        tree.commit('revision 1')
584
 
        dir = tree.bzrdir
585
 
        target = dir.clone(self.get_url('target'))
586
 
        self.skipIfNoWorkingTree(target)
587
 
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport,
588
 
                                    ['./.bzr/stat-cache',
589
 
                                     './.bzr/checkout/dirstate',
590
 
                                     './.bzr/checkout/stat-cache',
591
 
                                     './.bzr/checkout/merge-hashes',
592
 
                                     './.bzr/merge-hashes',
593
 
                                     './.bzr/repository',
594
 
                                     ])
595
 
        self.assertRepositoryHasSameItems(tree.branch.repository,
596
 
            target.open_repository())
597
 
 
598
 
        target.open_workingtree().revert()
599
 
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport,
600
 
                                    ['./.bzr/stat-cache',
601
 
                                     './.bzr/checkout/dirstate',
602
 
                                     './.bzr/checkout/stat-cache',
603
 
                                     './.bzr/checkout/merge-hashes',
604
 
                                     './.bzr/merge-hashes',
605
 
                                     './.bzr/repository',
606
 
                                     ])
607
 
        self.assertRepositoryHasSameItems(tree.branch.repository,
608
 
            target.open_repository())
609
 
 
610
 
    def test_clone_bzrdir_tree_branch_reference(self):
611
 
        # a tree with a branch reference (aka a checkout)
612
 
        # should stay a checkout on clone.
613
 
        referenced_branch = self.make_branch('referencced')
614
 
        dir = self.make_bzrdir('source')
615
 
        try:
616
 
            reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
617
 
                target_branch=referenced_branch)
618
 
        except errors.IncompatibleFormat:
619
 
            # this is ok too, not all formats have to support references.
620
 
            return
621
 
        self.createWorkingTreeOrSkip(dir)
622
 
        target = dir.clone(self.get_url('target'))
623
 
        self.skipIfNoWorkingTree(target)
624
 
        self.assertNotEqual(dir.transport.base, target.transport.base)
625
 
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport,
626
 
                                    ['./.bzr/stat-cache',
627
 
                                     './.bzr/checkout/stat-cache',
628
 
                                     './.bzr/checkout/merge-hashes',
629
 
                                     './.bzr/merge-hashes',
630
 
                                     './.bzr/repository/inventory.knit',
631
 
                                     ])
632
 
 
633
335
    def test_clone_bzrdir_tree_revision(self):
634
336
        # test for revision limiting, [smoke test, not corner case checks].
635
337
        # make a tree with a revision with a last-revision
737
439
        target.open_branch()
738
440
        self.openWorkingTreeIfLocal(target)
739
441
 
740
 
    def test_sprout_bzrdir_repository(self):
741
 
        tree = self.make_branch_and_tree('commit_tree')
742
 
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
743
 
        tree.add('foo')
744
 
        tree.commit('revision 1', rev_id='1')
745
 
        dir = self.make_bzrdir('source')
746
 
        repo = dir.create_repository()
747
 
        repo.fetch(tree.branch.repository)
748
 
        self.assertTrue(repo.has_revision('1'))
749
 
        try:
750
 
            self.assertTrue(
751
 
                _mod_revision.is_null(_mod_revision.ensure_null(
752
 
                dir.open_branch().last_revision())))
753
 
        except errors.NotBranchError:
754
 
            pass
755
 
        target = dir.sprout(self.get_url('target'))
756
 
        self.assertNotEqual(dir.transport.base, target.transport.base)
757
 
        # testing inventory isn't reasonable for repositories
758
 
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport,
759
 
                                    [
760
 
                                     './.bzr/branch',
761
 
                                     './.bzr/checkout',
762
 
                                     './.bzr/inventory',
763
 
                                     './.bzr/parent',
764
 
                                     './.bzr/repository/inventory.knit',
765
 
                                     ])
766
 
        try:
767
 
            local_inventory = dir.transport.local_abspath('inventory')
768
 
        except errors.NotLocalUrl:
769
 
            return
770
 
        try:
771
 
            # If we happen to have a tree, we'll guarantee everything
772
 
            # except for the tree root is the same.
773
 
            inventory_f = file(local_inventory, 'rb')
774
 
            self.addCleanup(inventory_f.close)
775
 
            self.assertContainsRe(inventory_f.read(),
776
 
                                  '<inventory format="5">\n</inventory>\n')
777
 
        except IOError, e:
778
 
            if e.errno != errno.ENOENT:
779
 
                raise
780
 
 
781
442
    def test_sprout_bzrdir_with_repository_to_shared(self):
782
443
        tree = self.make_branch_and_tree('commit_tree')
783
444
        self.build_tree(['commit_tree/foo'])
882
543
        target = self.sproutOrSkip(dir, self.get_url('target'), revision_id='2')
883
544
        raise TestSkipped('revision limiting not strict yet')
884
545
 
885
 
    def test_sprout_bzrdir_branch_and_repo(self):
886
 
        tree = self.make_branch_and_tree('commit_tree')
887
 
        self.build_tree(['commit_tree/foo'])
888
 
        tree.add('foo')
889
 
        tree.commit('revision 1')
890
 
        source = self.make_branch('source')
891
 
        tree.branch.repository.copy_content_into(source.repository)
892
 
        tree.bzrdir.open_branch().copy_content_into(source)
893
 
        dir = source.bzrdir
894
 
        target = dir.sprout(self.get_url('target'))
895
 
        self.assertNotEqual(dir.transport.base, target.transport.base)
896
 
        target_repo = target.open_repository()
897
 
        self.assertRepositoryHasSameItems(source.repository, target_repo)
898
 
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport,
899
 
                                    [
900
 
                                     './.bzr/basis-inventory-cache',
901
 
                                     './.bzr/branch/branch.conf',
902
 
                                     './.bzr/branch/parent',
903
 
                                     './.bzr/checkout',
904
 
                                     './.bzr/checkout/inventory',
905
 
                                     './.bzr/checkout/stat-cache',
906
 
                                     './.bzr/inventory',
907
 
                                     './.bzr/parent',
908
 
                                     './.bzr/repository',
909
 
                                     './.bzr/stat-cache',
910
 
                                     './foo',
911
 
                                     ])
912
 
 
913
546
    def test_sprout_bzrdir_branch_and_repo_shared(self):
914
547
        # sprouting a branch with a repo into a shared repo uses the shared
915
548
        # repo
1034
667
        target = dir.sprout(self.get_url('target'), revision_id='1')
1035
668
        self.assertEqual('1', target.open_branch().last_revision())
1036
669
 
1037
 
    def test_sprout_bzrdir_tree_branch_repo(self):
1038
 
        tree = self.make_branch_and_tree('source')
1039
 
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
1040
 
        tree.add('foo')
1041
 
        tree.commit('revision 1')
1042
 
        dir = tree.bzrdir
1043
 
        target = self.sproutOrSkip(dir, self.get_url('target'))
1044
 
        self.assertNotEqual(dir.transport.base, target.transport.base)
1045
 
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport,
1046
 
                                    [
1047
 
                                     './.bzr/branch/branch.conf',
1048
 
                                     './.bzr/branch/parent',
1049
 
                                     './.bzr/checkout/dirstate',
1050
 
                                     './.bzr/checkout/stat-cache',
1051
 
                                     './.bzr/checkout/inventory',
1052
 
                                     './.bzr/inventory',
1053
 
                                     './.bzr/parent',
1054
 
                                     './.bzr/repository',
1055
 
                                     './.bzr/stat-cache',
1056
 
                                     ])
1057
 
        self.assertRepositoryHasSameItems(
1058
 
            tree.branch.repository, target.open_repository())
1059
 
 
1060
670
    def test_sprout_bzrdir_tree_branch_reference(self):
1061
671
        # sprouting should create a repository if needed and a sprouted branch.
1062
672
        # the tree state should not be copied.
1393
1003
            network_name = format.network_name()
1394
1004
            self.assertEqual(real_dir._format.network_name(), network_name)
1395
1005
        else:
1396
 
            registry = bzrdir.network_format_registry
 
1006
            registry = controldir.network_format_registry
1397
1007
            network_name = format.network_name()
1398
1008
            looked_up_format = registry.get(network_name)
1399
1009
            self.assertEqual(format.__class__, looked_up_format.__class__)
1402
1012
 
1403
1013
    def test_open_not_bzrdir(self):
1404
1014
        # test the formats specific behaviour for no-content or similar dirs.
1405
 
        self.assertRaises(NotBranchError,
 
1015
        self.assertRaises(errors.NotBranchError,
1406
1016
                          self.bzrdir_format.open,
1407
1017
                          transport.get_transport(self.get_readonly_url()))
1408
1018
 
1802
1412
        text = dir._format.get_format_description()
1803
1413
        self.failUnless(len(text))
1804
1414
 
1805
 
    def test_retire_bzrdir(self):
1806
 
        bd = self.make_bzrdir('.')
1807
 
        transport = bd.root_transport
1808
 
        # must not overwrite existing directories
1809
 
        self.build_tree(['.bzr.retired.0/', '.bzr.retired.0/junk',],
1810
 
            transport=transport)
1811
 
        self.failUnless(transport.has('.bzr'))
1812
 
        bd.retire_bzrdir()
1813
 
        self.failIf(transport.has('.bzr'))
1814
 
        self.failUnless(transport.has('.bzr.retired.1'))
1815
 
 
1816
 
    def test_retire_bzrdir_limited(self):
1817
 
        bd = self.make_bzrdir('.')
1818
 
        transport = bd.root_transport
1819
 
        # must not overwrite existing directories
1820
 
        self.build_tree(['.bzr.retired.0/', '.bzr.retired.0/junk',],
1821
 
            transport=transport)
1822
 
        self.failUnless(transport.has('.bzr'))
1823
 
        self.assertRaises((errors.FileExists, errors.DirectoryNotEmpty),
1824
 
            bd.retire_bzrdir, limit=0)
1825
 
 
1826
1415
 
1827
1416
class TestBreakLock(TestCaseWithControlDir):
1828
1417