~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Matt Nordhoff
  • Date: 2009-04-04 02:50:01 UTC
  • mfrom: (4253 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4256.
  • Revision ID: mnordhoff@mattnordhoff.com-20090404025001-z1403k0tatmc8l91
Merge bzr.dev, fixing 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
 
75
75
        """Assert that the content of source and target are identical.
76
76
 
77
77
        paths in ignore list will be completely ignored.
78
 
        
 
78
 
79
79
        We ignore paths that represent data which is allowed to change during
80
80
        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 
 
81
        which have timestamps in them, and as we have read the inventory from
82
82
        the source knit, the already-read data is recompressed rather than
83
83
        reading it again, which leads to changed timestamps. This is ok though,
84
84
        because the inventory.kndx file is not ignored, and the integrity of
126
126
                for rev_id in left_repo.all_revision_ids():
127
127
                    self.assertEqual(left_repo.get_revision(rev_id),
128
128
                        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)
 
129
                # Assert the revision trees (and thus the inventories) are equal
 
130
                sort_key = lambda rev_tree: rev_tree.get_revision_id()
 
131
                rev_trees_a = sorted(
 
132
                    left_repo.revision_trees(all_revs), key=sort_key)
 
133
                rev_trees_b = sorted(
 
134
                    right_repo.revision_trees(all_revs), key=sort_key)
 
135
                for tree_a, tree_b in zip(rev_trees_a, rev_trees_b):
 
136
                    self.assertEqual([], list(tree_a.iter_changes(tree_b)))
144
137
                # texts
145
138
                text_index = left_repo._generate_text_key_index()
146
139
                self.assertEqual(text_index,
169
162
 
170
163
    def skipIfNoWorkingTree(self, a_bzrdir):
171
164
        """Raises TestSkipped if a_bzrdir doesn't have a working tree.
172
 
        
 
165
 
173
166
        If the bzrdir does have a workingtree, this is a no-op.
174
167
        """
175
168
        try:
178
171
            raise TestSkipped("bzrdir on transport %r has no working tree"
179
172
                              % a_bzrdir.transport)
180
173
 
 
174
    def openWorkingTreeIfLocal(self, a_bzrdir):
 
175
        """If a_bzrdir is on a local transport, call open_workingtree() on it.
 
176
        """
 
177
        if not isinstance(a_bzrdir.root_transport, LocalTransport):
 
178
            # it's not local, but that's ok
 
179
            return
 
180
        a_bzrdir.open_workingtree()
 
181
 
181
182
    def createWorkingTreeOrSkip(self, a_bzrdir):
182
183
        """Create a working tree on a_bzrdir, or raise TestSkipped.
183
 
        
 
184
 
184
185
        A simple wrapper for create_workingtree that translates NotLocalUrl into
185
186
        TestSkipped.  Returns the newly created working tree.
186
187
        """
194
195
                     force_new_repo=False, accelerator_tree=None,
195
196
                     create_tree_if_local=True):
196
197
        """Sprout from_bzrdir into to_url, or raise TestSkipped.
197
 
        
 
198
 
198
199
        A simple wrapper for from_bzrdir.sprout that translates NotLocalUrl into
199
200
        TestSkipped.  Returns the newly sprouted bzrdir.
200
201
        """
286
287
        self.assertNotEqual(dir.transport.base, target.transport.base)
287
288
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport,
288
289
                                    ['./.bzr/merge-hashes'])
289
 
    
 
290
 
290
291
    def test_clone_bzrdir_empty_force_new_ignored(self):
291
292
        # the force_new_repo parameter should have no effect on an empty
292
293
        # bzrdir's clone logic
295
296
        self.assertNotEqual(dir.transport.base, target.transport.base)
296
297
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport,
297
298
                                    ['./.bzr/merge-hashes'])
298
 
    
 
299
 
299
300
    def test_clone_bzrdir_repository(self):
300
301
        tree = self.make_branch_and_tree('commit_tree')
301
302
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
389
390
        self.assertTrue(branch.repository.has_revision('1'))
390
391
        self.assertFalse(branch.repository.make_working_trees())
391
392
        self.assertTrue(branch.repository.is_shared())
392
 
        
 
393
 
393
394
    def test_clone_bzrdir_repository_under_shared_force_new_repo(self):
394
395
        tree = self.make_branch_and_tree('commit_tree')
395
396
        self.build_tree(['commit_tree/foo'])
414
415
        # test for revision limiting, [smoke test, not corner case checks].
415
416
        # make a repository with some revisions,
416
417
        # and clone it with a revision limit.
417
 
        # 
 
418
        #
418
419
        tree = self.make_branch_and_tree('commit_tree')
419
420
        self.build_tree(['commit_tree/foo'])
420
421
        tree.add('foo')
510
511
        # test for revision limiting, [smoke test, not corner case checks].
511
512
        # make a branch with some revisions,
512
513
        # and clone it with a revision limit.
513
 
        # 
 
514
        #
514
515
        tree = self.make_branch_and_tree('commit_tree')
515
516
        self.build_tree(['commit_tree/foo'])
516
517
        tree.add('foo')
522
523
        dir = source.bzrdir
523
524
        target = dir.clone(self.get_url('target'), revision_id='1')
524
525
        self.assertEqual('1', target.open_branch().last_revision())
525
 
        
 
526
 
526
527
    def test_clone_bzrdir_tree_branch_repo(self):
527
528
        tree = self.make_branch_and_tree('source')
528
529
        self.build_tree(['source/foo'])
553
554
        # Ensure no format data is cached
554
555
        a_dir = bzrlib.branch.Branch.open_from_transport(
555
556
            self.get_transport('source')).bzrdir
556
 
        target_transport = a_dir.root_transport.clone('..').clone('target')
 
557
        target_transport = self.get_transport('target')
557
558
        target_bzrdir = a_dir.clone_on_transport(target_transport)
558
559
        target_repo = target_bzrdir.open_repository()
559
560
        source_branch = bzrlib.branch.Branch.open(
595
596
            target.open_repository())
596
597
 
597
598
    def test_clone_bzrdir_tree_branch_reference(self):
598
 
        # a tree with a branch reference (aka a checkout) 
 
599
        # a tree with a branch reference (aka a checkout)
599
600
        # should stay a checkout on clone.
600
601
        referenced_branch = self.make_branch('referencced')
601
602
        dir = self.make_bzrdir('source')
655
656
 
656
657
    def test_clone_respects_stacked(self):
657
658
        branch = self.make_branch('parent')
658
 
        child_transport = branch.bzrdir.root_transport.clone('../child')
 
659
        child_transport = self.get_transport('child')
659
660
        child = branch.bzrdir.clone_on_transport(child_transport,
660
661
                                                 stacked_on=branch.base)
661
662
        self.assertEqual(child.open_branch().get_stacked_on_url(), branch.base)
688
689
 
689
690
    def test_sprout_bzrdir_empty(self):
690
691
        dir = self.make_bzrdir('source')
691
 
        target = self.sproutOrSkip(dir, self.get_url('target'))
 
692
        target = dir.sprout(self.get_url('target'))
692
693
        self.assertNotEqual(dir.transport.base, target.transport.base)
693
694
        # creates a new repository branch and tree
694
695
        target.open_repository()
695
696
        target.open_branch()
696
 
        target.open_workingtree()
 
697
        self.openWorkingTreeIfLocal(target)
697
698
 
698
699
    def test_sprout_bzrdir_empty_under_shared_repo(self):
699
700
        # sprouting an empty dir into a repo uses the repo
702
703
            self.make_repository('target', shared=True)
703
704
        except errors.IncompatibleFormat:
704
705
            return
705
 
        target = self.sproutOrSkip(dir, self.get_url('target/child'))
 
706
        target = dir.sprout(self.get_url('target/child'))
706
707
        self.assertRaises(errors.NoRepositoryPresent, target.open_repository)
707
708
        target.open_branch()
708
709
        try:
720
721
            self.make_repository('target', shared=True)
721
722
        except errors.IncompatibleFormat:
722
723
            return
723
 
        target = self.sproutOrSkip(dir, self.get_url('target/child'),
724
 
                                   force_new_repo=True)
 
724
        target = dir.sprout(self.get_url('target/child'), force_new_repo=True)
725
725
        target.open_repository()
726
726
        target.open_branch()
727
 
        target.open_workingtree()
728
 
    
 
727
        self.openWorkingTreeIfLocal(target)
 
728
 
729
729
    def test_sprout_bzrdir_repository(self):
730
730
        tree = self.make_branch_and_tree('commit_tree')
731
731
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
741
741
                dir.open_branch().last_revision())))
742
742
        except errors.NotBranchError:
743
743
            pass
744
 
        target = self.sproutOrSkip(dir, self.get_url('target'))
 
744
        target = dir.sprout(self.get_url('target'))
745
745
        self.assertNotEqual(dir.transport.base, target.transport.base)
746
746
        # testing inventory isn't reasonable for repositories
747
747
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport,
756
756
            # If we happen to have a tree, we'll guarantee everything
757
757
            # except for the tree root is the same.
758
758
            inventory_f = file(dir.transport.base+'inventory', 'rb')
759
 
            self.assertContainsRe(inventory_f.read(), 
 
759
            self.assertContainsRe(inventory_f.read(),
760
760
                                  '<inventory file_id="TREE_ROOT[^"]*"'
761
761
                                  ' format="5">\n</inventory>\n')
762
762
            inventory_f.close()
779
779
            shared_repo = self.make_repository('target', shared=True)
780
780
        except errors.IncompatibleFormat:
781
781
            return
782
 
        target = self.sproutOrSkip(dir, self.get_url('target/child'))
 
782
        target = dir.sprout(self.get_url('target/child'))
783
783
        self.assertNotEqual(dir.transport.base, target.transport.base)
784
784
        self.assertTrue(shared_repo.has_revision('1'))
785
785
 
798
798
        tree.branch.repository.copy_content_into(shared_repo)
799
799
        dir = self.make_bzrdir('shared/source')
800
800
        dir.create_branch()
801
 
        target = self.sproutOrSkip(dir, self.get_url('shared/target'))
 
801
        target = dir.sprout(self.get_url('shared/target'))
802
802
        self.assertNotEqual(dir.transport.base, target.transport.base)
803
803
        self.assertNotEqual(dir.transport.base, shared_repo.bzrdir.transport.base)
804
804
        self.assertTrue(shared_repo.has_revision('1'))
822
822
        self.assertTrue(shared_repo.has_revision('1'))
823
823
        dir = self.make_bzrdir('shared/source')
824
824
        dir.create_branch()
825
 
        target = self.sproutOrSkip(dir, self.get_url('target'))
 
825
        target = dir.sprout(self.get_url('target'))
826
826
        self.assertNotEqual(dir.transport.base, target.transport.base)
827
827
        self.assertNotEqual(dir.transport.base, shared_repo.bzrdir.transport.base)
828
828
        branch = target.open_branch()
846
846
            shared_repo = self.make_repository('target', shared=True)
847
847
        except errors.IncompatibleFormat:
848
848
            return
849
 
        target = self.sproutOrSkip(dir, self.get_url('target/child'),
850
 
                                   force_new_repo=True)
 
849
        target = dir.sprout(self.get_url('target/child'), force_new_repo=True)
851
850
        self.assertNotEqual(dir.transport.base, target.transport.base)
852
851
        self.assertFalse(shared_repo.has_revision('1'))
853
852
 
855
854
        # test for revision limiting, [smoke test, not corner case checks].
856
855
        # make a repository with some revisions,
857
856
        # and sprout it with a revision limit.
858
 
        # 
 
857
        #
859
858
        tree = self.make_branch_and_tree('commit_tree')
860
859
        self.build_tree(['commit_tree/foo'])
861
860
        tree.add('foo')
878
877
        tree.branch.repository.copy_content_into(source.repository)
879
878
        tree.bzrdir.open_branch().copy_content_into(source)
880
879
        dir = source.bzrdir
881
 
        target = self.sproutOrSkip(dir, self.get_url('target'))
 
880
        target = dir.sprout(self.get_url('target'))
882
881
        self.assertNotEqual(dir.transport.base, target.transport.base)
 
882
        target_repo = target.open_repository()
 
883
        self.assertRepositoryHasSameItems(source.repository, target_repo)
883
884
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport,
884
885
                                    [
885
886
                                     './.bzr/basis-inventory-cache',
890
891
                                     './.bzr/checkout/stat-cache',
891
892
                                     './.bzr/inventory',
892
893
                                     './.bzr/parent',
893
 
                                     './.bzr/repository/inventory.knit',
 
894
                                     './.bzr/repository',
894
895
                                     './.bzr/stat-cache',
895
896
                                     './foo',
896
897
                                     ])
910
911
            shared_repo = self.make_repository('target', shared=True)
911
912
        except errors.IncompatibleFormat:
912
913
            return
913
 
        target = self.sproutOrSkip(dir, self.get_url('target/child'))
 
914
        target = dir.sprout(self.get_url('target/child'))
914
915
        self.assertTrue(shared_repo.has_revision('1'))
915
916
 
916
917
    def test_sprout_bzrdir_branch_and_repo_shared_force_new_repo(self):
928
929
            shared_repo = self.make_repository('target', shared=True)
929
930
        except errors.IncompatibleFormat:
930
931
            return
931
 
        target = self.sproutOrSkip(dir, self.get_url('target/child'),
932
 
                                   force_new_repo=True)
 
932
        target = dir.sprout(self.get_url('target/child'), force_new_repo=True)
933
933
        self.assertNotEqual(dir.transport.base, target.transport.base)
934
934
        self.assertFalse(shared_repo.has_revision('1'))
935
935
 
936
936
    def test_sprout_bzrdir_branch_reference(self):
937
937
        # sprouting should create a repository if needed and a sprouted branch.
938
 
        referenced_branch = self.make_branch('referencced')
 
938
        referenced_branch = self.make_branch('referenced')
939
939
        dir = self.make_bzrdir('source')
940
940
        try:
941
941
            reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
944
944
            # this is ok too, not all formats have to support references.
945
945
            return
946
946
        self.assertRaises(errors.NoRepositoryPresent, dir.open_repository)
947
 
        target = self.sproutOrSkip(dir, self.get_url('target'))
 
947
        target = dir.sprout(self.get_url('target'))
948
948
        self.assertNotEqual(dir.transport.base, target.transport.base)
949
949
        # we want target to have a branch that is in-place.
950
950
        self.assertEqual(target, target.open_branch().bzrdir)
951
 
        # and as we dont support repositories being detached yet, a repo in 
 
951
        # and as we dont support repositories being detached yet, a repo in
952
952
        # place
953
953
        target.open_repository()
954
954
 
968
968
            shared_repo = self.make_repository('target', shared=True)
969
969
        except errors.IncompatibleFormat:
970
970
            return
971
 
        target = self.sproutOrSkip(dir, self.get_url('target/child'))
 
971
        target = dir.sprout(self.get_url('target/child'))
972
972
        self.assertNotEqual(dir.transport.base, target.transport.base)
973
973
        # we want target to have a branch that is in-place.
974
974
        self.assertEqual(target, target.open_branch().bzrdir)
975
975
        # and we want no repository as the target is shared
976
 
        self.assertRaises(errors.NoRepositoryPresent, 
 
976
        self.assertRaises(errors.NoRepositoryPresent,
977
977
                          target.open_repository)
978
978
        # and we want revision '1' in the shared repo
979
979
        self.assertTrue(shared_repo.has_revision('1'))
994
994
            shared_repo = self.make_repository('target', shared=True)
995
995
        except errors.IncompatibleFormat:
996
996
            return
997
 
        target = self.sproutOrSkip(dir, self.get_url('target/child'),
998
 
                                   force_new_repo=True)
 
997
        target = dir.sprout(self.get_url('target/child'), force_new_repo=True)
999
998
        self.assertNotEqual(dir.transport.base, target.transport.base)
1000
999
        # we want target to have a branch that is in-place.
1001
1000
        self.assertEqual(target, target.open_branch().bzrdir)
1008
1007
        # test for revision limiting, [smoke test, not corner case checks].
1009
1008
        # make a repository with some revisions,
1010
1009
        # and sprout it with a revision limit.
1011
 
        # 
 
1010
        #
1012
1011
        tree = self.make_branch_and_tree('commit_tree')
1013
1012
        self.build_tree(['commit_tree/foo'])
1014
1013
        tree.add('foo')
1018
1017
        tree.branch.repository.copy_content_into(source.repository)
1019
1018
        tree.bzrdir.open_branch().copy_content_into(source)
1020
1019
        dir = source.bzrdir
1021
 
        target = self.sproutOrSkip(dir, self.get_url('target'), revision_id='1')
 
1020
        target = dir.sprout(self.get_url('target'), revision_id='1')
1022
1021
        self.assertEqual('1', target.open_branch().last_revision())
1023
 
        
 
1022
 
1024
1023
    def test_sprout_bzrdir_tree_branch_repo(self):
1025
1024
        tree = self.make_branch_and_tree('source')
1026
1025
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
1059
1058
        tree = self.createWorkingTreeOrSkip(dir)
1060
1059
        self.build_tree(['source/subdir/'])
1061
1060
        tree.add('subdir')
1062
 
        target = self.sproutOrSkip(dir, self.get_url('target'))
 
1061
        target = dir.sprout(self.get_url('target'))
1063
1062
        self.assertNotEqual(dir.transport.base, target.transport.base)
1064
1063
        # we want target to have a branch that is in-place.
1065
1064
        self.assertEqual(target, target.open_branch().bzrdir)
1066
 
        # and as we dont support repositories being detached yet, a repo in 
 
1065
        # and as we dont support repositories being detached yet, a repo in
1067
1066
        # place
1068
1067
        target.open_repository()
1069
1068
        result_tree = target.open_workingtree()
1092
1091
        self.assertNotEqual(dir.transport.base, target.transport.base)
1093
1092
        # we want target to have a branch that is in-place.
1094
1093
        self.assertEqual(target, target.open_branch().bzrdir)
1095
 
        # and as we dont support repositories being detached yet, a repo in 
 
1094
        # and as we dont support repositories being detached yet, a repo in
1096
1095
        # place
1097
1096
        target.open_repository()
1098
1097
        # we trust that the working tree sprouting works via the other tests.
1133
1132
        tree.commit('revision 2', rev_id='2', allow_pointless=True)
1134
1133
        dir = tree.bzrdir
1135
1134
        if isinstance(dir, (bzrdir.BzrDirPreSplitOut,)):
1136
 
            self.assertRaises(errors.MustHaveWorkingTree, self.sproutOrSkip,
1137
 
                              dir, self.get_url('target'),
 
1135
            self.assertRaises(errors.MustHaveWorkingTree, dir.sprout,
 
1136
                              self.get_url('target'),
1138
1137
                              create_tree_if_local=False)
1139
1138
            return
1140
 
        target = self.sproutOrSkip(dir, self.get_url('target'),
1141
 
                                   create_tree_if_local=False)
 
1139
        target = dir.sprout(self.get_url('target'), create_tree_if_local=False)
1142
1140
        self.failIfExists('target/foo')
1143
1141
        self.assertEqual(tree.branch.last_revision(),
1144
1142
                         target.open_branch().last_revision())
1165
1163
                         opened_dir._format)
1166
1164
        self.failUnless(isinstance(opened_dir, bzrdir.BzrDir))
1167
1165
 
 
1166
    def test_format_network_name(self):
 
1167
        # All control formats must have a network name.
 
1168
        dir = self.make_bzrdir('.')
 
1169
        format = dir._format
 
1170
        # We want to test that the network_name matches the actual format on
 
1171
        # disk. For local control dirsthat means that using network_name as a
 
1172
        # key in the registry gives back the same format. For remote obects
 
1173
        # we check that the network_name of the RemoteBzrDirFormat we have
 
1174
        # locally matches the actual format present on disk.
 
1175
        if isinstance(format, bzrdir.RemoteBzrDirFormat):
 
1176
            dir._ensure_real()
 
1177
            real_dir = dir._real_bzrdir
 
1178
            network_name = format.network_name()
 
1179
            self.assertEqual(real_dir._format.network_name(), network_name)
 
1180
        else:
 
1181
            registry = bzrdir.network_format_registry
 
1182
            network_name = format.network_name()
 
1183
            looked_up_format = registry.get(network_name)
 
1184
            self.assertEqual(format.__class__, looked_up_format.__class__)
 
1185
        # The network name must be a byte string.
 
1186
        self.assertIsInstance(network_name, str)
 
1187
 
1168
1188
    def test_open_not_bzrdir(self):
1169
1189
        # test the formats specific behaviour for no-content or similar dirs.
1170
1190
        self.assertRaises(NotBranchError,
1184
1204
        made_branch = made_control.create_branch()
1185
1205
        self.failUnless(isinstance(made_branch, bzrlib.branch.Branch))
1186
1206
        self.assertEqual(made_control, made_branch.bzrdir)
1187
 
        
 
1207
 
1188
1208
    def test_open_branch(self):
1189
1209
        if not self.bzrdir_format.is_supported():
1190
1210
            # unsupported formats are not loopback testable
1215
1235
        self.assertEqual(made_control, made_repo.bzrdir)
1216
1236
 
1217
1237
    def test_create_repository_shared(self):
1218
 
        # a bzrdir can create a shared repository or 
 
1238
        # a bzrdir can create a shared repository or
1219
1239
        # fail appropriately
1220
1240
        if not self.bzrdir_format.is_supported():
1221
1241
            # unsupported formats are not loopback testable
1233
1253
        self.assertTrue(made_repo.is_shared())
1234
1254
 
1235
1255
    def test_create_repository_nonshared(self):
1236
 
        # a bzrdir can create a non-shared repository 
 
1256
        # a bzrdir can create a non-shared repository
1237
1257
        if not self.bzrdir_format.is_supported():
1238
1258
            # unsupported formats are not loopback testable
1239
1259
            # because the default open will not open them and
1243
1263
        made_control = self.bzrdir_format.initialize(t.base)
1244
1264
        made_repo = made_control.create_repository(shared=False)
1245
1265
        self.assertFalse(made_repo.is_shared())
1246
 
        
 
1266
 
1247
1267
    def test_open_repository(self):
1248
1268
        if not self.bzrdir_format.is_supported():
1249
1269
            # unsupported formats are not loopback testable
1272
1292
        made_tree = self.createWorkingTreeOrSkip(made_control)
1273
1293
        self.failUnless(isinstance(made_tree, workingtree.WorkingTree))
1274
1294
        self.assertEqual(made_control, made_tree.bzrdir)
1275
 
        
 
1295
 
1276
1296
    def test_create_workingtree_revision(self):
1277
1297
        # a bzrdir can construct a working tree for itself @ a specific revision.
1278
1298
        t = self.get_transport()
1289
1309
        except errors.NotLocalUrl:
1290
1310
            raise TestSkipped("Can't make working tree on transport %r" % t)
1291
1311
        self.assertEqual(['a'], made_tree.get_parent_ids())
1292
 
        
 
1312
 
1293
1313
    def test_open_workingtree(self):
1294
1314
        if not self.bzrdir_format.is_supported():
1295
1315
            # unsupported formats are not loopback testable
1397
1417
            self.get_url('intermediate/child'))
1398
1418
        try:
1399
1419
            child_repo = innermost_control.open_repository()
1400
 
            # if there is a repository, then the format cannot ever hit this 
 
1420
            # if there is a repository, then the format cannot ever hit this
1401
1421
            # code path.
1402
1422
            return
1403
1423
        except errors.NoRepositoryPresent:
1418
1438
        made_control = self.bzrdir_format.initialize(url)
1419
1439
        try:
1420
1440
            child_repo = made_control.open_repository()
1421
 
            # if there is a repository, then the format cannot ever hit this 
 
1441
            # if there is a repository, then the format cannot ever hit this
1422
1442
            # code path.
1423
1443
            return
1424
1444
        except errors.NoRepositoryPresent:
1426
1446
        found_repo = made_control.find_repository()
1427
1447
        self.assertEqual(repo.bzrdir.root_transport.base,
1428
1448
                         found_repo.bzrdir.root_transport.base)
1429
 
        
 
1449
 
1430
1450
    def test_find_repository_standalone_with_containing_shared_repository(self):
1431
1451
        # find repo inside a standalone repo inside a shared repo finds the standalone repo
1432
1452
        try:
1459
1479
                            containing_repo.bzrdir.root_transport.base)
1460
1480
 
1461
1481
    def test_find_repository_with_nested_dirs_works(self):
1462
 
        # find repo inside a bzrdir inside a bzrdir inside a shared repo 
 
1482
        # find repo inside a bzrdir inside a bzrdir inside a shared repo
1463
1483
        # finds the outer shared repo.
1464
1484
        try:
1465
1485
            repo = self.make_repository('.', shared=True)
1472
1492
        made_control = self.bzrdir_format.initialize(url)
1473
1493
        try:
1474
1494
            child_repo = made_control.open_repository()
1475
 
            # if there is a repository, then the format cannot ever hit this 
 
1495
            # if there is a repository, then the format cannot ever hit this
1476
1496
            # code path.
1477
1497
            return
1478
1498
        except errors.NoRepositoryPresent:
1481
1501
            self.get_url('intermediate/child'))
1482
1502
        try:
1483
1503
            child_repo = innermost_control.open_repository()
1484
 
            # if there is a repository, then the format cannot ever hit this 
 
1504
            # if there is a repository, then the format cannot ever hit this
1485
1505
            # code path.
1486
1506
            return
1487
1507
        except errors.NoRepositoryPresent:
1489
1509
        found_repo = innermost_control.find_repository()
1490
1510
        self.assertEqual(repo.bzrdir.root_transport.base,
1491
1511
                         found_repo.bzrdir.root_transport.base)
1492
 
        
 
1512
 
1493
1513
    def test_can_and_needs_format_conversion(self):
1494
1514
        # check that we can ask an instance if its upgradable
1495
1515
        dir = self.make_bzrdir('.')
1496
1516
        if dir.can_convert_format():
1497
 
            # if its default updatable there must be an updater 
 
1517
            # if its default updatable there must be an updater
1498
1518
            # (we force the latest known format as downgrades may not be
1499
1519
            # available
1500
1520
            self.assertTrue(isinstance(dir._format.get_converter(
1512
1532
        new_path = urlutils.local_path_from_url(new_url)
1513
1533
        self.failUnlessExists(old_path)
1514
1534
        self.failUnlessExists(new_path)
1515
 
        for (((dir_relpath1, _), entries1), 
 
1535
        for (((dir_relpath1, _), entries1),
1516
1536
             ((dir_relpath2, _), entries2)) in izip(
1517
 
                osutils.walkdirs(old_path), 
 
1537
                osutils.walkdirs(old_path),
1518
1538
                osutils.walkdirs(new_path)):
1519
1539
            self.assertEquals(dir_relpath1, dir_relpath2)
1520
1540
            for f1, f2 in zip(entries1, entries2):
1531
1551
        dir.create_branch()
1532
1552
        self.createWorkingTreeOrSkip(dir)
1533
1553
        if dir.can_convert_format():
1534
 
            # if its default updatable there must be an updater 
 
1554
            # if its default updatable there must be an updater
1535
1555
            # (we force the latest known format as downgrades may not be
1536
1556
            # available
1537
1557
            pb = ui.ui_factory.nested_progress_bar()
1567
1587
            transport=transport)
1568
1588
        self.failUnless(transport.has('.bzr'))
1569
1589
        self.assertRaises((errors.FileExists, errors.DirectoryNotEmpty),
1570
 
            bd.retire_bzrdir, limit=0) 
 
1590
            bd.retire_bzrdir, limit=0)
1571
1591
 
1572
1592
 
1573
1593
class TestBreakLock(TestCaseWithBzrDir):
1662
1682
        self.assertRaises(errors.LockBroken, master.unlock)
1663
1683
 
1664
1684
    def test_break_lock_tree(self):
1665
 
        # break lock with a tree should unlock the tree but not try the 
1666
 
        # branch explicitly. However this is very hard to test for as we 
1667
 
        # dont have a tree reference class, nor is one needed; 
 
1685
        # break lock with a tree should unlock the tree but not try the
 
1686
        # branch explicitly. However this is very hard to test for as we
 
1687
        # dont have a tree reference class, nor is one needed;
1668
1688
        # the worst case if this code unlocks twice is an extra question
1669
1689
        # being asked.
1670
1690
        tree = self.make_branch_and_tree('.')
1708
1728
class ChrootedBzrDirTests(ChrootedTestCase):
1709
1729
 
1710
1730
    def test_find_repository_no_repository(self):
1711
 
        # loopback test to check the current format fails to find a 
 
1731
        # loopback test to check the current format fails to find a
1712
1732
        # share repository correctly.
1713
1733
        if not self.bzrdir_format.is_supported():
1714
1734
            # unsupported formats are not loopback testable
1723
1743
        made_control = self.bzrdir_format.initialize(self.get_url('subdir'))
1724
1744
        try:
1725
1745
            repo = made_control.open_repository()
1726
 
            # if there is a repository, then the format cannot ever hit this 
 
1746
            # if there is a repository, then the format cannot ever hit this
1727
1747
            # code path.
1728
1748
            return
1729
1749
        except errors.NoRepositoryPresent: