unselect: support the --cleanup flag to include all obsolete requests.

This commit is contained in:
Jimmy Berry 2017-03-18 17:45:53 -05:00
parent 3505736fe0
commit 94a4629d2c
2 changed files with 12 additions and 4 deletions

View File

@ -207,6 +207,8 @@ def do_staging(self, subcmd, opts, *args):
"unselect" will remove from the project - pushing them back to the backlog
If a message is included the requests will be ignored first.
Use the --cleanup flag to include all obsolete requests.
"unlock" will remove the staging lock in case it gets stuck
"rebuild" will rebuild broken packages in the given stagings or all
@ -234,7 +236,7 @@ def do_staging(self, subcmd, opts, *args):
[--filter-by...] [--group-by...]
[--merge] [--try-strategies] [--strategy]
[STAGING...] [REQUEST...]
osc staging unselect [-m MESSAGE] REQUEST...
osc staging unselect [--cleanup] [-m MESSAGE] [REQUEST...]
osc staging unlock
osc staging rebuild [--force] [STAGING...]
osc staging repair REQUEST...
@ -258,7 +260,7 @@ def do_staging(self, subcmd, opts, *args):
elif cmd == 'select':
min_args, max_args = 0, None
elif cmd == 'unselect':
min_args, max_args = 1, None
min_args, max_args = 0, None
elif cmd == 'adi':
min_args, max_args = 0, None
elif cmd == 'ignore':
@ -350,7 +352,7 @@ def do_staging(self, subcmd, opts, *args):
if opts.message:
print('Ignoring requests first')
IgnoreCommand(api).perform(args[1:], opts.message)
UnselectCommand(api).perform(args[1:])
UnselectCommand(api).perform(args[1:], opts.cleanup)
elif cmd == 'select':
# Include list of all stagings in short-hand and by full name.
existing_stagings = api.get_staging_projects_short(None)

View File

@ -7,12 +7,18 @@ class UnselectCommand(object):
def __init__(self, api):
self.api = api
def perform(self, packages):
def perform(self, packages, cleanup=False):
"""
Remove request from staging project
:param packages: packages/requests to delete from staging projects
"""
if cleanup:
obsolete = self.api.project_status_requests('obsolete')
if len(obsolete) > 0:
print('Cleanup {} obsolete requests'.format(len(obsolete)))
packages += tuple(obsolete)
ignored_requests = self.api.get_ignored_requests()
affected_projects = set()
for request, request_project in RequestFinder.find_staged_sr(packages,