Custom HPSS request handlers?
John Arbash Meinel
john at arbash-meinel.com
Wed Jan 21 17:07:14 GMT 2009
-----BEGIN PGP SIGNED MESSAGE-----
Russ Brown wrote:
> I'm wondering if it is possible to define a custom HPPS request in a
> plugin on the server, and make that request from a plugin at the client end.
> The specific use case is that we have a number of repositories contain a
> number of branches, and want to to be able to find out which are
> candidates for removal. For the purposes of this utility, removable
> branches are defined as containing no revisions that are not already
> merged into the trunk branch in the same repository.
> I have working code that does this already: the problem is that it is
> extremely slow. So, I'm thinking that if I could write something that
> would do the server-side trawling completely at the server side that
> just returned the results to the client, that would speed up the
> operation considerably.
> So, is it possible to do this in a plugin, and if so, could someone
> point me at an example of this that I can work from?
> Much appreciated,
On the server side you would need to register the RPC in
And then on the client side, I would assume you are adding a new command
object (registered via bzrlib.commands.register_command)
Which can then make the request. There is a helper class in
bzrlib.remote._RpcHelper, which provides a '_call()' function which
could be useful for you.
In general, I would imagine the client plugin would look roughly like:
from bzrlib import commands, errors
"""Run the xxx command on the remote machine."""
takes_args = ['location']
def run(self, location):
from bzrlib import bzrdir, remote
remote_bzrdir = bzrdir.BzrDir.open(location)
if not isinstance(remote_bzrdir, remote.RemoteBzrDir):
raise errors.BzrCommandError('Not a remote location:'
' %s' % (location,))
response = remote_bzrdir._call_with_body_bytes("MyCustomRPC",
response_tuple, response_handler = response
if response_tuple != 'ok':
# Request failed
body = response_handler.read_body_bytes()
# Parse the body bytes into whatever you need
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
More information about the bazaar