Rev 4020: (robertc) Create remote BzrDir objects using the existing bzr:// RPC in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Feb 19 08:43:48 GMT 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4020
revision-id: pqm at pqm.ubuntu.com-20090219084345-0wx5gbw9v6hdmjmz
parent: pqm at pqm.ubuntu.com-20090218235203-20qxqit61rkfwa1r
parent: robertc at robertcollins.net-20090219080129-r1h5npnyybteaohk
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2009-02-19 08:43:45 +0000
message:
(robertc) Create remote BzrDir objects using the existing bzr:// RPC
method when. (Robert Collins)
modified:
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
bzrlib/tests/test_bzrdir.py test_bzrdir.py-20060131065654-deba40eef51cf220
------------------------------------------------------------
revno: 4017.2.3
revision-id: robertc at robertcollins.net-20090219080129-r1h5npnyybteaohk
parent: robertc at robertcollins.net-20090219020654-1l19ged3zo7212jh
committer: Robert Collins <robertc at robertcollins.net>
branch nick: integration
timestamp: Thu 2009-02-19 19:01:29 +1100
message:
Review feedback.
modified:
bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
------------------------------------------------------------
revno: 4017.2.2
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:
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
bzrlib/tests/test_bzrdir.py test_bzrdir.py-20060131065654-deba40eef51cf220
------------------------------------------------------------
revno: 4017.2.1
revision-id: robertc at robertcollins.net-20090219014143-wv42sc7z71wbhht0
parent: pqm at pqm.ubuntu.com-20090218132708-okubrahz9exvae9r
committer: Robert Collins <robertc at robertcollins.net>
branch nick: push.roundtrips
timestamp: Thu 2009-02-19 12:41:43 +1100
message:
Add BzrDirFormatMeta1 test for the amount of rpc calls made initializing over the network.
modified:
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
bzrlib/tests/test_bzrdir.py test_bzrdir.py-20060131065654-deba40eef51cf220
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py 2009-02-18 03:25:21 +0000
+++ b/bzrlib/bzrdir.py 2009-02-19 02:06:54 +0000
@@ -188,8 +188,8 @@
"""
transport.ensure_base()
require_stacking = (stacked_on is not None)
- metadir = self.cloning_metadir(require_stacking)
- result = metadir.initialize_on_transport(transport)
+ format = self.cloning_metadir(require_stacking)
+ result = format.initialize_on_transport(transport)
repository_policy = None
try:
local_repo = self.find_repository()
@@ -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/__init__.py'
--- a/bzrlib/tests/__init__.py 2009-02-12 06:24:08 +0000
+++ b/bzrlib/tests/__init__.py 2009-02-19 01:41:43 +0000
@@ -76,6 +76,7 @@
from bzrlib.merge import merge_inner
import bzrlib.merge3
import bzrlib.plugin
+from bzrlib.smart import client, server
import bzrlib.store
from bzrlib import symbol_versioning
from bzrlib.symbol_versioning import (
@@ -2041,6 +2042,19 @@
self.__server = None
self.reduceLockdirTimeout()
+ def setup_smart_server_with_call_log(self):
+ """Sets up a smart server as the transport server with a call log."""
+ self.transport_server = server.SmartTCPServer_for_testing
+ self.hpss_calls = []
+ def capture_hpss_call(params):
+ import traceback
+ self.hpss_calls.append((params, traceback.format_stack()))
+ client._SmartClient.hooks.install_named_hook(
+ 'call', capture_hpss_call, None)
+
+ def reset_smart_call_log(self):
+ self.hpss_calls = []
+
class TestCaseInTempDir(TestCaseWithMemoryTransport):
"""Derived class that runs a test within a temporary directory.
=== modified file 'bzrlib/tests/blackbox/test_push.py'
--- a/bzrlib/tests/blackbox/test_push.py 2009-02-18 04:21:04 +0000
+++ b/bzrlib/tests/blackbox/test_push.py 2009-02-19 08:01:29 +0000
@@ -40,6 +40,16 @@
class TestPush(ExternalBase):
+ def test_push_error_on_vfs_http(self):
+ """ pushing a branch to a HTTP server fails cleanly. """
+ # the trunk is published on a web server
+ self.transport_readonly_server = HttpServer
+ self.make_branch('source')
+ public_url = self.get_readonly_url('target')
+ self.run_bzr_error(['http does not support mkdir'],
+ ['push', public_url],
+ working_dir='source')
+
def test_push_remember(self):
"""Push changes from one branch to another and test push location."""
transport = self.get_transport()
@@ -180,22 +190,11 @@
% tuple(map(urlutils.local_path_to_url, ['from', 'to-two'])))
self.failUnlessExists('to-two')
- def _reset_smart_call_log(self):
- self.hpss_calls = []
-
- def _setup_smart_call_log(self):
- self.transport_server = server.SmartTCPServer_for_testing
- self.hpss_calls = []
- def capture_hpss_call(params):
- self.hpss_calls.append(params)
- client._SmartClient.hooks.install_named_hook(
- 'call', capture_hpss_call, None)
-
def test_push_smart_non_stacked_streaming_acceptance(self):
- self._setup_smart_call_log()
+ self.setup_smart_server_with_call_log()
t = self.make_branch_and_tree('from')
t.commit(allow_pointless=True, message='first commit')
- self._reset_smart_call_log()
+ self.reset_smart_call_log()
self.run_bzr(['push', self.get_url('to-one')], working_dir='from')
rpc_count = len(self.hpss_calls)
# This figure represent the amount of work to perform this use case. It
@@ -203,15 +202,15 @@
# 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_call_log()
+ self.setup_smart_server_with_call_log()
parent = self.make_branch_and_tree('parent', format='1.9')
parent.commit(message='first commit')
local = parent.bzrdir.sprout('local').open_workingtree()
local.commit(message='local commit')
- self._reset_smart_call_log()
+ self.reset_smart_call_log()
self.run_bzr(['push', '--stacked', '--stacked-on', '../parent',
self.get_url('public')], working_dir='local')
rpc_count = len(self.hpss_calls)
@@ -220,7 +219,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-01-26 17:04:21 +0000
+++ b/bzrlib/tests/test_bzrdir.py 2009-02-19 02:06:54 +0000
@@ -32,6 +32,7 @@
repository,
osutils,
symbol_versioning,
+ remote,
urlutils,
win32utils,
workingtree,
@@ -885,6 +886,22 @@
self.assertTrue(tree.bzrdir.needs_format_conversion(
new_format))
+ def test_initialize_on_format_uses_smart_transport(self):
+ self.setup_smart_server_with_call_log()
+ new_format = bzrdir.format_registry.make_bzrdir('dirstate')
+ transport = self.get_transport('target')
+ transport.ensure_base()
+ self.reset_smart_call_log()
+ instance = new_format.initialize_on_transport(transport)
+ self.assertIsInstance(instance, remote.RemoteBzrDir)
+ rpc_count = len(self.hpss_calls)
+ # This figure represent the amount of work to perform this use case. It
+ # is entirely ok to reduce this number if a test fails due to rpc_count
+ # 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(2, rpc_count)
+
class TestFormat5(TestCaseWithTransport):
"""Tests specific to the version 5 bzrdir format."""
More information about the bazaar-commits
mailing list