Rev 4022: Create a smart verb for Repository.set_make_working_trees. in http://people.ubuntu.com/~robertc/baz2.0/push.roundtrips
Robert Collins
robertc at robertcollins.net
Thu Feb 19 09:51:15 GMT 2009
At http://people.ubuntu.com/~robertc/baz2.0/push.roundtrips
------------------------------------------------------------
revno: 4022
revision-id: robertc at robertcollins.net-20090219095111-x2uumj8oyxczkxvw
parent: robertc at robertcollins.net-20090219072837-vznmfrq7lz1grtti
committer: Robert Collins <robertc at robertcollins.net>
branch nick: push.roundtrips
timestamp: Thu 2009-02-19 20:51:11 +1100
message:
Create a smart verb for Repository.set_make_working_trees.
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py 2009-02-19 07:28:37 +0000
+++ b/bzrlib/remote.py 2009-02-19 09:51:11 +0000
@@ -1185,8 +1185,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/repository.py'
--- a/bzrlib/smart/repository.py 2008-09-08 05:49:27 +0000
+++ b/bzrlib/smart/repository.py 2009-02-19 09:51:11 +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-19 07:28:37 +0000
+++ b/bzrlib/smart/request.py 2009-02-19 09:51:11 +0000
@@ -454,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 07:28:37 +0000
+++ b/bzrlib/tests/blackbox/test_push.py 2009-02-19 09:51:11 +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(75, rpc_count)
+ self.assertEqual(74, 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(100, 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 2009-02-19 07:28:37 +0000
+++ b/bzrlib/tests/blackbox/test_shared_repository.py 2009-02-19 09:51:11 +0000
@@ -120,4 +120,4 @@
# 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(19, rpc_count)
+ self.assertEqual(16, rpc_count)
=== modified file 'bzrlib/tests/test_remote.py'
--- a/bzrlib/tests/test_remote.py 2009-02-19 07:28:37 +0000
+++ b/bzrlib/tests/test_remote.py 2009-02-19 09:51:11 +0000
@@ -260,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."""
@@ -447,22 +459,17 @@
RemoteBzrDirFormat.probe_transport, OldServerTransport())
-class TestBzrDirCreateRepository(tests.TestCaseWithMemoryTransport):
+class TestBzrDirCreateRepository(TestRemote):
def test_backwards_compat(self):
self.setup_smart_server_with_call_log()
bzrdir = self.make_bzrdir('.')
self.reset_smart_call_log()
- request_handlers = smart.request.request_handlers
- orig_method = request_handlers.get('BzrDir.create_repository')
- request_handlers.remove('BzrDir.create_repository')
- try:
- 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)
- finally:
- request_handlers.register('BzrDir.create_repository', orig_method)
+ 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('.')
@@ -1123,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
@@ -1466,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 2009-02-19 07:28:37 +0000
+++ b/bzrlib/tests/test_smart.py 2009-02-19 09:51:11 +0000
@@ -1054,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