[wishlist] add function to extract project name from parent URL of LP-hosted branches
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Bazaar |
Confirmed
|
Wishlist
|
Unassigned |
Bug Description
In QBzr we have the code to create suggestion for new push URL for feature branches. To create a suggestion we analyze the parent branch of the parent branch of the current branch which is about to push the first time (without remembered push location). We have a generic code for remote branches (just replace the last part of parent URL with new branch directory name). Also we have a specific support for LP-hosted branches because we want to suggest new push location as lp:~user-id/project/new-branch. That's worked well in the past but last months LP has switched to use +branch URL aliases, and it breaks the QBzr code.
Thanks to John Meinel and Max Bowsher I've fixed the code to extract the project name from URL, but I wonder if such code would be better keep in the launchpad plugin bundled with bzr itself, so this logic will be updated every time the LP support changed? Although the only one client for that code today is QBzr. I'm not sure how to ensure this code will be changed when lp_directory.py will be changed?
Below is my code and test:
def launchpad_
"""If url is a Launchpad code URL, get the project name.
@return: project name or None
"""
# The format ought to be one of the following:
# scheme:
# scheme:
# scheme:
# there could be distro branches, they are very complex,
# so we only support upstream branches based on source package
# scheme:
# scheme:
# scheme:
# scheme:
DISTROS = ('debian', 'ubuntu')
from urlparse import urlsplit
scheme, host, path = urlsplit(url)[:3]
# Sanity check the host
if (host in ('bazaar.
parts = path.strip(
if parts[0]
if len(parts) == 3 and parts[1] not in DISTROS:
# scheme:
elif len(parts) == 5 and parts[1] in DISTROS:
# scheme:
elif parts[0] in ('%2Bbranch', '+branch'):
n = len(parts)
if n >= 2:
if n in (2,3) and part1 not in DISTROS:
return None
def test_launchpad_
fut = util.launchpad_
# classic
# lp:qbzr
# lp:qbzr/0.20
# lp:ubuntu/qbzr
# lp:ubuntu/natty/qbzr
# lp:ubuntu/natty-proposed/qbzr
# lp:~someone/ubuntu/maverick/qbzr/sru
Changed in bzr: | |
status: | New → Confirmed |
importance: | Undecided → Wishlist |
tags: | added: check-for-breezy |
If it were to be put somewhere more general, like the bzr launchpad plugin, it would first need to support package branches better.