Is there a bzr command to see all branches of a project on Launchpad?

Solution 1:

I don't know of any bzr command that does this, but it's actually very easy to script using the Launchpad python API. For instance:

#!/usr/bin/env python
import os, sys
from launchpadlib.launchpad import Launchpad

cachedir = os.path.expanduser("~/.launchpadlib/cache/")
launchpad = Launchpad.login_anonymously('find_branches',
                                        'production',
                                        cachedir)

try:
    project = launchpad.projects[sys.argv[1]]
    for b in project.getBranches():
        if b.lifecycle_status not in ["Abandoned", "Merged"]:
            print b.bzr_identity
except KeyError:
    print "Project unknown... \nUsage: " + sys.argv[0] + " lp_project_name"

So with python find_branches.py deluge we get:

lp:deluge
lp:~vcs-imports/deluge/trunk
lp:~mvoncken/deluge/ajax-template-dev
lp:~deluge-team/deluge/master
lp:~shaohao/deluge/0.9
lp:~damoxc/deluge/master

You can run wild with it and do things like sort by date_created, date_last_modified, or create your own heuristic for what branches are interesting to you. See:

https://launchpad.net/+apidoc/1.0.html#branch

Solution 2:

Bazaar is a version control system no more then that, completely separate project from Launchpad.

It is possible to parse directly the project branches HTML page or its Atom news feed.

  1. Declare a shell function:

    lslp() {
        wget -q -O - http://feeds.launchpad.net/$1/branches.atom | xml2 | grep "/feed/entry/title=" | cut -c 19-;
    }
    
    • wget -q -O - http://feeds.launchpad.net/projectname/branches.atom

      get branches news feed (Atom xml)

    • xml2

      convert XML document to a flat format

    • grep "/feed/entry/title="

      filter out lines with "/feed/entry/title=", XML nodes that contain branch name

    • cut -c 19-

      remove "/feed/entry/title=" from result lines.

  2. Example:

    $ lslp deluge
    lp:deluge
    lp:~vcs-imports/deluge/trunk
    lp:~damoxc/deluge/master
    lp:~deluge-team/deluge/master
    lp:~shaohao/deluge/0.9
    lp:~mvoncken/deluge/ajax-template-dev