Custom HPSS request handlers?

John Arbash Meinel john at
Wed Jan 21 17:07:14 GMT 2009

Hash: SHA1

Russ Brown wrote:
> Hi,
> 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

class cmd_xxx(commands.Command):
    """Run the xxx command on the remote machine."""

    takes_args = ['location']

    def run(self, location):
	from bzrlib import bzrdir, remote
        remote_bzrdir =
        if not isinstance(remote_bzrdir, remote.RemoteBzrDir):
	    raise errors.BzrCommandError('Not a remote location:'
		' %s' % (location,))
        response = remote_bzrdir._call_with_body_bytes("MyCustomRPC",
			arg1, foo='bar')
	response_tuple, response_handler = response
	if response_tuple[0] != 'ok':
	  # Request failed
	  return 1
	body = response_handler.read_body_bytes()
	# Parse the body bytes into whatever you need


Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla -


More information about the bazaar mailing list