/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_bzrdir/test_bzrdir.py

  • Committer: Andrew Bennetts
  • Date: 2010-01-12 03:53:21 UTC
  • mfrom: (4948 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4964.
  • Revision ID: andrew.bennetts@canonical.com-20100112035321-hofpz5p10224ryj3
Merge lp:bzr, resolving conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
"""Tests for bzrdir implementations - tests a bzrdir format."""
18
18
 
26
26
import bzrlib.branch
27
27
from bzrlib import (
28
28
    bzrdir,
 
29
    check,
29
30
    errors,
 
31
    gpg,
30
32
    lockdir,
31
33
    osutils,
32
34
    repository,
38
40
    workingtree,
39
41
    )
40
42
from bzrlib.branch import Branch, needs_read_lock, needs_write_lock
41
 
from bzrlib.check import check_branch
42
43
from bzrlib.errors import (FileExists,
43
44
                           NoSuchRevision,
44
45
                           NoSuchFile,
53
54
                          TestNotApplicable,
54
55
                          TestSkipped,
55
56
                          )
56
 
from bzrlib.tests.bzrdir_implementations import TestCaseWithBzrDir
 
57
from bzrlib.tests.per_bzrdir import TestCaseWithBzrDir
57
58
from bzrlib.trace import mutter
58
59
from bzrlib.transport import get_transport
59
60
from bzrlib.transport.local import LocalTransport
 
61
from bzrlib.ui import (
 
62
    CannedInputUIFactory,
 
63
    )
60
64
from bzrlib.upgrade import upgrade
61
 
from bzrlib.remote import RemoteBzrDir
 
65
from bzrlib.remote import RemoteBzrDir, RemoteRepository
62
66
from bzrlib.repofmt import weaverepo
63
67
 
64
68
 
75
79
        """Assert that the content of source and target are identical.
76
80
 
77
81
        paths in ignore list will be completely ignored.
78
 
        
 
82
 
79
83
        We ignore paths that represent data which is allowed to change during
80
84
        a clone or sprout: for instance, inventory.knit contains gzip fragements
81
 
        which have timestamps in them, and as we have read the inventory from 
 
85
        which have timestamps in them, and as we have read the inventory from
82
86
        the source knit, the already-read data is recompressed rather than
83
87
        reading it again, which leads to changed timestamps. This is ok though,
84
88
        because the inventory.kndx file is not ignored, and the integrity of
126
130
                for rev_id in left_repo.all_revision_ids():
127
131
                    self.assertEqual(left_repo.get_revision(rev_id),
128
132
                        right_repo.get_revision(rev_id))
129
 
                # inventories
130
 
                left_inv_weave = left_repo.inventories
131
 
                right_inv_weave = right_repo.inventories
132
 
                self.assertEqual(set(left_inv_weave.keys()),
133
 
                    set(right_inv_weave.keys()))
134
 
                # XXX: currently this does not handle indirectly referenced
135
 
                # inventories (e.g. where the inventory is a delta basis for
136
 
                # one that is fully present but that the revid for that
137
 
                # inventory is not yet present.)
138
 
                self.assertEqual(set(left_inv_weave.keys()),
139
 
                    set(left_repo.revisions.keys()))
140
 
                left_trees = left_repo.revision_trees(all_revs)
141
 
                right_trees = right_repo.revision_trees(all_revs)
142
 
                for left_tree, right_tree in izip(left_trees, right_trees):
143
 
                    self.assertEqual(left_tree.inventory, right_tree.inventory)
 
133
                # Assert the revision trees (and thus the inventories) are equal
 
134
                sort_key = lambda rev_tree: rev_tree.get_revision_id()
 
135
                rev_trees_a = sorted(
 
136
                    left_repo.revision_trees(all_revs), key=sort_key)
 
137
                rev_trees_b = sorted(
 
138
                    right_repo.revision_trees(all_revs), key=sort_key)
 
139
                for tree_a, tree_b in zip(rev_trees_a, rev_trees_b):
 
140
                    self.assertEqual([], list(tree_a.iter_changes(tree_b)))
144
141
                # texts
145
142
                text_index = left_repo._generate_text_key_index()
146
143
                self.assertEqual(text_index,
169
166
 
170
167
    def skipIfNoWorkingTree(self, a_bzrdir):
171
168
        """Raises TestSkipped if a_bzrdir doesn't have a working tree.
172
 
        
 
169
 
173
170
        If the bzrdir does have a workingtree, this is a no-op.
174
171
        """
175
172
        try:
178
175
            raise TestSkipped("bzrdir on transport %r has no working tree"
179
176
                              % a_bzrdir.transport)
180
177
 
 
178
    def openWorkingTreeIfLocal(self, a_bzrdir):
 
179
        """If a_bzrdir is on a local transport, call open_workingtree() on it.
 
180
        """
 
181
        if not isinstance(a_bzrdir.root_transport, LocalTransport):
 
182
            # it's not local, but that's ok
 
183
            return
 
184
        a_bzrdir.open_workingtree()
 
185
 
181
186
    def createWorkingTreeOrSkip(self, a_bzrdir):
182
187
        """Create a working tree on a_bzrdir, or raise TestSkipped.
183
 
        
 
188
 
184
189
        A simple wrapper for create_workingtree that translates NotLocalUrl into
185
190
        TestSkipped.  Returns the newly created working tree.
186
191
        """
191
196
                              % a_bzrdir.transport)
192
197
 
193
198
    def sproutOrSkip(self, from_bzrdir, to_url, revision_id=None,
194
 
                     force_new_repo=False, accelerator_tree=None):
 
199
                     force_new_repo=False, accelerator_tree=None,
 
200
                     create_tree_if_local=True):
195
201
        """Sprout from_bzrdir into to_url, or raise TestSkipped.
196
 
        
 
202
 
197
203
        A simple wrapper for from_bzrdir.sprout that translates NotLocalUrl into
198
204
        TestSkipped.  Returns the newly sprouted bzrdir.
199
205
        """
203
209
        target = from_bzrdir.sprout(to_url, revision_id=revision_id,
204
210
                                    force_new_repo=force_new_repo,
205
211
                                    possible_transports=[to_transport],
206
 
                                    accelerator_tree=accelerator_tree)
 
212
                                    accelerator_tree=accelerator_tree,
 
213
                                    create_tree_if_local=create_tree_if_local)
207
214
        return target
208
215
 
209
216
    def test_create_null_workingtree(self):
284
291
        self.assertNotEqual(dir.transport.base, target.transport.base)
285
292
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport,
286
293
                                    ['./.bzr/merge-hashes'])
287
 
    
 
294
 
288
295
    def test_clone_bzrdir_empty_force_new_ignored(self):
289
296
        # the force_new_repo parameter should have no effect on an empty
290
297
        # bzrdir's clone logic
293
300
        self.assertNotEqual(dir.transport.base, target.transport.base)
294
301
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport,
295
302
                                    ['./.bzr/merge-hashes'])
296
 
    
 
303
 
297
304
    def test_clone_bzrdir_repository(self):
298
305
        tree = self.make_branch_and_tree('commit_tree')
299
306
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
387
394
        self.assertTrue(branch.repository.has_revision('1'))
388
395
        self.assertFalse(branch.repository.make_working_trees())
389
396
        self.assertTrue(branch.repository.is_shared())
390
 
        
 
397
 
391
398
    def test_clone_bzrdir_repository_under_shared_force_new_repo(self):
392
399
        tree = self.make_branch_and_tree('commit_tree')
393
400
        self.build_tree(['commit_tree/foo'])
412
419
        # test for revision limiting, [smoke test, not corner case checks].
413
420
        # make a repository with some revisions,
414
421
        # and clone it with a revision limit.
415
 
        # 
 
422
        #
416
423
        tree = self.make_branch_and_tree('commit_tree')
417
424
        self.build_tree(['commit_tree/foo'])
418
425
        tree.add('foo')
426
433
        target = dir.clone(self.get_url('target'), revision_id='2')
427
434
        raise TestSkipped('revision limiting not strict yet')
428
435
 
 
436
    def test_clone_bzrdir_branch_and_repo_fixed_user_id(self):
 
437
        # Bug #430868 is about an email containing '.sig'
 
438
        os.environ['BZR_EMAIL'] = 'murphy@host.sighup.org'
 
439
        tree = self.make_branch_and_tree('commit_tree')
 
440
        self.build_tree(['commit_tree/foo'])
 
441
        tree.add('foo')
 
442
        rev1 = tree.commit('revision 1')
 
443
        tree_repo = tree.branch.repository
 
444
        tree_repo.lock_write()
 
445
        tree_repo.start_write_group()
 
446
        tree_repo.sign_revision(rev1, gpg.LoopbackGPGStrategy(None))
 
447
        tree_repo.commit_write_group()
 
448
        tree_repo.unlock()
 
449
        target = self.make_branch('target')
 
450
        tree.branch.repository.copy_content_into(target.repository)
 
451
        tree.branch.copy_content_into(target)
 
452
        self.assertTrue(target.repository.has_revision(rev1))
 
453
        self.assertEqual(
 
454
            tree_repo.get_signature_text(rev1),
 
455
            target.repository.get_signature_text(rev1))
 
456
 
429
457
    def test_clone_bzrdir_branch_and_repo(self):
430
458
        tree = self.make_branch_and_tree('commit_tree')
431
459
        self.build_tree(['commit_tree/foo'])
508
536
        # test for revision limiting, [smoke test, not corner case checks].
509
537
        # make a branch with some revisions,
510
538
        # and clone it with a revision limit.
511
 
        # 
 
539
        #
512
540
        tree = self.make_branch_and_tree('commit_tree')
513
541
        self.build_tree(['commit_tree/foo'])
514
542
        tree.add('foo')
520
548
        dir = source.bzrdir
521
549
        target = dir.clone(self.get_url('target'), revision_id='1')
522
550
        self.assertEqual('1', target.open_branch().last_revision())
523
 
        
 
551
 
524
552
    def test_clone_bzrdir_tree_branch_repo(self):
525
553
        tree = self.make_branch_and_tree('source')
526
554
        self.build_tree(['source/foo'])
551
579
        # Ensure no format data is cached
552
580
        a_dir = bzrlib.branch.Branch.open_from_transport(
553
581
            self.get_transport('source')).bzrdir
554
 
        target_transport = a_dir.root_transport.clone('..').clone('target')
 
582
        target_transport = self.get_transport('target')
555
583
        target_bzrdir = a_dir.clone_on_transport(target_transport)
556
584
        target_repo = target_bzrdir.open_repository()
557
585
        source_branch = bzrlib.branch.Branch.open(
558
586
            self.get_vfs_only_url('source'))
 
587
        if isinstance(target_repo, RemoteRepository):
 
588
            target_repo._ensure_real()
 
589
            target_repo = target_repo._real_repository
559
590
        self.assertEqual(target_repo._format, source_branch.repository._format)
560
591
 
561
592
    def test_revert_inventory(self):
590
621
            target.open_repository())
591
622
 
592
623
    def test_clone_bzrdir_tree_branch_reference(self):
593
 
        # a tree with a branch reference (aka a checkout) 
 
624
        # a tree with a branch reference (aka a checkout)
594
625
        # should stay a checkout on clone.
595
626
        referenced_branch = self.make_branch('referencced')
596
627
        dir = self.make_bzrdir('source')
650
681
 
651
682
    def test_clone_respects_stacked(self):
652
683
        branch = self.make_branch('parent')
653
 
        child_transport = branch.bzrdir.root_transport.clone('../child')
 
684
        child_transport = self.get_transport('child')
654
685
        child = branch.bzrdir.clone_on_transport(child_transport,
655
686
                                                 stacked_on=branch.base)
656
687
        self.assertEqual(child.open_branch().get_stacked_on_url(), branch.base)
683
714
 
684
715
    def test_sprout_bzrdir_empty(self):
685
716
        dir = self.make_bzrdir('source')
686
 
        target = self.sproutOrSkip(dir, self.get_url('target'))
 
717
        target = dir.sprout(self.get_url('target'))
687
718
        self.assertNotEqual(dir.transport.base, target.transport.base)
688
719
        # creates a new repository branch and tree
689
720
        target.open_repository()
690
721
        target.open_branch()
691
 
        target.open_workingtree()
 
722
        self.openWorkingTreeIfLocal(target)
692
723
 
693
724
    def test_sprout_bzrdir_empty_under_shared_repo(self):
694
725
        # sprouting an empty dir into a repo uses the repo
697
728
            self.make_repository('target', shared=True)
698
729
        except errors.IncompatibleFormat:
699
730
            return
700
 
        target = self.sproutOrSkip(dir, self.get_url('target/child'))
 
731
        target = dir.sprout(self.get_url('target/child'))
701
732
        self.assertRaises(errors.NoRepositoryPresent, target.open_repository)
702
733
        target.open_branch()
703
734
        try:
715
746
            self.make_repository('target', shared=True)
716
747
        except errors.IncompatibleFormat:
717
748
            return
718
 
        target = self.sproutOrSkip(dir, self.get_url('target/child'),
719
 
                                   force_new_repo=True)
 
749
        target = dir.sprout(self.get_url('target/child'), force_new_repo=True)
720
750
        target.open_repository()
721
751
        target.open_branch()
722
 
        target.open_workingtree()
723
 
    
 
752
        self.openWorkingTreeIfLocal(target)
 
753
 
724
754
    def test_sprout_bzrdir_repository(self):
725
755
        tree = self.make_branch_and_tree('commit_tree')
726
756
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
736
766
                dir.open_branch().last_revision())))
737
767
        except errors.NotBranchError:
738
768
            pass
739
 
        target = self.sproutOrSkip(dir, self.get_url('target'))
 
769
        target = dir.sprout(self.get_url('target'))
740
770
        self.assertNotEqual(dir.transport.base, target.transport.base)
741
771
        # testing inventory isn't reasonable for repositories
742
772
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport,
748
778
                                     './.bzr/repository/inventory.knit',
749
779
                                     ])
750
780
        try:
 
781
            local_inventory = dir.transport.local_abspath('inventory')
 
782
        except errors.NotLocalUrl:
 
783
            return
 
784
        try:
751
785
            # If we happen to have a tree, we'll guarantee everything
752
786
            # except for the tree root is the same.
753
 
            inventory_f = file(dir.transport.base+'inventory', 'rb')
754
 
            self.assertContainsRe(inventory_f.read(), 
755
 
                                  '<inventory file_id="TREE_ROOT[^"]*"'
756
 
                                  ' format="5">\n</inventory>\n')
757
 
            inventory_f.close()
 
787
            inventory_f = file(local_inventory, 'rb')
 
788
            self.addCleanup(inventory_f.close)
 
789
            self.assertContainsRe(inventory_f.read(),
 
790
                                  '<inventory format="5">\n</inventory>\n')
758
791
        except IOError, e:
759
792
            if e.errno != errno.ENOENT:
760
793
                raise
774
807
            shared_repo = self.make_repository('target', shared=True)
775
808
        except errors.IncompatibleFormat:
776
809
            return
777
 
        target = self.sproutOrSkip(dir, self.get_url('target/child'))
 
810
        target = dir.sprout(self.get_url('target/child'))
778
811
        self.assertNotEqual(dir.transport.base, target.transport.base)
779
812
        self.assertTrue(shared_repo.has_revision('1'))
780
813
 
793
826
        tree.branch.repository.copy_content_into(shared_repo)
794
827
        dir = self.make_bzrdir('shared/source')
795
828
        dir.create_branch()
796
 
        target = self.sproutOrSkip(dir, self.get_url('shared/target'))
 
829
        target = dir.sprout(self.get_url('shared/target'))
797
830
        self.assertNotEqual(dir.transport.base, target.transport.base)
798
831
        self.assertNotEqual(dir.transport.base, shared_repo.bzrdir.transport.base)
799
832
        self.assertTrue(shared_repo.has_revision('1'))
817
850
        self.assertTrue(shared_repo.has_revision('1'))
818
851
        dir = self.make_bzrdir('shared/source')
819
852
        dir.create_branch()
820
 
        target = self.sproutOrSkip(dir, self.get_url('target'))
 
853
        target = dir.sprout(self.get_url('target'))
821
854
        self.assertNotEqual(dir.transport.base, target.transport.base)
822
855
        self.assertNotEqual(dir.transport.base, shared_repo.bzrdir.transport.base)
823
856
        branch = target.open_branch()
841
874
            shared_repo = self.make_repository('target', shared=True)
842
875
        except errors.IncompatibleFormat:
843
876
            return
844
 
        target = self.sproutOrSkip(dir, self.get_url('target/child'),
845
 
                                   force_new_repo=True)
 
877
        target = dir.sprout(self.get_url('target/child'), force_new_repo=True)
846
878
        self.assertNotEqual(dir.transport.base, target.transport.base)
847
879
        self.assertFalse(shared_repo.has_revision('1'))
848
880
 
850
882
        # test for revision limiting, [smoke test, not corner case checks].
851
883
        # make a repository with some revisions,
852
884
        # and sprout it with a revision limit.
853
 
        # 
 
885
        #
854
886
        tree = self.make_branch_and_tree('commit_tree')
855
887
        self.build_tree(['commit_tree/foo'])
856
888
        tree.add('foo')
873
905
        tree.branch.repository.copy_content_into(source.repository)
874
906
        tree.bzrdir.open_branch().copy_content_into(source)
875
907
        dir = source.bzrdir
876
 
        target = self.sproutOrSkip(dir, self.get_url('target'))
 
908
        target = dir.sprout(self.get_url('target'))
877
909
        self.assertNotEqual(dir.transport.base, target.transport.base)
 
910
        target_repo = target.open_repository()
 
911
        self.assertRepositoryHasSameItems(source.repository, target_repo)
878
912
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport,
879
913
                                    [
880
914
                                     './.bzr/basis-inventory-cache',
885
919
                                     './.bzr/checkout/stat-cache',
886
920
                                     './.bzr/inventory',
887
921
                                     './.bzr/parent',
888
 
                                     './.bzr/repository/inventory.knit',
 
922
                                     './.bzr/repository',
889
923
                                     './.bzr/stat-cache',
890
924
                                     './foo',
891
925
                                     ])
905
939
            shared_repo = self.make_repository('target', shared=True)
906
940
        except errors.IncompatibleFormat:
907
941
            return
908
 
        target = self.sproutOrSkip(dir, self.get_url('target/child'))
 
942
        target = dir.sprout(self.get_url('target/child'))
909
943
        self.assertTrue(shared_repo.has_revision('1'))
910
944
 
911
945
    def test_sprout_bzrdir_branch_and_repo_shared_force_new_repo(self):
923
957
            shared_repo = self.make_repository('target', shared=True)
924
958
        except errors.IncompatibleFormat:
925
959
            return
926
 
        target = self.sproutOrSkip(dir, self.get_url('target/child'),
927
 
                                   force_new_repo=True)
 
960
        target = dir.sprout(self.get_url('target/child'), force_new_repo=True)
928
961
        self.assertNotEqual(dir.transport.base, target.transport.base)
929
962
        self.assertFalse(shared_repo.has_revision('1'))
930
963
 
931
964
    def test_sprout_bzrdir_branch_reference(self):
932
965
        # sprouting should create a repository if needed and a sprouted branch.
933
 
        referenced_branch = self.make_branch('referencced')
 
966
        referenced_branch = self.make_branch('referenced')
934
967
        dir = self.make_bzrdir('source')
935
968
        try:
936
969
            reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
939
972
            # this is ok too, not all formats have to support references.
940
973
            return
941
974
        self.assertRaises(errors.NoRepositoryPresent, dir.open_repository)
942
 
        target = self.sproutOrSkip(dir, self.get_url('target'))
 
975
        target = dir.sprout(self.get_url('target'))
943
976
        self.assertNotEqual(dir.transport.base, target.transport.base)
944
977
        # we want target to have a branch that is in-place.
945
978
        self.assertEqual(target, target.open_branch().bzrdir)
946
 
        # and as we dont support repositories being detached yet, a repo in 
 
979
        # and as we dont support repositories being detached yet, a repo in
947
980
        # place
948
981
        target.open_repository()
949
982
 
963
996
            shared_repo = self.make_repository('target', shared=True)
964
997
        except errors.IncompatibleFormat:
965
998
            return
966
 
        target = self.sproutOrSkip(dir, self.get_url('target/child'))
 
999
        target = dir.sprout(self.get_url('target/child'))
967
1000
        self.assertNotEqual(dir.transport.base, target.transport.base)
968
1001
        # we want target to have a branch that is in-place.
969
1002
        self.assertEqual(target, target.open_branch().bzrdir)
970
1003
        # and we want no repository as the target is shared
971
 
        self.assertRaises(errors.NoRepositoryPresent, 
 
1004
        self.assertRaises(errors.NoRepositoryPresent,
972
1005
                          target.open_repository)
973
1006
        # and we want revision '1' in the shared repo
974
1007
        self.assertTrue(shared_repo.has_revision('1'))
989
1022
            shared_repo = self.make_repository('target', shared=True)
990
1023
        except errors.IncompatibleFormat:
991
1024
            return
992
 
        target = self.sproutOrSkip(dir, self.get_url('target/child'),
993
 
                                   force_new_repo=True)
 
1025
        target = dir.sprout(self.get_url('target/child'), force_new_repo=True)
994
1026
        self.assertNotEqual(dir.transport.base, target.transport.base)
995
1027
        # we want target to have a branch that is in-place.
996
1028
        self.assertEqual(target, target.open_branch().bzrdir)
1003
1035
        # test for revision limiting, [smoke test, not corner case checks].
1004
1036
        # make a repository with some revisions,
1005
1037
        # and sprout it with a revision limit.
1006
 
        # 
 
1038
        #
1007
1039
        tree = self.make_branch_and_tree('commit_tree')
1008
1040
        self.build_tree(['commit_tree/foo'])
1009
1041
        tree.add('foo')
1013
1045
        tree.branch.repository.copy_content_into(source.repository)
1014
1046
        tree.bzrdir.open_branch().copy_content_into(source)
1015
1047
        dir = source.bzrdir
1016
 
        target = self.sproutOrSkip(dir, self.get_url('target'), revision_id='1')
 
1048
        target = dir.sprout(self.get_url('target'), revision_id='1')
1017
1049
        self.assertEqual('1', target.open_branch().last_revision())
1018
 
        
 
1050
 
1019
1051
    def test_sprout_bzrdir_tree_branch_repo(self):
1020
1052
        tree = self.make_branch_and_tree('source')
1021
1053
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
1054
1086
        tree = self.createWorkingTreeOrSkip(dir)
1055
1087
        self.build_tree(['source/subdir/'])
1056
1088
        tree.add('subdir')
1057
 
        target = self.sproutOrSkip(dir, self.get_url('target'))
 
1089
        target = dir.sprout(self.get_url('target'))
1058
1090
        self.assertNotEqual(dir.transport.base, target.transport.base)
1059
1091
        # we want target to have a branch that is in-place.
1060
1092
        self.assertEqual(target, target.open_branch().bzrdir)
1061
 
        # and as we dont support repositories being detached yet, a repo in 
 
1093
        # and as we dont support repositories being detached yet, a repo in
1062
1094
        # place
1063
1095
        target.open_repository()
1064
1096
        result_tree = target.open_workingtree()
1087
1119
        self.assertNotEqual(dir.transport.base, target.transport.base)
1088
1120
        # we want target to have a branch that is in-place.
1089
1121
        self.assertEqual(target, target.open_branch().bzrdir)
1090
 
        # and as we dont support repositories being detached yet, a repo in 
 
1122
        # and as we dont support repositories being detached yet, a repo in
1091
1123
        # place
1092
1124
        target.open_repository()
1093
1125
        # we trust that the working tree sprouting works via the other tests.
1120
1152
                                   accelerator_tree=tree)
1121
1153
        self.assertEqual(['2'], target.open_workingtree().get_parent_ids())
1122
1154
 
 
1155
    def test_sprout_branch_no_tree(self):
 
1156
        tree = self.make_branch_and_tree('source')
 
1157
        self.build_tree(['source/foo'])
 
1158
        tree.add('foo')
 
1159
        tree.commit('revision 1', rev_id='1')
 
1160
        tree.commit('revision 2', rev_id='2', allow_pointless=True)
 
1161
        dir = tree.bzrdir
 
1162
        if isinstance(dir, (bzrdir.BzrDirPreSplitOut,)):
 
1163
            self.assertRaises(errors.MustHaveWorkingTree, dir.sprout,
 
1164
                              self.get_url('target'),
 
1165
                              create_tree_if_local=False)
 
1166
            return
 
1167
        target = dir.sprout(self.get_url('target'), create_tree_if_local=False)
 
1168
        self.failIfExists('target/foo')
 
1169
        self.assertEqual(tree.branch.last_revision(),
 
1170
                         target.open_branch().last_revision())
 
1171
 
1123
1172
    def test_format_initialize_find_open(self):
1124
1173
        # loopback test to check the current format initializes to itself.
1125
1174
        if not self.bzrdir_format.is_supported():
1127
1176
            # because the default open will not open them and
1128
1177
            # they may not be initializable.
1129
1178
            return
 
1179
        # for remote formats, there must be no prior assumption about the
 
1180
        # network name to use - it's possible that this may somehow have got
 
1181
        # in through an unisolated test though - see
 
1182
        # <https://bugs.edge.launchpad.net/bzr/+bug/504102>
 
1183
        self.assertEquals(getattr(self.bzrdir_format,
 
1184
            '_network_name', None),
 
1185
            None)
1130
1186
        # supported formats must be able to init and open
1131
1187
        t = get_transport(self.get_url())
1132
1188
        readonly_t = get_transport(self.get_readonly_url())
1142
1198
                         opened_dir._format)
1143
1199
        self.failUnless(isinstance(opened_dir, bzrdir.BzrDir))
1144
1200
 
 
1201
    def test_format_initialize_on_transport_ex(self):
 
1202
        t = self.get_transport('dir')
 
1203
        self.assertInitializeEx(t)
 
1204
 
 
1205
    def test_format_initialize_on_transport_ex_use_existing_dir_True(self):
 
1206
        t = self.get_transport('dir')
 
1207
        t.ensure_base()
 
1208
        self.assertInitializeEx(t, use_existing_dir=True)
 
1209
 
 
1210
    def test_format_initialize_on_transport_ex_use_existing_dir_False(self):
 
1211
        if not self.bzrdir_format.is_supported():
 
1212
            # Not initializable - not a failure either.
 
1213
            return
 
1214
        t = self.get_transport('dir')
 
1215
        t.ensure_base()
 
1216
        self.assertRaises(errors.FileExists,
 
1217
            self.bzrdir_format.initialize_on_transport_ex, t,
 
1218
            use_existing_dir=False)
 
1219
 
 
1220
    def test_format_initialize_on_transport_ex_create_prefix_True(self):
 
1221
        t = self.get_transport('missing/dir')
 
1222
        self.assertInitializeEx(t, create_prefix=True)
 
1223
 
 
1224
    def test_format_initialize_on_transport_ex_create_prefix_False(self):
 
1225
        if not self.bzrdir_format.is_supported():
 
1226
            # Not initializable - not a failure either.
 
1227
            return
 
1228
        t = self.get_transport('missing/dir')
 
1229
        self.assertRaises(errors.NoSuchFile, self.assertInitializeEx, t,
 
1230
            create_prefix=False)
 
1231
 
 
1232
    def test_format_initialize_on_transport_ex_force_new_repo_True(self):
 
1233
        t = self.get_transport('repo')
 
1234
        repo_fmt = bzrdir.format_registry.make_bzrdir('1.9')
 
1235
        repo_name = repo_fmt.repository_format.network_name()
 
1236
        repo = repo_fmt.initialize_on_transport_ex(t,
 
1237
            repo_format_name=repo_name, shared_repo=True)[0]
 
1238
        made_repo, control = self.assertInitializeEx(t.clone('branch'),
 
1239
            force_new_repo=True, repo_format_name=repo_name)
 
1240
        if control is None:
 
1241
            # uninitialisable format
 
1242
            return
 
1243
        self.assertNotEqual(repo.bzrdir.root_transport.base,
 
1244
            made_repo.bzrdir.root_transport.base)
 
1245
 
 
1246
    def test_format_initialize_on_transport_ex_force_new_repo_False(self):
 
1247
        t = self.get_transport('repo')
 
1248
        repo_fmt = bzrdir.format_registry.make_bzrdir('1.9')
 
1249
        repo_name = repo_fmt.repository_format.network_name()
 
1250
        repo = repo_fmt.initialize_on_transport_ex(t,
 
1251
            repo_format_name=repo_name, shared_repo=True)[0]
 
1252
        made_repo, control = self.assertInitializeEx(t.clone('branch'),
 
1253
            force_new_repo=False, repo_format_name=repo_name)
 
1254
        if control is None:
 
1255
            # uninitialisable format
 
1256
            return
 
1257
        if not isinstance(control._format, (bzrdir.BzrDirFormat5,
 
1258
            bzrdir.BzrDirFormat6,)):
 
1259
            self.assertEqual(repo.bzrdir.root_transport.base,
 
1260
                made_repo.bzrdir.root_transport.base)
 
1261
 
 
1262
    def test_format_initialize_on_transport_ex_stacked_on(self):
 
1263
        # trunk is a stackable format.  Note that its in the same server area
 
1264
        # which is what launchpad does, but not sufficient to exercise the
 
1265
        # general case.
 
1266
        trunk = self.make_branch('trunk', format='1.9')
 
1267
        t = self.get_transport('stacked')
 
1268
        old_fmt = bzrdir.format_registry.make_bzrdir('pack-0.92')
 
1269
        repo_name = old_fmt.repository_format.network_name()
 
1270
        # Should end up with a 1.9 format (stackable)
 
1271
        repo, control = self.assertInitializeEx(t, need_meta=True,
 
1272
            repo_format_name=repo_name, stacked_on='../trunk', stack_on_pwd=t.base)
 
1273
        if control is None:
 
1274
            # uninitialisable format
 
1275
            return
 
1276
        self.assertLength(1, repo._fallback_repositories)
 
1277
 
 
1278
    def test_format_initialize_on_transport_ex_default_stack_on(self):
 
1279
        # When initialize_on_transport_ex uses a stacked-on branch because of
 
1280
        # a stacking policy on the target, the location of the fallback
 
1281
        # repository is the same as the external location of the stacked-on
 
1282
        # branch.
 
1283
        balloon = self.make_bzrdir('balloon')
 
1284
        if isinstance(balloon._format, bzrdir.BzrDirMetaFormat1):
 
1285
            stack_on = self.make_branch('stack-on', format='1.9')
 
1286
        else:
 
1287
            stack_on = self.make_branch('stack-on')
 
1288
        config = self.make_bzrdir('.').get_config()
 
1289
        try:
 
1290
            config.set_default_stack_on('stack-on')
 
1291
        except errors.BzrError:
 
1292
            raise TestNotApplicable('Only relevant for stackable formats.')
 
1293
        # Initialize a bzrdir subject to the policy.
 
1294
        t = self.get_transport('stacked')
 
1295
        repo_fmt = bzrdir.format_registry.make_bzrdir('1.9')
 
1296
        repo_name = repo_fmt.repository_format.network_name()
 
1297
        repo, control = self.assertInitializeEx(
 
1298
            t, need_meta=True, repo_format_name=repo_name, stacked_on=None)
 
1299
        # self.addCleanup(repo.unlock)
 
1300
        if control is None:
 
1301
            # uninitialisable format
 
1302
            return
 
1303
        # There's one fallback repo, with a public location.
 
1304
        self.assertLength(1, repo._fallback_repositories)
 
1305
        fallback_repo = repo._fallback_repositories[0]
 
1306
        self.assertEqual(
 
1307
            stack_on.base, fallback_repo.bzrdir.root_transport.base)
 
1308
        # The bzrdir creates a branch in stacking-capable format.
 
1309
        new_branch = control.create_branch()
 
1310
        self.assertTrue(new_branch._format.supports_stacking())
 
1311
 
 
1312
    def test_format_initialize_on_transport_ex_repo_fmt_name_None(self):
 
1313
        t = self.get_transport('dir')
 
1314
        repo, control = self.assertInitializeEx(t)
 
1315
        self.assertEqual(None, repo)
 
1316
 
 
1317
    def test_format_initialize_on_transport_ex_repo_fmt_name_followed(self):
 
1318
        t = self.get_transport('dir')
 
1319
        # 1.6 is likely to never be default
 
1320
        fmt = bzrdir.format_registry.make_bzrdir('1.6')
 
1321
        repo_name = fmt.repository_format.network_name()
 
1322
        repo, control = self.assertInitializeEx(t, repo_format_name=repo_name)
 
1323
        if control is None:
 
1324
            # uninitialisable format
 
1325
            return
 
1326
        if isinstance(self.bzrdir_format, (bzrdir.BzrDirFormat5,
 
1327
            bzrdir.BzrDirFormat6)):
 
1328
            # must stay with the all-in-one-format.
 
1329
            repo_name = self.bzrdir_format.network_name()
 
1330
        self.assertEqual(repo_name, repo._format.network_name())
 
1331
 
 
1332
    def assertInitializeEx(self, t, need_meta=False, **kwargs):
 
1333
        """Execute initialize_on_transport_ex and check it succeeded correctly.
 
1334
 
 
1335
        This involves checking that the disk objects were created, open with
 
1336
        the same format returned, and had the expected disk format.
 
1337
 
 
1338
        :param t: The transport to initialize on.
 
1339
        :param **kwargs: Additional arguments to pass to
 
1340
            initialize_on_transport_ex.
 
1341
        :return: the resulting repo, control dir tuple.
 
1342
        """
 
1343
        if not self.bzrdir_format.is_supported():
 
1344
            # Not initializable - not a failure either.
 
1345
            return None, None
 
1346
        repo, control, require_stacking, repo_policy = \
 
1347
            self.bzrdir_format.initialize_on_transport_ex(t, **kwargs)
 
1348
        if repo is not None:
 
1349
            # Repositories are open write-locked
 
1350
            self.assertTrue(repo.is_write_locked())
 
1351
            self.addCleanup(repo.unlock)
 
1352
        self.assertIsInstance(control, bzrdir.BzrDir)
 
1353
        opened = bzrdir.BzrDir.open(t.base)
 
1354
        expected_format = self.bzrdir_format
 
1355
        if isinstance(expected_format, bzrdir.RemoteBzrDirFormat):
 
1356
            # Current RemoteBzrDirFormat's do not reliably get network_name
 
1357
            # set, so we skip a number of tests for RemoteBzrDirFormat's.
 
1358
            self.assertIsInstance(control, RemoteBzrDir)
 
1359
        else:
 
1360
            if need_meta and isinstance(expected_format, (bzrdir.BzrDirFormat5,
 
1361
                bzrdir.BzrDirFormat6)):
 
1362
                # Pre-metadir formats change when we are making something that
 
1363
                # needs a metaformat, because clone is used for push.
 
1364
                expected_format = bzrdir.BzrDirMetaFormat1()
 
1365
            self.assertEqual(control._format.network_name(),
 
1366
                expected_format.network_name())
 
1367
            self.assertEqual(control._format.network_name(),
 
1368
                opened._format.network_name())
 
1369
        self.assertEqual(control.__class__, opened.__class__)
 
1370
        return repo, control
 
1371
 
 
1372
    def test_format_network_name(self):
 
1373
        # All control formats must have a network name.
 
1374
        dir = self.make_bzrdir('.')
 
1375
        format = dir._format
 
1376
        # We want to test that the network_name matches the actual format on
 
1377
        # disk. For local control dirsthat means that using network_name as a
 
1378
        # key in the registry gives back the same format. For remote obects
 
1379
        # we check that the network_name of the RemoteBzrDirFormat we have
 
1380
        # locally matches the actual format present on disk.
 
1381
        if isinstance(format, bzrdir.RemoteBzrDirFormat):
 
1382
            dir._ensure_real()
 
1383
            real_dir = dir._real_bzrdir
 
1384
            network_name = format.network_name()
 
1385
            self.assertEqual(real_dir._format.network_name(), network_name)
 
1386
        else:
 
1387
            registry = bzrdir.network_format_registry
 
1388
            network_name = format.network_name()
 
1389
            looked_up_format = registry.get(network_name)
 
1390
            self.assertEqual(format.__class__, looked_up_format.__class__)
 
1391
        # The network name must be a byte string.
 
1392
        self.assertIsInstance(network_name, str)
 
1393
 
1145
1394
    def test_open_not_bzrdir(self):
1146
1395
        # test the formats specific behaviour for no-content or similar dirs.
1147
1396
        self.assertRaises(NotBranchError,
1161
1410
        made_branch = made_control.create_branch()
1162
1411
        self.failUnless(isinstance(made_branch, bzrlib.branch.Branch))
1163
1412
        self.assertEqual(made_control, made_branch.bzrdir)
1164
 
        
 
1413
 
1165
1414
    def test_open_branch(self):
1166
1415
        if not self.bzrdir_format.is_supported():
1167
1416
            # unsupported formats are not loopback testable
1192
1441
        self.assertEqual(made_control, made_repo.bzrdir)
1193
1442
 
1194
1443
    def test_create_repository_shared(self):
1195
 
        # a bzrdir can create a shared repository or 
 
1444
        # a bzrdir can create a shared repository or
1196
1445
        # fail appropriately
1197
1446
        if not self.bzrdir_format.is_supported():
1198
1447
            # unsupported formats are not loopback testable
1210
1459
        self.assertTrue(made_repo.is_shared())
1211
1460
 
1212
1461
    def test_create_repository_nonshared(self):
1213
 
        # a bzrdir can create a non-shared repository 
 
1462
        # a bzrdir can create a non-shared repository
1214
1463
        if not self.bzrdir_format.is_supported():
1215
1464
            # unsupported formats are not loopback testable
1216
1465
            # because the default open will not open them and
1220
1469
        made_control = self.bzrdir_format.initialize(t.base)
1221
1470
        made_repo = made_control.create_repository(shared=False)
1222
1471
        self.assertFalse(made_repo.is_shared())
1223
 
        
 
1472
 
1224
1473
    def test_open_repository(self):
1225
1474
        if not self.bzrdir_format.is_supported():
1226
1475
            # unsupported formats are not loopback testable
1249
1498
        made_tree = self.createWorkingTreeOrSkip(made_control)
1250
1499
        self.failUnless(isinstance(made_tree, workingtree.WorkingTree))
1251
1500
        self.assertEqual(made_control, made_tree.bzrdir)
1252
 
        
 
1501
 
1253
1502
    def test_create_workingtree_revision(self):
1254
1503
        # a bzrdir can construct a working tree for itself @ a specific revision.
1255
1504
        t = self.get_transport()
1266
1515
        except errors.NotLocalUrl:
1267
1516
            raise TestSkipped("Can't make working tree on transport %r" % t)
1268
1517
        self.assertEqual(['a'], made_tree.get_parent_ids())
1269
 
        
 
1518
 
1270
1519
    def test_open_workingtree(self):
1271
1520
        if not self.bzrdir_format.is_supported():
1272
1521
            # unsupported formats are not loopback testable
1374
1623
            self.get_url('intermediate/child'))
1375
1624
        try:
1376
1625
            child_repo = innermost_control.open_repository()
1377
 
            # if there is a repository, then the format cannot ever hit this 
 
1626
            # if there is a repository, then the format cannot ever hit this
1378
1627
            # code path.
1379
1628
            return
1380
1629
        except errors.NoRepositoryPresent:
1395
1644
        made_control = self.bzrdir_format.initialize(url)
1396
1645
        try:
1397
1646
            child_repo = made_control.open_repository()
1398
 
            # if there is a repository, then the format cannot ever hit this 
 
1647
            # if there is a repository, then the format cannot ever hit this
1399
1648
            # code path.
1400
1649
            return
1401
1650
        except errors.NoRepositoryPresent:
1403
1652
        found_repo = made_control.find_repository()
1404
1653
        self.assertEqual(repo.bzrdir.root_transport.base,
1405
1654
                         found_repo.bzrdir.root_transport.base)
1406
 
        
 
1655
 
1407
1656
    def test_find_repository_standalone_with_containing_shared_repository(self):
1408
1657
        # find repo inside a standalone repo inside a shared repo finds the standalone repo
1409
1658
        try:
1436
1685
                            containing_repo.bzrdir.root_transport.base)
1437
1686
 
1438
1687
    def test_find_repository_with_nested_dirs_works(self):
1439
 
        # find repo inside a bzrdir inside a bzrdir inside a shared repo 
 
1688
        # find repo inside a bzrdir inside a bzrdir inside a shared repo
1440
1689
        # finds the outer shared repo.
1441
1690
        try:
1442
1691
            repo = self.make_repository('.', shared=True)
1449
1698
        made_control = self.bzrdir_format.initialize(url)
1450
1699
        try:
1451
1700
            child_repo = made_control.open_repository()
1452
 
            # if there is a repository, then the format cannot ever hit this 
 
1701
            # if there is a repository, then the format cannot ever hit this
1453
1702
            # code path.
1454
1703
            return
1455
1704
        except errors.NoRepositoryPresent:
1458
1707
            self.get_url('intermediate/child'))
1459
1708
        try:
1460
1709
            child_repo = innermost_control.open_repository()
1461
 
            # if there is a repository, then the format cannot ever hit this 
 
1710
            # if there is a repository, then the format cannot ever hit this
1462
1711
            # code path.
1463
1712
            return
1464
1713
        except errors.NoRepositoryPresent:
1466
1715
        found_repo = innermost_control.find_repository()
1467
1716
        self.assertEqual(repo.bzrdir.root_transport.base,
1468
1717
                         found_repo.bzrdir.root_transport.base)
1469
 
        
 
1718
 
1470
1719
    def test_can_and_needs_format_conversion(self):
1471
1720
        # check that we can ask an instance if its upgradable
1472
1721
        dir = self.make_bzrdir('.')
1473
1722
        if dir.can_convert_format():
1474
 
            # if its default updatable there must be an updater 
 
1723
            # if its default updatable there must be an updater
1475
1724
            # (we force the latest known format as downgrades may not be
1476
1725
            # available
1477
1726
            self.assertTrue(isinstance(dir._format.get_converter(
1489
1738
        new_path = urlutils.local_path_from_url(new_url)
1490
1739
        self.failUnlessExists(old_path)
1491
1740
        self.failUnlessExists(new_path)
1492
 
        for (((dir_relpath1, _), entries1), 
 
1741
        for (((dir_relpath1, _), entries1),
1493
1742
             ((dir_relpath2, _), entries2)) in izip(
1494
 
                osutils.walkdirs(old_path), 
 
1743
                osutils.walkdirs(old_path),
1495
1744
                osutils.walkdirs(new_path)):
1496
1745
            self.assertEquals(dir_relpath1, dir_relpath2)
1497
1746
            for f1, f2 in zip(entries1, entries2):
1508
1757
        dir.create_branch()
1509
1758
        self.createWorkingTreeOrSkip(dir)
1510
1759
        if dir.can_convert_format():
1511
 
            # if its default updatable there must be an updater 
 
1760
            # if its default updatable there must be an updater
1512
1761
            # (we force the latest known format as downgrades may not be
1513
1762
            # available
1514
1763
            pb = ui.ui_factory.nested_progress_bar()
1517
1766
            finally:
1518
1767
                pb.finished()
1519
1768
            # and it should pass 'check' now.
1520
 
            check_branch(bzrdir.BzrDir.open(self.get_url('.')).open_branch(),
1521
 
                         False)
 
1769
            check.check_dwim(self.get_url('.'), False, True, True)
1522
1770
 
1523
1771
    def test_format_description(self):
1524
1772
        dir = self.make_bzrdir('.')
1544
1792
            transport=transport)
1545
1793
        self.failUnless(transport.has('.bzr'))
1546
1794
        self.assertRaises((errors.FileExists, errors.DirectoryNotEmpty),
1547
 
            bd.retire_bzrdir, limit=0) 
 
1795
            bd.retire_bzrdir, limit=0)
1548
1796
 
1549
1797
 
1550
1798
class TestBreakLock(TestCaseWithBzrDir):
1556
1804
        # ours
1557
1805
        self.old_factory = bzrlib.ui.ui_factory
1558
1806
        self.addCleanup(self.restoreFactory)
1559
 
        bzrlib.ui.ui_factory = bzrlib.ui.SilentUIFactory()
1560
1807
 
1561
1808
    def restoreFactory(self):
1562
1809
        bzrlib.ui.ui_factory = self.old_factory
1582
1829
            return
1583
1830
        # only one yes needed here: it should only be unlocking
1584
1831
        # the repo
1585
 
        bzrlib.ui.ui_factory.stdin = StringIO("y\n")
 
1832
        bzrlib.ui.ui_factory = CannedInputUIFactory([True])
1586
1833
        try:
1587
1834
            repo.bzrdir.break_lock()
1588
1835
        except NotImplementedError:
1613
1860
            # two yes's : branch and repository. If the repo in this
1614
1861
            # dir is inappropriately accessed, 3 will be needed, and
1615
1862
            # we'll see that because the stream will be fully consumed
1616
 
            bzrlib.ui.ui_factory.stdin = StringIO("y\ny\ny\n")
 
1863
            bzrlib.ui.ui_factory = CannedInputUIFactory([True, True, True])
1617
1864
            # determine if the repository will have been locked;
1618
1865
            this_repo_locked = \
1619
1866
                thisdir.open_repository().get_physical_lock_status()
1620
1867
            master.bzrdir.break_lock()
1621
1868
            if this_repo_locked:
1622
1869
                # only two ys should have been read
1623
 
                self.assertEqual("y\n", bzrlib.ui.ui_factory.stdin.read())
 
1870
                self.assertEqual([True],
 
1871
                    bzrlib.ui.ui_factory.responses)
1624
1872
            else:
1625
1873
                # only one y should have been read
1626
 
                self.assertEqual("y\ny\n", bzrlib.ui.ui_factory.stdin.read())
 
1874
                self.assertEqual([True, True],
 
1875
                    bzrlib.ui.ui_factory.responses)
1627
1876
            # we should be able to lock a newly opened branch now
1628
1877
            branch = master.bzrdir.open_branch()
1629
1878
            branch.lock_write()
1639
1888
        self.assertRaises(errors.LockBroken, master.unlock)
1640
1889
 
1641
1890
    def test_break_lock_tree(self):
1642
 
        # break lock with a tree should unlock the tree but not try the 
1643
 
        # branch explicitly. However this is very hard to test for as we 
1644
 
        # dont have a tree reference class, nor is one needed; 
 
1891
        # break lock with a tree should unlock the tree but not try the
 
1892
        # branch explicitly. However this is very hard to test for as we
 
1893
        # dont have a tree reference class, nor is one needed;
1645
1894
        # the worst case if this code unlocks twice is an extra question
1646
1895
        # being asked.
1647
1896
        tree = self.make_branch_and_tree('.')
1648
1897
        tree.lock_write()
1649
1898
        # three yes's : tree, branch and repository.
1650
 
        bzrlib.ui.ui_factory.stdin = StringIO("y\ny\ny\ny\n")
 
1899
        bzrlib.ui.ui_factory = CannedInputUIFactory([True, True, True])
1651
1900
        try:
1652
1901
            tree.bzrdir.break_lock()
1653
1902
        except (NotImplementedError, errors.LockActive):
1657
1906
            # object.
1658
1907
            tree.unlock()
1659
1908
            return
1660
 
        self.assertEqual("y\n", bzrlib.ui.ui_factory.stdin.read())
 
1909
        self.assertEqual([True],
 
1910
                bzrlib.ui.ui_factory.responses)
1661
1911
        lock_tree = tree.bzrdir.open_workingtree()
1662
1912
        lock_tree.lock_write()
1663
1913
        lock_tree.unlock()
1669
1919
    def test_get_config(self):
1670
1920
        my_dir = self.make_bzrdir('.')
1671
1921
        config = my_dir.get_config()
1672
 
        if config is None:
1673
 
            self.assertFalse(
1674
 
                isinstance(my_dir, (bzrdir.BzrDirMeta1, RemoteBzrDir)),
1675
 
                "%r should support configs" % my_dir)
1676
 
            raise TestNotApplicable(
1677
 
                'This BzrDir format does not support configs.')
1678
 
        config.set_default_stack_on('http://example.com')
 
1922
        try:
 
1923
            config.set_default_stack_on('http://example.com')
 
1924
        except errors.BzrError, e:
 
1925
            if 'Cannot set config' in str(e):
 
1926
                self.assertFalse(
 
1927
                    isinstance(my_dir, (bzrdir.BzrDirMeta1, RemoteBzrDir)),
 
1928
                    "%r should support configs" % my_dir)
 
1929
                raise TestNotApplicable(
 
1930
                    'This BzrDir format does not support configs.')
 
1931
            else:
 
1932
                raise
1679
1933
        self.assertEqual('http://example.com', config.get_default_stack_on())
1680
1934
        my_dir2 = bzrdir.BzrDir.open(self.get_url('.'))
1681
1935
        config2 = my_dir2.get_config()
1685
1939
class ChrootedBzrDirTests(ChrootedTestCase):
1686
1940
 
1687
1941
    def test_find_repository_no_repository(self):
1688
 
        # loopback test to check the current format fails to find a 
 
1942
        # loopback test to check the current format fails to find a
1689
1943
        # share repository correctly.
1690
1944
        if not self.bzrdir_format.is_supported():
1691
1945
            # unsupported formats are not loopback testable
1700
1954
        made_control = self.bzrdir_format.initialize(self.get_url('subdir'))
1701
1955
        try:
1702
1956
            repo = made_control.open_repository()
1703
 
            # if there is a repository, then the format cannot ever hit this 
 
1957
            # if there is a repository, then the format cannot ever hit this
1704
1958
            # code path.
1705
1959
            return
1706
1960
        except errors.NoRepositoryPresent: