Rev 4019: Perform creation of BzrDirMetaFormat1 control directories using an RPC where possible. (Robert Collins) in http://people.ubuntu.com/~robertc/baz2.0/push.roundtrips

Robert Collins robertc at robertcollins.net
Thu Feb 19 02:06:57 GMT 2009


At http://people.ubuntu.com/~robertc/baz2.0/push.roundtrips

------------------------------------------------------------
revno: 4019
revision-id: robertc at robertcollins.net-20090219020654-1l19ged3zo7212jh
parent: robertc at robertcollins.net-20090219014143-wv42sc7z71wbhht0
committer: Robert Collins <robertc at robertcollins.net>
branch nick: push.roundtrips
timestamp: Thu 2009-02-19 13:06:54 +1100
message:
  Perform creation of BzrDirMetaFormat1 control directories using an RPC where possible. (Robert Collins)
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py	2009-02-19 01:41:43 +0000
+++ b/bzrlib/bzrdir.py	2009-02-19 02:06:54 +0000
@@ -1707,7 +1707,29 @@
 
     def initialize_on_transport(self, transport):
         """Initialize a new bzrdir in the base directory of a Transport."""
-        # Since we don't have a .bzr directory, inherit the
+        try:
+            # can we hand off the request to the smart server rather than using
+            # vfs calls?
+            client_medium = transport.get_smart_medium()
+        except errors.NoSmartMedium:
+            return self._initialize_on_transport_vfs(transport)
+        else:
+            # Current RPC's only know how to create bzr metadir1 instances, so
+            # we still delegate to vfs methods if the requested format is not a
+            # metadir1
+            if type(self) != BzrDirMetaFormat1:
+                return self._initialize_on_transport_vfs(transport)
+            remote_format = RemoteBzrDirFormat()
+            self._supply_sub_formats_to(remote_format)
+            return remote_format.initialize_on_transport(transport)
+
+    def _initialize_on_transport_vfs(self, transport):
+        """Initialize a new bzrdir using VFS calls.
+        
+        :param transport: The transport to create the .bzr directory in.
+        :return: A
+        """
+        # Since we are creating a .bzr directory, inherit the
         # mode from the root directory
         temp_control = lockable_files.LockableFiles(transport,
                             '', lockable_files.TransportLock)
@@ -1737,12 +1759,7 @@
                     mode=file_mode)
         finally:
             control_files.unlock()
-        # If we initialized using VFS methods on a RemoteTransport, return a
-        # Remote object: No need for it to be slower than necessary.
-        if isinstance(transport, remote_transport.RemoteTransport):
-            return self.open(transport)
-        else:
-            return self.open(transport, _found=True)
+        return self.open(transport, _found=True)
 
     def is_supported(self):
         """Is this format supported?

=== modified file 'bzrlib/tests/blackbox/test_push.py'
--- a/bzrlib/tests/blackbox/test_push.py	2009-02-19 01:41:43 +0000
+++ b/bzrlib/tests/blackbox/test_push.py	2009-02-19 02:06:54 +0000
@@ -192,7 +192,7 @@
         # being too low. If rpc_count increases, more network roundtrips have
         # become necessary for this use case. Please do not adjust this number
         # upwards without agreement from bzr's network support maintainers.
-        self.assertEqual(107, rpc_count)
+        self.assertEqual(94, rpc_count)
 
     def test_push_smart_stacked_streaming_acceptance(self):
         self.setup_smart_server_with_call_log()
@@ -209,7 +209,7 @@
         # being too low. If rpc_count increases, more network roundtrips have
         # become necessary for this use case. Please do not adjust this number
         # upwards without agreement from bzr's network support maintainers.
-        self.assertEqual(132, rpc_count)
+        self.assertEqual(119, rpc_count)
         remote = Branch.open('public')
         self.assertEndsWith(remote.get_stacked_on_url(), '/parent')
 

=== modified file 'bzrlib/tests/test_bzrdir.py'
--- a/bzrlib/tests/test_bzrdir.py	2009-02-19 01:41:43 +0000
+++ b/bzrlib/tests/test_bzrdir.py	2009-02-19 02:06:54 +0000
@@ -900,7 +900,7 @@
         # being too low. If rpc_count increases, more network roundtrips have
         # become necessary for this use case. Please do not adjust this number
         # upwards without agreement from bzr's network support maintainers.
-        self.assertEqual(15, rpc_count)
+        self.assertEqual(2, rpc_count)
 
 
 class TestFormat5(TestCaseWithTransport):




More information about the bazaar-commits mailing list