mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-07-23 12:51:29 +00:00
sponsor_patch.py: Refactor long function.
This commit is contained in:
parent
0c8520ee8c
commit
39e6306364
@ -94,6 +94,40 @@ def ask_for_manual_fixing():
|
|||||||
if answer == "no":
|
if answer == "no":
|
||||||
user_abort()
|
user_abort()
|
||||||
|
|
||||||
|
def ask_for_patch_or_branch(bug, attached_patches, linked_branches):
|
||||||
|
patch = None
|
||||||
|
branch = None
|
||||||
|
if len(attached_patches) == 0:
|
||||||
|
msg = "https://launchpad.net/bugs/%i has %i branches linked:" % \
|
||||||
|
(bug.id, len(linked_branches))
|
||||||
|
elif len(linked_branches) == 0:
|
||||||
|
msg = "https://launchpad.net/bugs/%i has %i patches attached:" % \
|
||||||
|
(bug.id, len(attached_patches))
|
||||||
|
else:
|
||||||
|
branches = "%i branch" % len(linked_branches)
|
||||||
|
if len(linked_branches) > 1:
|
||||||
|
branches += "es"
|
||||||
|
patches = "%i patch" % len(attached_patches)
|
||||||
|
if len(attached_patches) > 1:
|
||||||
|
patches += "es"
|
||||||
|
msg = "https://launchpad.net/bugs/%i has %s linked and %s attached:" % \
|
||||||
|
(bug.id, branches, patches)
|
||||||
|
Logger.normal(msg)
|
||||||
|
i = 0
|
||||||
|
for linked_branch in linked_branches:
|
||||||
|
i += 1
|
||||||
|
print "%i) %s" % (i, linked_branch.display_name)
|
||||||
|
for attached_patch in attached_patches:
|
||||||
|
i += 1
|
||||||
|
print "%i) %s" % (i, attached_patch.title)
|
||||||
|
selected = input_number("Which branch or patch do you want to download",
|
||||||
|
1, i, i)
|
||||||
|
if selected <= len(linked_branches):
|
||||||
|
branch = linked_branches[selected - 1].bzr_identity
|
||||||
|
else:
|
||||||
|
patch = attached_patches[selected - len(linked_branches) - 1]
|
||||||
|
return (patch, branch)
|
||||||
|
|
||||||
def get_patch_or_branch(bug):
|
def get_patch_or_branch(bug):
|
||||||
patch = None
|
patch = None
|
||||||
branch = None
|
branch = None
|
||||||
@ -113,30 +147,8 @@ def get_patch_or_branch(bug):
|
|||||||
elif len(attached_patches) == 0 and len(linked_branches) == 1:
|
elif len(attached_patches) == 0 and len(linked_branches) == 1:
|
||||||
branch = linked_branches[0].bzr_identity
|
branch = linked_branches[0].bzr_identity
|
||||||
else:
|
else:
|
||||||
if len(attached_patches) == 0:
|
patch, branch = ask_for_patch_or_branch(bug, attached_patches,
|
||||||
msg = "https://launchpad.net/bugs/%i has %i branches linked:" % \
|
linked_branches)
|
||||||
(bug.id, len(linked_branches))
|
|
||||||
elif len(linked_branches) == 0:
|
|
||||||
msg = "https://launchpad.net/bugs/%i has %i patches attached:" % \
|
|
||||||
(bug.id, len(attached_patches))
|
|
||||||
else:
|
|
||||||
msg = ("https://launchpad.net/bugs/%i has %i branch(es) linked and "
|
|
||||||
"%i patch(es) attached:") % (bug.id, len(linked_branches),
|
|
||||||
len(attached_patches))
|
|
||||||
Logger.normal(msg)
|
|
||||||
i = 0
|
|
||||||
for linked_branch in linked_branches:
|
|
||||||
i += 1
|
|
||||||
print "%i) %s" % (i, linked_branch.display_name)
|
|
||||||
for attached_patch in attached_patches:
|
|
||||||
i += 1
|
|
||||||
print "%i) %s" % (i, attached_patch.title)
|
|
||||||
selected = input_number("Which branch or patch do you want to download",
|
|
||||||
1, i, i)
|
|
||||||
if selected <= len(linked_branches):
|
|
||||||
branch = linked_branches[selected - 1].bzr_identity
|
|
||||||
else:
|
|
||||||
patch = attached_patches[selected - len(linked_branches) - 1]
|
|
||||||
return (patch, branch)
|
return (patch, branch)
|
||||||
|
|
||||||
def download_patch(patch):
|
def download_patch(patch):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user