bzrlib and branch discovery

John Arbash Meinel john at arbash-meinel.com
Sun Aug 8 19:37:57 BST 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Gabriel Filion wrote:
> Hi,
> 
> I'm trying my luck on using bzrlib to discover bazaar branches so that I
> can interact with them.
> 
> In a shared repository setup as in Launchpad-hosted projects, is it
> possible to obtain a list of available branches, either using a bzr
> command, or by directly calling a function from bzrlib? The particular
> information I need is a list of branches and their last revision.
> 
> I've tried my luck with the above question this week (with help from
> people on IRC), and so far I found that 'd =
> BzrDir.open_containing(some_url)' followed by
> 'd.find_branches(d.root_transport)' would logically get what I wanted.
> But it spits out an exception saying that the HTTP transport doesn't
> support list_dir().
> 
> Is branch discovery possible at all with repositories hosted via http?
> 

It sort of depends what you want to discover.

If what you want is all branches of a given project that are in
Launchpad, then your best bet is to go via the api (launchpadlib).
Specifically, all branches are of the form:

 ~user/project/branch-name

As such, any recursion you would do would be very inefficient, since you
have to potentially check all possible ~user entries to find out if any
of them had a branch of a given project.

There is the 'launchpadlib' python library that helps interact with
launchpad. There is also 'hydrazine' which is some work by Martin Pool
to make it a little bit easier to interact with launchpadlib.

Anyway, my quick run is:

import hydrazine
lp = hydrazine.create_session()
bzr = lp.projects['bzr']
branches = bzr.getBranches()
for b in branches:
  # What do you want to know?
  # b.url? (some of these are None, I don't know why)
  # b.name
  # b.project_link
  # b.owner_link
  # b.lifecycle_status # Merged/Abandoned/etc
  # etc

And this should perform efficiently, since the data is partitioned
appropriately.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkxe+YUACgkQJdeBCYSNAAPH1ACfXpMMy9+Ms+jAAvyahAwsasaZ
PtkAnRdcLKlheFqdc7wMcWtYfqfCNWkw
=UrBj
-----END PGP SIGNATURE-----



More information about the bazaar mailing list