Rev 6300: (jelmer) Add HPSS call for ``Repository.get_physical_lock_status``. (Jelmer in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Nov 25 15:36:45 UTC 2011
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6300 [merge]
revision-id: pqm at pqm.ubuntu.com-20111125153645-7ojsm3a4oz24m754
parent: pqm at pqm.ubuntu.com-20111125144749-spezm225qcymzqpn
parent: jelmer at samba.org-20111125151043-bgchti3pcrnxgchk
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2011-11-25 15:36:45 +0000
message:
(jelmer) Add HPSS call for ``Repository.get_physical_lock_status``. (Jelmer
Vernooij)
modified:
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/smart/branch.py branch.py-20061124031907-mzh3pla28r83r97f-1
bzrlib/smart/repository.py repository.py-20061128022038-vr5wy5bubyb8xttk-1
bzrlib/smart/request.py request.py-20061108095550-gunadhxmzkdjfeek-1
bzrlib/tests/blackbox/test_info.py test_info.py-20060215045507-bbdd2d34efab9e0a
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
bzrlib/tests/test_smart.py test_smart.py-20061122024551-ol0l0o0oofsu9b3t-2
doc/en/release-notes/bzr-2.5.txt bzr2.5.txt-20110708125756-587p0hpw7oke4h05-1
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py 2011-11-25 14:47:49 +0000
+++ b/bzrlib/remote.py 2011-11-25 15:10:43 +0000
@@ -1328,9 +1328,15 @@
def get_physical_lock_status(self):
"""See Repository.get_physical_lock_status()."""
- # should be an API call to the server.
- self._ensure_real()
- return self._real_repository.get_physical_lock_status()
+ path = self.bzrdir._path_for_remote_call(self._client)
+ try:
+ response = self._call('Repository.get_physical_lock_status', path)
+ except errors.UnknownSmartMethod:
+ self._ensure_real()
+ return self._real_repository.get_physical_lock_status()
+ if response[0] not in ('yes', 'no'):
+ raise errors.UnexpectedSmartServerResponse(response)
+ return (response[0] == 'yes')
def is_in_write_group(self):
"""Return True if there is an open write group.
@@ -2875,9 +2881,15 @@
def get_physical_lock_status(self):
"""See Branch.get_physical_lock_status()."""
- # should be an API call to the server, as branches must be lockable.
- self._ensure_real()
- return self._real_branch.get_physical_lock_status()
+ try:
+ response = self._client.call('Branch.get_physical_lock_status',
+ self._remote_path())
+ except errors.UnknownSmartMethod:
+ self._ensure_real()
+ return self._real_branch.get_physical_lock_status()
+ if response[0] not in ('yes', 'no'):
+ raise errors.UnexpectedSmartServerResponse(response)
+ return (response[0] == 'yes')
def get_stacked_on_url(self):
"""Get the URL this branch is stacked against.
=== modified file 'bzrlib/smart/branch.py'
--- a/bzrlib/smart/branch.py 2011-11-25 13:31:19 +0000
+++ b/bzrlib/smart/branch.py 2011-11-25 14:04:12 +0000
@@ -434,3 +434,15 @@
branch.unlock()
return SuccessfulSmartServerResponse(('ok',))
+
+class SmartServerBranchRequestGetPhysicalLockStatus(SmartServerBranchRequest):
+ """Get the physical lock status for a branch.
+
+ New in 2.5.
+ """
+
+ def do_with_branch(self, branch):
+ if branch.get_physical_lock_status():
+ return SuccessfulSmartServerResponse(('yes',))
+ else:
+ return SuccessfulSmartServerResponse(('no',))
=== modified file 'bzrlib/smart/repository.py'
--- a/bzrlib/smart/repository.py 2011-11-25 13:50:56 +0000
+++ b/bzrlib/smart/repository.py 2011-11-25 14:05:18 +0000
@@ -753,6 +753,19 @@
return SuccessfulSmartServerResponse(('ok',))
+class SmartServerRepositoryGetPhysicalLockStatus(SmartServerRepositoryRequest):
+ """Get the physical lock status for a repository.
+
+ New in 2.5.
+ """
+
+ def do_repository_request(self, repository):
+ if repository.get_physical_lock_status():
+ return SuccessfulSmartServerResponse(('yes', ))
+ else:
+ return SuccessfulSmartServerResponse(('no', ))
+
+
class SmartServerRepositorySetMakeWorkingTrees(SmartServerRepositoryRequest):
def do_repository_request(self, repository, str_bool_new_value):
=== modified file 'bzrlib/smart/request.py'
--- a/bzrlib/smart/request.py 2011-11-25 14:47:49 +0000
+++ b/bzrlib/smart/request.py 2011-11-25 15:10:43 +0000
@@ -520,6 +520,9 @@
'Branch.last_revision_info', 'bzrlib.smart.branch', 'SmartServerBranchRequestLastRevisionInfo')
request_handlers.register_lazy(
'Branch.lock_write', 'bzrlib.smart.branch', 'SmartServerBranchRequestLockWrite')
+request_handlers.register_lazy(
+ 'Branch.get_physical_lock_status', 'bzrlib.smart.branch',
+ 'SmartServerBranchRequestGetPhysicalLockStatus')
request_handlers.register_lazy( 'Branch.revision_history',
'bzrlib.smart.branch', 'SmartServerRequestRevisionHistory')
request_handlers.register_lazy( 'Branch.set_config_option',
@@ -656,6 +659,9 @@
request_handlers.register_lazy(
'Repository.unlock', 'bzrlib.smart.repository', 'SmartServerRepositoryUnlock')
request_handlers.register_lazy(
+ 'Repository.get_physical_lock_status', 'bzrlib.smart.repository',
+ 'SmartServerRepositoryGetPhysicalLockStatus')
+request_handlers.register_lazy(
'Repository.get_rev_id_for_revno', 'bzrlib.smart.repository',
'SmartServerRepositoryGetRevIdForRevno')
request_handlers.register_lazy(
=== modified file 'bzrlib/tests/blackbox/test_info.py'
--- a/bzrlib/tests/blackbox/test_info.py 2011-11-22 23:17:05 +0000
+++ b/bzrlib/tests/blackbox/test_info.py 2011-11-23 12:01:08 +0000
@@ -1457,4 +1457,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.assertLength(25, self.hpss_calls)
+ self.assertLength(16, self.hpss_calls)
=== modified file 'bzrlib/tests/test_remote.py'
--- a/bzrlib/tests/test_remote.py 2011-11-25 14:47:49 +0000
+++ b/bzrlib/tests/test_remote.py 2011-11-25 15:10:43 +0000
@@ -1084,6 +1084,41 @@
self.assertFinished(client)
+class TestBranchGetPhysicalLockStatus(RemoteBranchTestCase):
+
+ def test_get_physical_lock_status_yes(self):
+ transport = MemoryTransport()
+ client = FakeClient(transport.base)
+ client.add_expected_call(
+ 'Branch.get_stacked_on_url', ('quack/',),
+ 'error', ('NotStacked',))
+ client.add_expected_call(
+ 'Branch.get_physical_lock_status', ('quack/',),
+ 'success', ('yes',))
+ transport.mkdir('quack')
+ transport = transport.clone('quack')
+ branch = self.make_remote_branch(transport, client)
+ result = branch.get_physical_lock_status()
+ self.assertFinished(client)
+ self.assertEqual(True, result)
+
+ def test_get_physical_lock_status_no(self):
+ transport = MemoryTransport()
+ client = FakeClient(transport.base)
+ client.add_expected_call(
+ 'Branch.get_stacked_on_url', ('quack/',),
+ 'error', ('NotStacked',))
+ client.add_expected_call(
+ 'Branch.get_physical_lock_status', ('quack/',),
+ 'success', ('no',))
+ transport.mkdir('quack')
+ transport = transport.clone('quack')
+ branch = self.make_remote_branch(transport, client)
+ result = branch.get_physical_lock_status()
+ self.assertFinished(client)
+ self.assertEqual(False, result)
+
+
class TestBranchGetParent(RemoteBranchTestCase):
def test_no_parent(self):
@@ -2739,6 +2774,31 @@
self.assertEqual(False, result)
+class TestRepositoryPhysicalLockStatus(TestRemoteRepository):
+
+ def test_get_physical_lock_status_yes(self):
+ transport_path = 'qwack'
+ repo, client = self.setup_fake_client_and_repository(transport_path)
+ client.add_success_response('yes')
+ result = repo.get_physical_lock_status()
+ self.assertEqual(
+ [('call', 'Repository.get_physical_lock_status',
+ ('qwack/', ))],
+ client._calls)
+ self.assertEqual(True, result)
+
+ def test_get_physical_lock_status_no(self):
+ transport_path = 'qwack'
+ repo, client = self.setup_fake_client_and_repository(transport_path)
+ client.add_success_response('no')
+ result = repo.get_physical_lock_status()
+ self.assertEqual(
+ [('call', 'Repository.get_physical_lock_status',
+ ('qwack/', ))],
+ client._calls)
+ self.assertEqual(False, result)
+
+
class TestRepositoryIsShared(TestRemoteRepository):
def test_is_shared(self):
=== modified file 'bzrlib/tests/test_smart.py'
--- a/bzrlib/tests/test_smart.py 2011-11-25 14:47:49 +0000
+++ b/bzrlib/tests/test_smart.py 2011-11-25 15:10:43 +0000
@@ -1428,6 +1428,34 @@
self.assertEqual('LockFailed', error_name)
+class TestSmartServerBranchRequestGetPhysicalLockStatus(TestLockedBranch):
+
+ def setUp(self):
+ tests.TestCaseWithMemoryTransport.setUp(self)
+
+ def test_true(self):
+ backing = self.get_transport()
+ request = smart_branch.SmartServerBranchRequestGetPhysicalLockStatus(
+ backing)
+ branch = self.make_branch('.')
+ branch_token, repo_token = self.get_lock_tokens(branch)
+ self.assertEquals(True, branch.get_physical_lock_status())
+ response = request.execute('')
+ self.assertEqual(
+ smart_req.SmartServerResponse(('yes',)), response)
+ branch.unlock()
+
+ def test_false(self):
+ backing = self.get_transport()
+ request = smart_branch.SmartServerBranchRequestGetPhysicalLockStatus(
+ backing)
+ branch = self.make_branch('.')
+ self.assertEquals(False, branch.get_physical_lock_status())
+ response = request.execute('')
+ self.assertEqual(
+ smart_req.SmartServerResponse(('no',)), response)
+
+
class TestSmartServerBranchRequestUnlock(TestLockedBranch):
def setUp(self):
@@ -2027,6 +2055,34 @@
smart_req.SmartServerResponse(('TokenMismatch',)), response)
+class TestSmartServerRepositoryGetPhysicalLockStatus(
+ tests.TestCaseWithTransport):
+
+ def test_with_write_lock(self):
+ backing = self.get_transport()
+ repo = self.make_repository('.')
+ self.addCleanup(repo.lock_write().unlock)
+ # lock_write() doesn't necessarily actually take a physical
+ # lock out.
+ if repo.get_physical_lock_status():
+ expected = 'yes'
+ else:
+ expected = 'no'
+ request_class = smart_repo.SmartServerRepositoryGetPhysicalLockStatus
+ request = request_class(backing)
+ self.assertEqual(smart_req.SuccessfulSmartServerResponse((expected,)),
+ request.execute('', ))
+
+ def test_without_write_lock(self):
+ backing = self.get_transport()
+ repo = self.make_repository('.')
+ self.assertEquals(False, repo.get_physical_lock_status())
+ request_class = smart_repo.SmartServerRepositoryGetPhysicalLockStatus
+ request = request_class(backing)
+ self.assertEqual(smart_req.SuccessfulSmartServerResponse(('no',)),
+ request.execute('', ))
+
+
class TestSmartServerIsReadonly(tests.TestCaseWithMemoryTransport):
def test_is_readonly_no(self):
@@ -2170,6 +2226,8 @@
smart_branch.SmartServerBranchPutConfigFile)
self.assertHandlerEqual('Branch.get_parent',
smart_branch.SmartServerBranchGetParent)
+ self.assertHandlerEqual('Branch.get_physical_lock_status',
+ smart_branch.SmartServerBranchRequestGetPhysicalLockStatus)
self.assertHandlerEqual('Branch.get_tags_bytes',
smart_branch.SmartServerBranchGetTagsBytes)
self.assertHandlerEqual('Branch.lock_write',
@@ -2222,6 +2280,8 @@
smart_repo.SmartServerRepositoryGatherStats)
self.assertHandlerEqual('Repository.get_parent_map',
smart_repo.SmartServerRepositoryGetParentMap)
+ self.assertHandlerEqual('Repository.get_physical_lock_status',
+ smart_repo.SmartServerRepositoryGetPhysicalLockStatus)
self.assertHandlerEqual('Repository.get_rev_id_for_revno',
smart_repo.SmartServerRepositoryGetRevIdForRevno)
self.assertHandlerEqual('Repository.get_revision_graph',
=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt 2011-11-25 14:47:49 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt 2011-11-25 15:10:43 +0000
@@ -107,10 +107,12 @@
* New HPSS calls ``Repository.has_signature_for_revision_id``,
``Repository.make_working_trees``, ``BzrDir.destroy_repository``,
- ``BzrDir.has_workingtree``, ``Branch.put_config_file``,
- ``Repository.all_revision_ids``, ``BzrDir.destroy_branch``.
- ``Branch.break_lock``, ``Repository.break_lock`` and
- ``VersionedFileRepository.get_serializer_format``.
+ ``BzrDir.has_workingtree``, ``Repository.get_physical_lock_status``,
+ ``Branch.get_physical_lock_status``,
+ ``Branch.put_config_file``, ``Branch.break_lock``,
+ ``BzrDir.destroy_branch``, ``Repository.break_lock``,
+ ``VersionedFileRepository.get_serializer_format`` and
+ ``Repository.all_revision_ids``.
(Jelmer Vernooij)
* Custom HPSS error handlers can now be installed in the smart server client
More information about the bazaar-commits
mailing list