Rev 6299: (jelmer) Add HPSS call for ``Repository.destroy_branch``. (Jelmer Vernooij) in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Nov 25 14:47:51 UTC 2011
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6299 [merge]
revision-id: pqm at pqm.ubuntu.com-20111125144749-spezm225qcymzqpn
parent: pqm at pqm.ubuntu.com-20111125142243-y4j74jb7phvc25vz
parent: jelmer at samba.org-20111125135056-9l6isjww24278uv5
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2011-11-25 14:47:49 +0000
message:
(jelmer) Add HPSS call for ``Repository.destroy_branch``. (Jelmer Vernooij)
modified:
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_rmbranch.py test_rmbranch.py-20100131150653-auenl06hu4y2d9tr-1
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:22:43 +0000
+++ b/bzrlib/remote.py 2011-11-25 14:47:49 +0000
@@ -579,9 +579,21 @@
def destroy_branch(self, name=None):
"""See BzrDir.destroy_branch"""
- self._ensure_real()
- self._real_bzrdir.destroy_branch(name=name)
+ path = self._path_for_remote_call(self._client)
+ try:
+ if name is not None:
+ args = (name, )
+ else:
+ args = ()
+ response = self._call('BzrDir.destroy_branch', path, *args)
+ except errors.UnknownSmartMethod:
+ self._ensure_real()
+ self._real_bzrdir.destroy_branch(name=name)
+ self._next_open_branch_result = None
+ return
self._next_open_branch_result = None
+ if response[0] != 'ok':
+ raise SmartProtocolError('unexpected response code %s' % (response,))
def create_workingtree(self, revision_id=None, from_branch=None,
accelerator_tree=None, hardlink=False):
=== modified file 'bzrlib/smart/bzrdir.py'
--- a/bzrlib/smart/bzrdir.py 2011-11-18 14:37:41 +0000
+++ b/bzrlib/smart/bzrdir.py 2011-11-21 14:44:03 +0000
@@ -120,6 +120,21 @@
return '/'.join(segments)
+class SmartServerBzrDirRequestDestroyBranch(SmartServerRequestBzrDir):
+
+ def do_bzrdir_request(self, name=None):
+ """Destroy the branch with the specified name.
+
+ New in 2.5.0.
+ :return: On success, 'ok'.
+ """
+ try:
+ self._bzrdir.destroy_branch(name)
+ except errors.NotBranchError, e:
+ return FailedSmartServerResponse(('nobranch',))
+ return SuccessfulSmartServerResponse(('ok',))
+
+
class SmartServerBzrDirRequestHasWorkingTree(SmartServerRequestBzrDir):
def do_bzrdir_request(self, name=None):
=== modified file 'bzrlib/smart/request.py'
--- a/bzrlib/smart/request.py 2011-11-25 14:22:43 +0000
+++ b/bzrlib/smart/request.py 2011-11-25 14:47:49 +0000
@@ -563,12 +563,15 @@
'BzrDir.get_config_file', 'bzrlib.smart.bzrdir',
'SmartServerBzrDirRequestConfigFile')
request_handlers.register_lazy(
+ 'BzrDir.destroy_branch', 'bzrlib.smart.bzrdir',
+ 'SmartServerBzrDirRequestDestroyBranch')
+request_handlers.register_lazy(
+ 'BzrDir.destroy_repository', 'bzrlib.smart.bzrdir',
+ 'SmartServerBzrDirRequestDestroyRepository')
+request_handlers.register_lazy(
'BzrDir.has_workingtree', 'bzrlib.smart.bzrdir',
'SmartServerBzrDirRequestHasWorkingTree')
request_handlers.register_lazy(
- 'BzrDir.destroy_repository', 'bzrlib.smart.bzrdir',
- 'SmartServerBzrDirRequestDestroyRepository')
-request_handlers.register_lazy(
'BzrDirFormat.initialize', 'bzrlib.smart.bzrdir',
'SmartServerRequestInitializeBzrDir')
request_handlers.register_lazy(
=== modified file 'bzrlib/tests/blackbox/test_rmbranch.py'
--- a/bzrlib/tests/blackbox/test_rmbranch.py 2011-11-24 12:11:56 +0000
+++ b/bzrlib/tests/blackbox/test_rmbranch.py 2011-11-25 12:16:12 +0000
@@ -82,4 +82,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(18, self.hpss_calls)
+ self.assertLength(5, self.hpss_calls)
=== modified file 'bzrlib/tests/test_remote.py'
--- a/bzrlib/tests/test_remote.py 2011-11-25 14:22:43 +0000
+++ b/bzrlib/tests/test_remote.py 2011-11-25 14:47:49 +0000
@@ -485,6 +485,33 @@
self.assertFinished(client)
+class TestBzrDirDestroyBranch(TestRemote):
+
+ def test_destroy_default(self):
+ transport = self.get_transport('quack')
+ referenced = self.make_branch('referenced')
+ client = FakeClient(transport.base)
+ client.add_expected_call(
+ 'BzrDir.destroy_branch', ('quack/', ),
+ 'success', ('ok',)),
+ a_bzrdir = RemoteBzrDir(transport, RemoteBzrDirFormat(),
+ _client=client)
+ a_bzrdir.destroy_branch()
+ self.assertFinished(client)
+
+ def test_destroy_named(self):
+ transport = self.get_transport('quack')
+ referenced = self.make_branch('referenced')
+ client = FakeClient(transport.base)
+ client.add_expected_call(
+ 'BzrDir.destroy_branch', ('quack/', "foo"),
+ 'success', ('ok',)),
+ a_bzrdir = RemoteBzrDir(transport, RemoteBzrDirFormat(),
+ _client=client)
+ a_bzrdir.destroy_branch("foo")
+ self.assertFinished(client)
+
+
class TestBzrDirHasWorkingTree(TestRemote):
def test_has_workingtree(self):
=== modified file 'bzrlib/tests/test_smart.py'
--- a/bzrlib/tests/test_smart.py 2011-11-25 14:22:43 +0000
+++ b/bzrlib/tests/test_smart.py 2011-11-25 14:47:49 +0000
@@ -222,6 +222,39 @@
self.assertEqual(expected, request.execute('', 'False'))
+class TestSmartServerBzrDirRequestDestroyBranch(
+ tests.TestCaseWithMemoryTransport):
+ """Tests for BzrDir.destroy_branch."""
+
+ def test_destroy_branch_default(self):
+ """The default branch can be removed."""
+ backing = self.get_transport()
+ dir = self.make_branch('.').bzrdir
+ request_class = smart_dir.SmartServerBzrDirRequestDestroyBranch
+ request = request_class(backing)
+ expected = smart_req.SuccessfulSmartServerResponse(('ok',))
+ self.assertEqual(expected, request.execute('', None))
+
+ def test_destroy_branch_named(self):
+ """A named branch can be removed."""
+ backing = self.get_transport()
+ dir = self.make_repository('.', format="development-colo").bzrdir
+ dir.create_branch(name="branchname")
+ request_class = smart_dir.SmartServerBzrDirRequestDestroyBranch
+ request = request_class(backing)
+ expected = smart_req.SuccessfulSmartServerResponse(('ok',))
+ self.assertEqual(expected, request.execute('', "branchname"))
+
+ def test_destroy_branch_missing(self):
+ """An error is raised if the branch didn't exist."""
+ backing = self.get_transport()
+ dir = self.make_bzrdir('.', format="development-colo")
+ request_class = smart_dir.SmartServerBzrDirRequestDestroyBranch
+ request = request_class(backing)
+ expected = smart_req.FailedSmartServerResponse(('nobranch',), None)
+ self.assertEqual(expected, request.execute('', "branchname"))
+
+
class TestSmartServerBzrDirRequestHasWorkingTree(
tests.TestCaseWithTransport):
"""Tests for BzrDir.has_workingtree."""
@@ -2159,6 +2192,8 @@
smart_branch.SmartServerBranchRequestSetParentLocation)
self.assertHandlerEqual('Branch.unlock',
smart_branch.SmartServerBranchRequestUnlock)
+ self.assertHandlerEqual('BzrDir.destroy_branch',
+ smart_dir.SmartServerBzrDirRequestDestroyBranch)
self.assertHandlerEqual('BzrDir.find_repository',
smart_dir.SmartServerRequestFindRepositoryV1)
self.assertHandlerEqual('BzrDir.find_repositoryV2',
=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt 2011-11-25 14:22:43 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt 2011-11-25 14:47:49 +0000
@@ -108,9 +108,9 @@
* New HPSS calls ``Repository.has_signature_for_revision_id``,
``Repository.make_working_trees``, ``BzrDir.destroy_repository``,
``BzrDir.has_workingtree``, ``Branch.put_config_file``,
- ``Branch.break_lock``, ``Repository.break_lock``,
+ ``Repository.all_revision_ids``, ``BzrDir.destroy_branch``.
+ ``Branch.break_lock``, ``Repository.break_lock`` and
``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