[MERGE/RFC] Add support for Launchpad API to plugin, including 'mirror branch now' command

Vincent Ladeuil v.ladeuil+lp at free.fr
Thu Jul 9 08:56:29 BST 2009


>>>>> "jml" == Jonathan Lange <jml at mumak.net> writes:

    jml> On Sat, Jul 4, 2009 at 11:19 AM, Jonathan Lange<jml at mumak.net> wrote:
    >> Hello all,
    >> 
    >> Attached is a bundle that adds a command 'lp-mirror' to Bazaar, that
    >> requests the branch be mirrored instantly.

Yummy, that could certainly help a lot with our merge proposals
madnesses...

    >> 
    >> It also adds a simple wrapper API for the Launchpad API, encapsulating
    >> the two major operations I think we'll need:
    >>  1. Log in to the Launchpad REST service
    >>  2. A function, load_branch, to get a Launchpad branch object based
    >> on a Bazaar branch
    >> 
    >> The load_branch function kind of sucks, because Launchpad doesn't
    >> provide a way of getting a branch based on a URL. I've filed this as
    >> bug 395076 and will start fixing that bug asap.
    >> 
    >> The bundle is missing:
    >>  - a way to 'logout', or rather to invalidate the cached login data
    >>  - tests

right, so BB:reject :0D

Kidding,
BB:comment only as that is what you think to be asking for.

...
    jml> === modified file 'bzrlib/plugins/launchpad/__init__.py'
    jml> --- bzrlib/plugins/launchpad/__init__.py	2009-06-19 15:10:17 +0000
    jml> +++ bzrlib/plugins/launchpad/__init__.py	2009-07-04 09:29:51 +0000
    jml> @@ -48,6 +48,11 @@
    jml>      NotLaunchpadBranch,
    jml>      )
 
    jml> +try:
    jml> +    from bzrlib.plugins.launchpad import lp_api
    jml> +except ImportError:
    jml> +    lp_api = None
    jml> +
 

Right, so it seems my tests stop right there :-/

I installed launchpadlib at first, ok, I had to do that for a
while anyway, 'httplib2', why not and then 'lazr' caught my eye,
but setting a breakpoint in the except clause above told me that
the next missing one was 'oauth.oauth'.

A bit too much :-/

Can you clarify the dependencies ?
 
    jml> +class cmd_launchpad_mirror(Command):
    jml> +    """Ask Launchpad to mirror a branch now."""
    jml> +
    jml> +    aliases = ['lp-mirror']
    jml> +    takes_args = ['location?']
    jml> +
    jml> +    def run(self, location='.'):
    jml> +        service = LaunchpadService()
    jml> +        launchpad = lp_api.login(service)
    jml> +        branch = _mod_branch.Branch.open(location)
    jml> +        lp_branch = lp_api.load_branch(launchpad, branch)
    jml> +        lp_branch.requestMirror()

Hmm, without testing I'm not sure about what the default will be,
but I'm pretty sure I will prefer to rely on a branch.conf
variable (that can be overridden in from location.conf, etc, as
usual).

    jml> === added file 'bzrlib/plugins/launchpad/lp_api.py'

    jml> +from lazr.uri import URI

What's that ?

And just a general remark, we differ from the launchpad project
coding rules here, I think, in that we prefer to use:

  from lazr import uri

and then

  uri.URI

    jml> +def _get_api_url(service):

    jml> +def _get_credential_path(service):

    jml> +def login(service, timeout=None, proxy_info=None):

Not a lot to say here, I can't see how to integrate that scheme
into our existing credentials handling, which is sad :-/

Or is it done upper in the stack (after all I'm connecting to
launchpad almost every minute and all I have a section in
authentication.conf mentioning my launchpad ID...).

    jml> +def load_branch(launchpad, branch):
    jml> +    """Return the launchpadlib Branch object corresponding to 'branch'.
    jml> +
    jml> +    :param launchpad: The root `Launchpad` object from launchpadlib.
    jml> +    :param branch: A `bzrlib.branch.Branch`.
    jml> +    :raise NotLaunchpadBranch: If we cannot determine the Launchpad URL of
    jml> +        `branch`.
    jml> +    :return: A launchpadlib Branch object.
    jml> +    """


As far as API is concerned, I'd feel better if I could just
provide a lp URL and get back a http or bzr+ssh URL.



More information about the bazaar mailing list