mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
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:
parent
0ee66adc16
commit
853f0275a6
27
get-branches
27
get-branches
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user