Rev 4023: (robertc) Reduce the number of round trips required for initial push in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Feb 20 04:15:14 GMT 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4023
revision-id: pqm at pqm.ubuntu.com-20090220041509-nyuby6mehjjuaycj
parent: pqm at pqm.ubuntu.com-20090220022509-leun2dkfewbwcgn7
parent: robertc at robertcollins.net-20090220032937-n2ic1iy4selnjpy2
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2009-02-20 04:15:09 +0000
message:
(robertc) Reduce the number of round trips required for initial push
over a smart server by adding verbs for Repository
initialization and set_make_working_trees. (Robert Collins)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/smart/bzrdir.py bzrdir.py-20061122024551-ol0l0o0oofsu9b3t-1
bzrlib/smart/medium.py medium.py-20061103051856-rgu2huy59fkz902q-1
bzrlib/smart/repository.py repository.py-20061128022038-vr5wy5bubyb8xttk-1
bzrlib/smart/request.py request.py-20061108095550-gunadhxmzkdjfeek-1
bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
bzrlib/tests/blackbox/test_shared_repository.py test_shared_repository.py-20060317053531-ed30c0d79325e483
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
bzrlib/tests/test_smart.py test_smart.py-20061122024551-ol0l0o0oofsu9b3t-2
------------------------------------------------------------
revno: 4017.3.5
revision-id: robertc at robertcollins.net-20090220032937-n2ic1iy4selnjpy2
parent: robertc at robertcollins.net-20090220032807-9ezo43wv9boso5id
parent: pqm at pqm.ubuntu.com-20090220022509-leun2dkfewbwcgn7
committer: Robert Collins <robertc at robertcollins.net>
branch nick: integration
timestamp: Fri 2009-02-20 14:29:37 +1100
message:
Merge bzr.dev, resolve conflicts.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/btree_index.py index.py-20080624222253-p0x5f92uyh5hw734-7
bzrlib/index.py index.py-20070712131115-lolkarso50vjr64s-1
bzrlib/knit.py knit.py-20051212171256-f056ac8f0fbe1bd9
bzrlib/progress.py progress.py-20050610070202-df9faaab791964c0
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/repofmt/pack_repo.py pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
bzrlib/tests/test_btree_index.py test_index.py-20080624222253-p0x5f92uyh5hw734-13
bzrlib/tests/test_index.py test_index.py-20070712131115-lolkarso50vjr64s-2
bzrlib/tests/test_knit.py test_knit.py-20051212171302-95d4c00dd5f11f2b
bzrlib/tests/test_pack_repository.py test_pack_repository-20080801043947-eaw0e6h2gu75kwmy-1
bzrlib/tests/test_ui.py test_ui.py-20051130162854-458e667a7414af09
bzrlib/ui/text.py text.py-20051130153916-2e438cffc8afc478
------------------------------------------------------------
revno: 4017.3.4
revision-id: robertc at robertcollins.net-20090220032807-9ezo43wv9boso5id
parent: robertc at robertcollins.net-20090220032708-83exgbd9tymcs051
committer: Robert Collins <robertc at robertcollins.net>
branch nick: push.roundtrips
timestamp: Fri 2009-02-20 14:28:07 +1100
message:
Create a verb for Repository.set_make_working_trees.
modified:
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/smart/repository.py repository.py-20061128022038-vr5wy5bubyb8xttk-1
bzrlib/smart/request.py request.py-20061108095550-gunadhxmzkdjfeek-1
bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
bzrlib/tests/blackbox/test_shared_repository.py test_shared_repository.py-20060317053531-ed30c0d79325e483
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
bzrlib/tests/test_smart.py test_smart.py-20061122024551-ol0l0o0oofsu9b3t-2
------------------------------------------------------------
revno: 4017.3.3
revision-id: robertc at robertcollins.net-20090220032708-83exgbd9tymcs051
parent: robertc at robertcollins.net-20090219072837-vznmfrq7lz1grtti
committer: Robert Collins <robertc at robertcollins.net>
branch nick: push.roundtrips
timestamp: Fri 2009-02-20 14:27:08 +1100
message:
Review feedback - make RemoteRepository.initialize use helpers, and version-lock the new method to not attempt the method on older servers.
modified:
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/smart/medium.py medium.py-20061103051856-rgu2huy59fkz902q-1
------------------------------------------------------------
revno: 4017.3.2
revision-id: robertc at robertcollins.net-20090219072837-vznmfrq7lz1grtti
parent: robertc at robertcollins.net-20090219033543-s63jjuz9vcgrnio9
committer: Robert Collins <robertc at robertcollins.net>
branch nick: push.roundtrips
timestamp: Thu 2009-02-19 18:28:37 +1100
message:
Reduce the number of round trips required to create a repository over the network.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/smart/bzrdir.py bzrdir.py-20061122024551-ol0l0o0oofsu9b3t-1
bzrlib/smart/request.py request.py-20061108095550-gunadhxmzkdjfeek-1
bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
bzrlib/tests/blackbox/test_shared_repository.py test_shared_repository.py-20060317053531-ed30c0d79325e483
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
bzrlib/tests/test_smart.py test_smart.py-20061122024551-ol0l0o0oofsu9b3t-2
------------------------------------------------------------
revno: 4017.3.1
revision-id: robertc at robertcollins.net-20090219033543-s63jjuz9vcgrnio9
parent: robertc at robertcollins.net-20090219020654-1l19ged3zo7212jh
parent: robertc at robertcollins.net-20090219030955-1gqi3hfhg3h16eqv
committer: Robert Collins <robertc at robertcollins.net>
branch nick: push.roundtrips
timestamp: Thu 2009-02-19 14:35:43 +1100
message:
Add effort test for init-repo on smart server urls.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/repofmt/weaverepo.py presplitout.py-20070125045333-wfav3tsh73oxu3zk-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/tests/blackbox/test_shared_repository.py test_shared_repository.py-20060317053531-ed30c0d79325e483
bzrlib/tests/per_repository/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
=== modified file 'NEWS'
--- a/NEWS 2009-02-20 02:25:09 +0000
+++ b/NEWS 2009-02-20 03:29:37 +0000
@@ -65,6 +65,9 @@
* ``bzrlib.tests.run_suite`` accepts a runner_class parameter
supporting the use of different runners. (Robert Collins)
+ * Creating a repository on a bzr+ssh:// server will now make a single
+ call rather than many VFS calls. (Robert Collins)
+
* New hook Commands['extend_command'] to allow plugins to access a
command object before the command is run (or help generated from
it), without overriding the command. (Robert Collins)
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py 2009-02-20 02:25:09 +0000
+++ b/bzrlib/bzrdir.py 2009-02-20 03:29:37 +0000
@@ -2757,7 +2757,10 @@
if custom_format:
# We will use the custom format to create repositories over the
# wire; expose its details like rich_root_data for code to query
- result._custom_format = custom_format
+ if isinstance(custom_format, remote.RemoteRepositoryFormat):
+ result._custom_format = custom_format._custom_format
+ else:
+ result._custom_format = custom_format
result.rich_root_data = custom_format.rich_root_data
return result
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py 2009-02-20 01:45:00 +0000
+++ b/bzrlib/remote.py 2009-02-20 03:29:37 +0000
@@ -21,6 +21,7 @@
from bzrlib import (
branch,
+ bzrdir,
debug,
errors,
graph,
@@ -281,25 +282,74 @@
def __init__(self):
repository.RepositoryFormat.__init__(self)
self._custom_format = None
+ self._network_name = None
+ self._creating_bzrdir = None
- def initialize(self, a_bzrdir, shared=False):
+ def _vfs_initialize(self, a_bzrdir, shared):
+ """Helper for common code in initialize."""
if self._custom_format:
- # This returns a custom instance - e.g. a pack repo, not a remote
- # repo.
- return self._custom_format.initialize(a_bzrdir, shared=shared)
- if not isinstance(a_bzrdir, RemoteBzrDir):
+ # Custom format requested
+ result = self._custom_format.initialize(a_bzrdir, shared=shared)
+ elif self._creating_bzrdir is not None:
+ # Use the format that the repository we were created to back
+ # has.
prior_repo = self._creating_bzrdir.open_repository()
prior_repo._ensure_real()
- return prior_repo._real_repository._format.initialize(
+ result = prior_repo._real_repository._format.initialize(
a_bzrdir, shared=shared)
- # delegate to a real object at this point (remoteBzrDir delegate to the
- # repository format which would lead to infinite recursion).
- a_bzrdir._ensure_real()
- result = a_bzrdir._real_bzrdir.create_repository(shared=shared)
+ else:
+ # assume that a_bzr is a RemoteBzrDir but the smart server didn't
+ # support remote initialization.
+ # We delegate to a real object at this point (as RemoteBzrDir
+ # delegate to the repository format which would lead to infinite
+ # recursion if we just called a_bzrdir.create_repository.
+ a_bzrdir._ensure_real()
+ result = a_bzrdir._real_bzrdir.create_repository(shared=shared)
if not isinstance(result, RemoteRepository):
return self.open(a_bzrdir)
else:
return result
+
+ def initialize(self, a_bzrdir, shared=False):
+ # Being asked to create on a non RemoteBzrDir:
+ if not isinstance(a_bzrdir, RemoteBzrDir):
+ return self._vfs_initialize(a_bzrdir, shared)
+ medium = a_bzrdir._client._medium
+ if medium._is_remote_before((1, 13)):
+ return self._vfs_initialize(a_bzrdir, shared)
+ # Creating on a remote bzr dir.
+ # 1) get the network name to use.
+ if self._custom_format:
+ network_name = self._custom_format.network_name()
+ else:
+ # Select the current bzrlib default and ask for that.
+ reference_bzrdir_format = bzrdir.format_registry.get('default')()
+ reference_format = reference_bzrdir_format.repository_format
+ network_name = reference_format.network_name()
+ # 2) try direct creation via RPC
+ path = a_bzrdir._path_for_remote_call(a_bzrdir._client)
+ verb = 'BzrDir.create_repository'
+ if shared:
+ shared_str = 'True'
+ else:
+ shared_str = 'False'
+ try:
+ response = a_bzrdir._call(verb, path, network_name, shared_str)
+ except errors.UnknownSmartMethod:
+ # Fallback - use vfs methods
+ return self._vfs_initialize(a_bzrdir, shared)
+ else:
+ # Turn the response into a RemoteRepository object.
+ format = RemoteRepositoryFormat()
+ format.rich_root_data = (response[1] == 'yes')
+ format.supports_tree_reference = (response[2] == 'yes')
+ format.supports_external_lookups = (response[3] == 'yes')
+ format._network_name = response[4]
+ # Used to support creating a real format instance when needed.
+ format._creating_bzrdir = a_bzrdir
+ remote_repo = RemoteRepository(a_bzrdir, format)
+ format._creating_repo = remote_repo
+ return remote_repo
def open(self, a_bzrdir):
if not isinstance(a_bzrdir, RemoteBzrDir):
@@ -322,6 +372,8 @@
'Does not support nested trees', target_format)
def network_name(self):
+ if self._network_name:
+ return self._network_name
self._creating_repo._ensure_real()
return self._creating_repo._real_repository._format.network_name()
@@ -1142,8 +1194,20 @@
return self._real_repository.revisions
def set_make_working_trees(self, new_value):
- self._ensure_real()
- self._real_repository.set_make_working_trees(new_value)
+ if new_value:
+ new_value_str = "True"
+ else:
+ new_value_str = "False"
+ path = self.bzrdir._path_for_remote_call(self._client)
+ try:
+ response = self._call(
+ 'Repository.set_make_working_trees', path, new_value_str)
+ except errors.UnknownSmartMethod:
+ self._ensure_real()
+ self._real_repository.set_make_working_trees(new_value)
+ else:
+ if response[0] != 'ok':
+ raise errors.UnexpectedSmartServerResponse(response)
@property
def signatures(self):
=== modified file 'bzrlib/smart/bzrdir.py'
--- a/bzrlib/smart/bzrdir.py 2008-03-27 06:10:18 +0000
+++ b/bzrlib/smart/bzrdir.py 2009-02-19 07:28:37 +0000
@@ -24,6 +24,7 @@
SmartServerRequest,
SuccessfulSmartServerResponse,
)
+from bzrlib.repository import network_format_registry
class SmartServerRequestOpenBzrDir(SmartServerRequest):
@@ -51,7 +52,7 @@
return SuccessfulSmartServerResponse((answer,))
-class SmartServerRequestFindRepository(SmartServerRequest):
+class SmartServerRequestBzrDir(SmartServerRequest):
def _boolean_to_yes_no(self, a_boolean):
if a_boolean:
@@ -59,6 +60,50 @@
else:
return 'no'
+ def _format_to_capabilities(self, repo_format):
+ rich_root = self._boolean_to_yes_no(repo_format.rich_root_data)
+ tree_ref = self._boolean_to_yes_no(
+ repo_format.supports_tree_reference)
+ external_lookup = self._boolean_to_yes_no(
+ repo_format.supports_external_lookups)
+ return rich_root, tree_ref, external_lookup
+
+
+class SmartServerRequestCreateRepository(SmartServerRequestBzrDir):
+
+ def do(self, path, network_name, shared):
+ """Create a repository in the bzr dir at path.
+
+ This operates precisely like 'bzrdir.create_repository'.
+
+ If a bzrdir is not present, an exception is propogated
+ rather than 'no branch' because these are different conditions (and
+ this method should only be called after establishing that a bzr dir
+ exists anyway).
+
+ This is the initial version of this method introduced to the smart
+ server for 1.13.
+
+ :param path: The path to the bzrdir.
+ :param network_name: The network name of the repository type to create.
+ :param shared: The value to pass create_repository for the shared
+ parameter.
+ :return: (ok, rich_root, tree_ref, external_lookup, network_name)
+ """
+ bzrdir = BzrDir.open_from_transport(
+ self.transport_from_client_path(path))
+ shared = shared == 'True'
+ format = network_format_registry.get(network_name)
+ bzrdir.repository_format = format
+ result = format.initialize(bzrdir, shared=shared)
+ rich_root, tree_ref, external_lookup = self._format_to_capabilities(
+ result._format)
+ return SuccessfulSmartServerResponse(('ok', rich_root, tree_ref,
+ external_lookup, result._format.network_name()))
+
+
+class SmartServerRequestFindRepository(SmartServerRequestBzrDir):
+
def _find(self, path):
"""try to find a repository from path upwards
@@ -81,11 +126,8 @@
segments = ['..'] * len(relpath.split('/'))
else:
segments = []
- rich_root = self._boolean_to_yes_no(repository.supports_rich_root())
- tree_ref = self._boolean_to_yes_no(
- repository._format.supports_tree_reference)
- external_lookup = self._boolean_to_yes_no(
- repository._format.supports_external_lookups)
+ rich_root, tree_ref, external_lookup = self._format_to_capabilities(
+ repository._format)
return '/'.join(segments), rich_root, tree_ref, external_lookup
=== modified file 'bzrlib/smart/medium.py'
--- a/bzrlib/smart/medium.py 2009-01-07 00:58:30 +0000
+++ b/bzrlib/smart/medium.py 2009-02-20 03:27:08 +0000
@@ -574,6 +574,10 @@
"""
if (self._remote_version_is_before is not None and
version_tuple > self._remote_version_is_before):
+ # We have been told that the remote side is older than some version
+ # which is newer than a previously supplied older-than version.
+ # This indicates that some smart verb call is not guarded
+ # appropriately (it should simply not have been tried).
raise AssertionError(
"_remember_remote_is_before(%r) called, but "
"_remember_remote_is_before(%r) was called previously."
=== modified file 'bzrlib/smart/repository.py'
--- a/bzrlib/smart/repository.py 2008-09-08 05:49:27 +0000
+++ b/bzrlib/smart/repository.py 2009-02-20 03:28:07 +0000
@@ -336,6 +336,17 @@
return SuccessfulSmartServerResponse(('ok',))
+class SmartServerRepositorySetMakeWorkingTrees(SmartServerRepositoryRequest):
+
+ def do_repository_request(self, repository, str_bool_new_value):
+ if str_bool_new_value == 'True':
+ new_value = True
+ else:
+ new_value = False
+ repository.set_make_working_trees(new_value)
+ return SuccessfulSmartServerResponse(('ok',))
+
+
class SmartServerRepositoryTarball(SmartServerRepositoryRequest):
"""Get the raw repository files as a tarball.
=== modified file 'bzrlib/smart/request.py'
--- a/bzrlib/smart/request.py 2009-02-11 09:54:36 +0000
+++ b/bzrlib/smart/request.py 2009-02-20 03:28:07 +0000
@@ -401,6 +401,8 @@
request_handlers.register_lazy(
'Branch.unlock', 'bzrlib.smart.branch', 'SmartServerBranchRequestUnlock')
request_handlers.register_lazy(
+ 'BzrDir.create_repository', 'bzrlib.smart.bzrdir', 'SmartServerRequestCreateRepository')
+request_handlers.register_lazy(
'BzrDir.find_repository', 'bzrlib.smart.bzrdir', 'SmartServerRequestFindRepositoryV1')
request_handlers.register_lazy(
'BzrDir.find_repositoryV2', 'bzrlib.smart.bzrdir', 'SmartServerRequestFindRepositoryV2')
@@ -452,6 +454,9 @@
request_handlers.register_lazy(
'Repository.lock_write', 'bzrlib.smart.repository', 'SmartServerRepositoryLockWrite')
request_handlers.register_lazy(
+ 'Repository.set_make_working_trees', 'bzrlib.smart.repository',
+ 'SmartServerRepositorySetMakeWorkingTrees')
+request_handlers.register_lazy(
'Repository.unlock', 'bzrlib.smart.repository', 'SmartServerRepositoryUnlock')
request_handlers.register_lazy(
'Repository.tarball', 'bzrlib.smart.repository',
=== modified file 'bzrlib/tests/blackbox/test_push.py'
--- a/bzrlib/tests/blackbox/test_push.py 2009-02-19 08:01:29 +0000
+++ b/bzrlib/tests/blackbox/test_push.py 2009-02-20 03:29:37 +0000
@@ -202,7 +202,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(94, rpc_count)
+ self.assertEqual(74, rpc_count)
def test_push_smart_stacked_streaming_acceptance(self):
self.setup_smart_server_with_call_log()
@@ -219,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(119, rpc_count)
+ self.assertEqual(99, rpc_count)
remote = Branch.open('public')
self.assertEndsWith(remote.get_stacked_on_url(), '/parent')
=== modified file 'bzrlib/tests/blackbox/test_shared_repository.py'
--- a/bzrlib/tests/blackbox/test_shared_repository.py 2008-07-18 07:29:06 +0000
+++ b/bzrlib/tests/blackbox/test_shared_repository.py 2009-02-20 03:28:07 +0000
@@ -108,3 +108,16 @@
self.run_bzr("init-repo --no-trees notrees")
repo = BzrDir.open("notrees").open_repository()
self.assertEqual(False, repo.make_working_trees())
+
+ def test_init_repo_smart_acceptance(self):
+ # The amount of hpss calls made on init-repo to a smart server should
+ # be fixed.
+ self.setup_smart_server_with_call_log()
+ self.run_bzr(['init-repo', self.get_url('repo')])
+ 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(16, rpc_count)
=== modified file 'bzrlib/tests/test_remote.py'
--- a/bzrlib/tests/test_remote.py 2009-02-13 00:52:18 +0000
+++ b/bzrlib/tests/test_remote.py 2009-02-20 03:28:07 +0000
@@ -34,6 +34,7 @@
pack,
remote,
repository,
+ smart,
tests,
urlutils,
)
@@ -259,6 +260,18 @@
self.assertTrue(result)
+class TestRemote(tests.TestCaseWithMemoryTransport):
+
+ def disable_verb(self, verb):
+ """Disable a verb for one test."""
+ request_handlers = smart.request.request_handlers
+ orig_method = request_handlers.get(verb)
+ request_handlers.remove(verb)
+ def restoreVerb():
+ request_handlers.register(verb, orig_method)
+ self.addCleanup(restoreVerb)
+
+
class Test_ClientMedium_remote_path_from_transport(tests.TestCase):
"""Tests for the behaviour of client_medium.remote_path_from_transport."""
@@ -446,6 +459,43 @@
RemoteBzrDirFormat.probe_transport, OldServerTransport())
+class TestBzrDirCreateRepository(TestRemote):
+
+ def test_backwards_compat(self):
+ self.setup_smart_server_with_call_log()
+ bzrdir = self.make_bzrdir('.')
+ self.reset_smart_call_log()
+ self.disable_verb('BzrDir.create_repository')
+ repo = bzrdir.create_repository()
+ create_repo_call_count = len([call for call in self.hpss_calls if
+ call[0].method == 'BzrDir.create_repository'])
+ self.assertEqual(1, create_repo_call_count)
+
+ def test_current_server(self):
+ transport = self.get_transport('.')
+ transport = transport.clone('quack')
+ self.make_bzrdir('quack')
+ client = FakeClient(transport.base)
+ reference_bzrdir_format = bzrdir.format_registry.get('default')()
+ reference_format = reference_bzrdir_format.repository_format
+ network_name = reference_format.network_name()
+ client.add_expected_call(
+ 'BzrDir.create_repository', ('quack/',
+ 'Bazaar pack repository format 1 (needs bzr 0.92)\n', 'False'),
+ 'success', ('ok', 'no', 'no', 'no', network_name))
+ a_bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
+ _client=client)
+ repo = a_bzrdir.create_repository()
+ # We should have got a remote repository
+ self.assertIsInstance(repo, remote.RemoteRepository)
+ # its format should have the settings from the response
+ format = repo._format
+ self.assertFalse(format.rich_root_data)
+ self.assertFalse(format.supports_tree_reference)
+ self.assertFalse(format.supports_external_lookups)
+ self.assertEqual(network_name, format.network_name())
+
+
class TestBzrDirOpenRepository(tests.TestCase):
def test_backwards_compat_1_2(self):
@@ -453,7 +503,7 @@
transport.mkdir('quack')
transport = transport.clone('quack')
client = FakeClient(transport.base)
- client.add_unknown_method_response('RemoteRepository.find_repositoryV2')
+ client.add_unknown_method_response('BzrDir.find_repositoryV2')
client.add_success_response('ok', '', 'no', 'no')
bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
_client=client)
@@ -1080,7 +1130,7 @@
self.assertEqual('bar', t._get_credentials()[0])
-class TestRemoteRepository(tests.TestCase):
+class TestRemoteRepository(TestRemote):
"""Base for testing RemoteRepository protocol usage.
These tests contain frozen requests and responses. We want any changes to
@@ -1423,6 +1473,32 @@
client._calls)
+class TestRepositorySetMakeWorkingTrees(TestRemoteRepository):
+
+ def test_backwards_compat(self):
+ self.setup_smart_server_with_call_log()
+ repo = self.make_repository('.')
+ self.reset_smart_call_log()
+ verb = 'Repository.set_make_working_trees'
+ self.disable_verb(verb)
+ repo.set_make_working_trees(True)
+ call_count = len([call for call in self.hpss_calls if
+ call[0].method == verb])
+ self.assertEqual(1, call_count)
+
+ def test_current(self):
+ transport_path = 'quack'
+ repo, client = self.setup_fake_client_and_repository(transport_path)
+ client.add_expected_call(
+ 'Repository.set_make_working_trees', ('quack/', 'True'),
+ 'success', ('ok',))
+ client.add_expected_call(
+ 'Repository.set_make_working_trees', ('quack/', 'False'),
+ 'success', ('ok',))
+ repo.set_make_working_trees(True)
+ repo.set_make_working_trees(False)
+
+
class TestRepositoryUnlock(TestRemoteRepository):
def test_unlock(self):
=== modified file 'bzrlib/tests/test_smart.py'
--- a/bzrlib/tests/test_smart.py 2008-11-20 10:43:39 +0000
+++ b/bzrlib/tests/test_smart.py 2009-02-20 03:28:07 +0000
@@ -160,6 +160,23 @@
request.transport_from_client_path('foo/').base)
+class TestSmartServerRequestCreateRepository(tests.TestCaseWithMemoryTransport):
+ """Tests for BzrDir.create_repository."""
+
+ def test_makes_repository(self):
+ """When there is a bzrdir present, the call succeeds."""
+ backing = self.get_transport()
+ self.make_bzrdir('.')
+ request_class = bzrlib.smart.bzrdir.SmartServerRequestCreateRepository
+ request = request_class(backing)
+ reference_bzrdir_format = bzrdir.format_registry.get('default')()
+ reference_format = reference_bzrdir_format.repository_format
+ network_name = reference_format.network_name()
+ expected = SuccessfulSmartServerResponse(
+ ('ok', 'no', 'no', 'no', network_name))
+ self.assertEqual(expected, request.execute('', network_name, 'True'))
+
+
class TestSmartServerRequestFindRepository(tests.TestCaseWithMemoryTransport):
"""Tests for BzrDir.find_repository."""
@@ -1037,6 +1054,31 @@
SmartServerResponse(('yes',)), response)
+class TestSmartServerRepositorySetMakeWorkingTrees(tests.TestCaseWithMemoryTransport):
+
+ def test_set_false(self):
+ backing = self.get_transport()
+ repo = self.make_repository('.', shared=True)
+ repo.set_make_working_trees(True)
+ request_class = smart.repository.SmartServerRepositorySetMakeWorkingTrees
+ request = request_class(backing)
+ self.assertEqual(SuccessfulSmartServerResponse(('ok',)),
+ request.execute('', 'False'))
+ repo = repo.bzrdir.open_repository()
+ self.assertFalse(repo.make_working_trees())
+
+ def test_set_true(self):
+ backing = self.get_transport()
+ repo = self.make_repository('.', shared=True)
+ repo.set_make_working_trees(False)
+ request_class = smart.repository.SmartServerRepositorySetMakeWorkingTrees
+ request = request_class(backing)
+ self.assertEqual(SuccessfulSmartServerResponse(('ok',)),
+ request.execute('', 'True'))
+ repo = repo.bzrdir.open_repository()
+ self.assertTrue(repo.make_working_trees())
+
+
class TestSmartServerPackRepositoryAutopack(tests.TestCaseWithTransport):
def make_repo_needing_autopacking(self, path='.'):
More information about the bazaar-commits
mailing list