Proof of concept: bzr over RPC
Lalo Martins
lalo.martins at gmail.com
Mon Aug 28 12:29:44 BST 2006
http://pyro.sourceforge.net/ is a pretty nice Python RPC/remote object
library. I've been toying for over an year with trying bzr over some sort
of rpc, and today I decided to actually take a look at it.
So what I can do right now is obtain a proxy for a remote Branch,
WorkingTree, or Repository (adding more classes is trivial if necessary).
These proxies can execute methods on the remote object, and read
attributes. Note this is only a proof of concept; notably, any method
that returns a non-builtin object will instead return a deep copy (for
example, get_inventory()); this mostly works, but there will probably be
issues at some point.
How to play with it:
1. Install Pyro from the url above.
2. Get bzrpserver.py and bzrpclient.py from
http://lalo.revisioncontrol.net/bzr/bzrpc/
3. Create a config file at (by default) ~/.bazaar/bzrpc-exports.conf
listing the locations you want to expose. The format is very simple
(because I don't expect this file to stick around): each line that doesn't
start with '#' and that contains a ':' is a name, path pair. Leading and
trailing whitespace is stripped from both. You can list branches, trees,
shared repositories, or even directories containing any of those.
4. Run bzrpserver.py
5. Start the interactive interpreter so that bzrpclient.py is in your
path. Now you can do something like:
>>> import bzrpcclient
>>> server = bzrpclient.get_server('localhost')
>>> server.get_exports()
['powerchick.dev', 'cfmaps', 'vos']
>>> powerchick_tree = server.get_workingtree('powerchick.dev')
>>> vos_repo = server.get_repository('vos')
>>> myvos = server.get_branch('vos/vos.lalo')
So get_server gets a hostname and optional port; you can try running
bzrpserver in a different machine. The get_$CLASS methods take a path,
where the "root" is the export name, and the remainder is a subpath
from the path corresponding to the export (so that you can access branches
inside a repository, as in the last example).
My idea is to whip up a transport, which uses a url looking like
bzrpc://localhost/vos/vos.lalo for the last example above.
Of course there's no reason to believe this will be fast or useful until
it's working. But what the heck, it's fun. ;-)
Sample bzrpc-exports.conf:
cfmaps: /usr/local/share/crossfire/maps
powerchick.dev: /repo/src/powerchick.dev
vos: /repo/src/vos
best,
Lalo Martins
--
So many of our dreams at first seem impossible,
then they seem improbable, and then, when we
summon the will, they soon become inevitable.
--
personal: http://www.laranja.org/
technical: http://lalo.revisioncontrol.net/
GNU: never give up freedom http://www.gnu.org/
More information about the bazaar
mailing list