Rev 3701: Merge Andrew's wrong repo format from Remote patch in http://bzr.arbash-meinel.com/branches/bzr/1.7-dev/1.7rc2

John Arbash Meinel john at arbash-meinel.com
Tue Sep 16 22:36:20 BST 2008


At http://bzr.arbash-meinel.com/branches/bzr/1.7-dev/1.7rc2

------------------------------------------------------------
revno: 3701
revision-id: john at arbash-meinel.com-20080916213541-u1pdcwlt1pjlcmbz
parent: john at arbash-meinel.com-20080911211222-s2strfs3qt1iih7i
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 1.7rc2
timestamp: Tue 2008-09-16 16:35:41 -0500
message:
  Merge Andrew's wrong repo format from Remote patch
-------------- next part --------------
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py	2008-09-02 22:08:56 +0000
+++ b/bzrlib/bzrdir.py	2008-09-16 21:35:41 +0000
@@ -1007,8 +1007,10 @@
             # the fix recommended in bug # 103195 - to delegate this choice the
             # repository itself.
             repo_format = source_repository._format
-            if not isinstance(repo_format, remote.RemoteRepositoryFormat):
-                result_format.repository_format = repo_format
+            if isinstance(repo_format, remote.RemoteRepositoryFormat):
+                source_repository._ensure_real()
+                repo_format = source_repository._real_repository._format
+            result_format.repository_format = repo_format
         try:
             # TODO: Couldn't we just probe for the format in these cases,
             # rather than opening the whole tree?  It would be a little

=== modified file 'bzrlib/tests/repository_implementations/__init__.py'
--- a/bzrlib/tests/repository_implementations/__init__.py	2008-07-17 02:37:07 +0000
+++ b/bzrlib/tests/repository_implementations/__init__.py	2008-09-16 21:35:41 +0000
@@ -107,17 +107,18 @@
 
 class TestCaseWithRepository(TestCaseWithBzrDir):
 
-    def make_repository(self, relpath, format=None):
+    def make_repository(self, relpath, shared=False, format=None):
         if format is None:
             # Create a repository of the type we are trying to test.
             made_control = self.make_bzrdir(relpath)
-            repo = self.repository_format.initialize(made_control)
+            repo = self.repository_format.initialize(made_control,
+                    shared=shared)
             if getattr(self, "repository_to_test_repository", None):
                 repo = self.repository_to_test_repository(repo)
             return repo
         else:
             return super(TestCaseWithRepository, self).make_repository(
-                relpath, format=format)
+                relpath, shared=shared, format=format)
 
 
 class BrokenRepoScenario(object):

=== modified file 'bzrlib/tests/repository_implementations/test_repository.py'
--- a/bzrlib/tests/repository_implementations/test_repository.py	2008-09-01 15:52:24 +0000
+++ b/bzrlib/tests/repository_implementations/test_repository.py	2008-09-16 21:35:41 +0000
@@ -693,10 +693,10 @@
         self.assertEqual(signature, repo2.get_signature_text('A'))
 
     # XXX: this helper duplicated from tests.test_repository
-    def make_remote_repository(self, path):
+    def make_remote_repository(self, path, shared=False):
         """Make a RemoteRepository object backed by a real repository that will
         be created at the given path."""
-        repo = self.make_repository(path)
+        repo = self.make_repository(path, shared=shared)
         smart_server = server.SmartTCPServer_for_testing()
         smart_server.setUp(self.get_server())
         remote_transport = get_transport(smart_server.get_url()).clone(path)
@@ -741,6 +741,37 @@
             self.get_vfs_only_url('remote')).open_repository()
         self.assertEqual(remote_backing_repo._format, local_repo._format)
 
+    def test_sprout_branch_from_hpss_preserves_shared_repo_format(self):
+        """branch.sprout from a smart server preserves the repository format of
+        a branch from a shared repository.
+        """
+        weave_formats = [RepositoryFormat5(), RepositoryFormat6(),
+                         RepositoryFormat7()]
+        if self.repository_format in weave_formats:
+            raise TestNotApplicable(
+                "Cannot fetch weaves over smart protocol.")
+        # Make a shared repo
+        remote_repo = self.make_remote_repository('remote', shared=True)
+        remote_backing_repo = bzrdir.BzrDir.open(
+            self.get_vfs_only_url('remote')).open_repository()
+        # Make a branch in that repo in an old format that isn't the default
+        # branch format for the repo.
+        from bzrlib.branch import BzrBranchFormat5
+        format = remote_backing_repo.bzrdir.cloning_metadir()
+        format._branch_format = BzrBranchFormat5()
+        remote_transport = remote_repo.bzrdir.root_transport.clone('branch')
+        remote_backing_repo.bzrdir.create_branch_convenience(
+            remote_transport.base, force_new_repo=False, format=format)
+        remote_branch = bzrdir.BzrDir.open_from_transport(
+            remote_transport).open_branch()
+        try:
+            local_bzrdir = remote_branch.bzrdir.sprout('local')
+        except errors.TransportNotPossible:
+            raise TestNotApplicable(
+                "Cannot lock_read old formats like AllInOne over HPSS.")
+        local_repo = local_bzrdir.open_repository()
+        self.assertEqual(remote_backing_repo._format, local_repo._format)
+
     def test__make_parents_provider(self):
         """Repositories must have a _make_parents_provider method that returns
         an object with a get_parent_map method.



More information about the bazaar-commits mailing list