1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-09 22:36:14 +01:00

support list of open reviews

This commit is contained in:
Adrian Schröter 2010-07-29 13:45:44 +02:00
parent cff8696818
commit 753893222a
3 changed files with 56 additions and 10 deletions

1
NEWS
View File

@ -1,5 +1,6 @@
0.129
- "dists" command to show the configured default base repos from the server.
- "review list" command to list open review requests
#
# Feature which requires OBS 2.1
#

View File

@ -1438,7 +1438,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
@cmdln.option('-D', '--days', metavar='DAYS',
help='only list requests in state "new" or changed in the last DAYS. [default=%(request_list_days)s]')
@cmdln.option('-U', '--user', metavar='USER',
help='same as -M, but for the specified USER')
help='requests or reviews limited for the specified USER')
@cmdln.option('-G', '--group', metavar='GROUP',
help='requests or reviews limited for the specified GROUP')
@cmdln.option('-b', '--brief', action='store_true', default=False,
help='print output in list view as list subcommand')
@cmdln.option('-M', '--mine', action='store_true',
@ -1505,6 +1507,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
osc request revoke [-m TEXT] ID
osc request wipe ID
osc request checkout/co ID
osc review list [-U USER] [-G GROUP] [-s state]
osc review accept [-m TEXT] ID
osc review decline [-m TEXT] ID
osc review new [-m TEXT] ID # for setting a temporary comment without changing the state
@ -1575,12 +1578,17 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if cmd == 'list' or cmd == 'approvenew':
states = ('new', 'accepted', 'revoked', 'declined')
who = ''
group = opts.group
if cmd == 'approvenew':
states = ('new')
results = get_request_list(apiurl, project, package, '', ['new'])
else:
state_list = opts.state.split(',')
if opts.state == 'all':
if opts.all:
state_list = ['all']
if subcmd == 'review':
state_list = ['review']
elif opts.state == 'all':
state_list = ['all']
else:
for s in state_list:
@ -1590,21 +1598,23 @@ Please submit there instead, or use --nodevelproject to force direct submission.
who = conf.get_apiurl_usr(apiurl)
if opts.user:
who = opts.user
if opts.all:
state_list = ['all']
## FIXME -B not implemented!
if opts.bugowner:
if (self.options.debug):
print 'list: option --bugowner ignored: not impl.'
if opts.involved_projects:
who = who or conf.get_apiurl_usr(apiurl)
results = get_user_projpkgs_request_list(apiurl, who, req_state=state_list,
req_type=opts.type, exclude_projects=opts.exclude_target_project or [])
if subcmd == 'review':
# FIXME: do the review list for the user and for all groups he belong to
results = get_review_list(apiurl, project, package, who, opts.group, state_list)
else:
results = get_request_list(apiurl, project, package, who,
state_list, opts.type, opts.exclude_target_project or [])
if opts.involved_projects:
who = who or conf.get_apiurl_usr(apiurl)
results = get_user_projpkgs_request_list(apiurl, who, req_state=state_list,
req_type=opts.type, exclude_projects=opts.exclude_target_project or [])
else:
results = get_request_list(apiurl, project, package, who,
state_list, opts.type, opts.exclude_target_project or [])
results.sort(reverse=True)
import time

View File

@ -2813,6 +2813,41 @@ def change_request_state(apiurl, reqid, newstate, message='', supersed=''):
return f.read()
def get_review_list(apiurl, project='', package='', user='', group='', states=('new')):
xpath = ''
xpath = xpath_join(xpath, 'state/@name=\'review\'', inner=True)
if not 'all' in states:
for state in states:
xpath = xpath_join(xpath, 'review/@state=\'%s\'' % state, inner=True)
if user:
xpath = xpath_join(xpath, 'review/@by_user=\'%s\'\'' % user, op='and')
if group:
xpath = xpath_join(xpath, 'review/@by_group=\'%s\'\'' % group, op='and')
# XXX: we cannot use the '|' in the xpath expression because it is not supported
# in the backend
todo = {}
if project:
todo['project'] = project
if package:
todo['package'] = package
for kind, val in todo.iteritems():
xpath = xpath_join(xpath, '(action/target/@%(kind)s=\'%(val)s\' or ' \
'action/source/@%(kind)s=\'%(val)s\' or ' \
'submit/target/@%(kind)s=\'%(val)s\' or ' \
'submit/source/@%(kind)s=\'%(val)s\')' % {'kind': kind, 'val': val}, op='and')
if conf.config['verbose'] > 1:
print '[ %s ]' % xpath
res = search(apiurl, request=xpath)
collection = res['request']
requests = []
for root in collection.findall('request'):
r = Request()
r.read(root)
requests.append(r)
return requests
def get_request_list(apiurl, project='', package='', req_who='', req_state=('new',), req_type=None, exclude_target_projects=[]):
xpath = ''
if not 'all' in req_state: