Update get-branches to account for changes in LP's web UI. Really, someone should update it to use the LP API, but for now, this will have to do.

This commit is contained in:
Soren Hansen 2010-04-08 09:55:27 -05:00
parent 0ee66adc16
commit 853f0275a6

View File

@ -38,7 +38,7 @@ def main():
# Our options.
optParser.add_option("-d", "--directory", action = "store", type = "string",
dest = "directory", default = ".",
dest = "directory", default = os.getcwd(),
help = "Directory to download branches to.")
optParser.add_option("-t", "--team", action = "store", type = "string",
dest = "lpteam", help = "Launchpad team to download branches from.")
@ -92,7 +92,7 @@ def main():
branch_list_page = sock.read()
sock.close()
branch_page_urls_regex = r'.*<a href="/(~%s/.*)".*' % team
branch_page_urls_regex = r'.*href="/(~%s/.*)">lp:.*' % team
branch_page_urls = re.findall(branch_page_urls_regex, branch_list_page)
# Check the team actually has branches.
@ -114,25 +114,28 @@ def main():
sock = urllib2.urlopen("https://code.launchpad.net/%s" % url)
branch_page = sock.read()
sock.close()
branch_url_regex = r'<tt>bzr branch lp:~(.*)</tt>'
branch_url_regex = r'<dd>bzr branch <span.*>lp:(.*)</span></dd>'
branch_url = re.findall(branch_url_regex, branch_page)
print "Downloading branch: lp:~%s." % branch_url[0]
if branch_url[0]:
product = branch_url[0].split("/")[-2]
branch_nick = branch_url[0].split("/")[-1]
print "Downloading branch: lp:%s (%s)." % (branch_url[0], url)
product = url.split("/")[-2]
branch_nick = url.split("/")[-1]
else:
continue
if not os.path.exists(product):
os.makedirs(product)
os.chdir(product)
print branch_nick, product, os.getcwd()
if not os.path.exists(product):
os.makedirs(product)
os.chdir(product)
if not os.path.exists(branch_nick):
subprocess.call(["bzr", operation_type, "lp:~%s" % branch_url[0]])
subprocess.call(["bzr", operation_type, "lp:%s" % url])
else:
os.chdir(branch_nick)
subprocess.call(["bzr", "merge", "--pull", "--remember"])
os.chdir(os.path.join(directory, team))
os.chdir(os.path.join(directory, team))
os.chdir(pwd)
sys.exit(0)