[MERGE] Command for opening Launchpad pages for Launchpad branches

John Arbash Meinel john at arbash-meinel.com
Mon Jan 26 16:02:22 GMT 2009


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

Jonathan Lange wrote:
> On Sat, Jan 24, 2009 at 5:15 PM, John Arbash Meinel  wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
> 
>> Jonathan Lange wrote:
>>> Hello Bazaaros,
>>>
>>> A lot of the time, I want to open the Launchpad web page for a branch
>>> that I'm working on. The way I normally do it is by opening up the
>>> Code tab for whatever project I'm working on, then finding it in the
>>> listing. This is a bit of a pain, so I decided to teach my computer
>>> how to do it for me.
>>>
>>> I thought a bit about just opening the public location in the web
>>> browser, since that might well work for non-Launchpad branches. I
>>> decided not to for two reasons:
>>>     1. Many of my branches have a bzr+ssh:// URL as their public location.
>>>     2. That would take me to Launchpad's loggerhead page for that
>>> branch. I actually want to go to the main branch page (e.g.
>>> https://code.launchpad.net/~jml/testdoc/trunk).
>>>
>>> I still think that a command, similar to this one (perhaps called 'bzr
>>> open'), that opened the public location would be a good idea. It's
>>> just a good idea for another patch.
>>>
>>> The attached patch fiddles around with the LaunchpadService class so
>>> that it also has a get_web_url_for_branch_url() method. This might be
>>> pushing the class beyond it's original intent, but it seemed like the
>>> least wrong thing to do given the constraints.
>>>
>>> cheers,
>>> jml
>> +    def get_web_url_from_branch_url(self, branch_url):
>> +        """Get the Launchpad web URL for the given branch URL.
>> +
>> +        :raise errors.InvalidURL: if 'branch_url' cannot be identified as a
>> +            Launchpad branch URL.
>> +        :return: The URL of the branch on Launchpad.
>> +        """
>> +        scheme, hostinfo, path = urlsplit(branch_url)[:3]
>> +        if scheme != 'lp':
>> +            domains = ('bazaar.%s' % domain
>> +                       for domain in self.LAUNCHPAD_DOMAINS.itervalues())
>> +            if hostinfo not in domains:
>> +                raise NotLaunchpadBranch(branch_url)
>> +        return urlutils.join('https://code.%s' % self.domain, path)
> 
> 
>> ^- Does this work for stuff like "lp:bzr" or "lp:bzr/1.11" ? I'm not
>> sure about the specifics of code.launchpad.net, but I'm pretty sure it
>> wouldn't work for "lp:bzr/1.11".
> 
> 
> No it doesn't! Good catch. I've updated it to ask the Launchpad
> directory service to expand the lp:// URL.
> 
>> Otherwise this seems like a decent update to me.
> 
> 
> Thanks.
> 
>> BB:tweak
> 
>> I wonder if we wouldn't want "bzr lp-open --project" or something along
>> those lines.
> 
> 
> That's a good idea for a future patch.
> 
>> Also, for *my* branches, I think the public_location is ok, but the
>> push_location is also an lp url. Would we want to support checking that?
> 
> 
> Hmm. Good question. :)
> 
>> BB:tweak
> 
> 
> Here's the updated patch.
> 
> jml


BB:approve

Looks good to me.

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

iEYEARECAAYFAkl93o4ACgkQJdeBCYSNAAPw9wCgyq5cw8Hqv4oqXzGWFTq52R4Q
gAcAnjqF4UGfZ33xR6tAGOkntAJa7oKi
=Bs+e
-----END PGP SIGNATURE-----



More information about the bazaar mailing list