1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-26 01:46:13 +01:00

new request syntax as proposed on ml.

will roll a beta version from this later today for more feedback.
This commit is contained in:
Adrian Schröter 2009-06-02 14:57:42 +00:00
parent 46d726133c
commit dc81d5f278
2 changed files with 162 additions and 327 deletions

15
NEWS
View File

@ -1,9 +1,12 @@
0.118:
- Obsolete "submitreq" command
- New generic "request" command:
- new "delete" request
- new "change_devel" request
- Support new request types
- "submitreq" command has a new syntax (incompatible !)
- new "deleterequest" command
- new "changedevelrequest" command
- new "request" command for showing/modifing requests
- Multiple actions in one request is not yet supported by osc
- The new commands require an OBS 1.7 server, submitreq is still working with
older servers.
- support of added .changes in commit message template
- make submit request listing fast by server side filtering
- allow pulling of conflicting changes via "osc repairlink"
@ -12,7 +15,7 @@
* delete and rdelete take over
- enable package tracking by default
- bugfix: templates in edit commit message causes an empty commit logs
- osc sr create consumes DESTPRJ [DESTPKG] arguments only
- osc submitrequest consumes DESTPRJ [DESTPKG] arguments only
- osc build now also tested on native arm targets where uname -m reports a string like armv{4l,5el,6l,7el,7l}
- osc rlog now works with srcmd5 also
- plugins now should be placed in /usr/lib/osc-plugins to match FHS (the /var path is still supported though)
@ -29,7 +32,7 @@
* -r|--repo to specify a repository(repositories)
* -a|--arch to specify a architexure(s)
* --xml for xml output (makes results_meta obsolete)
- submitreq list -M shows open SRs created by the user.
- request list -M shows open SRs created by the user.
0.117:
- support checkout of single package via "osc co PACKAGE" when local dir is project

View File

@ -466,11 +466,6 @@ class Osc(cmdln.Cmdln):
sys.exit('The --delete switch is only for pattern metadata.')
@cmdln.option('-d', '--diff', action='store_true',
help='generate a diff')
@cmdln.option('-u', '--unified', action='store_true',
help='output the diff in the unified diff format')
@cmdln.option('-m', '--message', metavar='TEXT',
help='specify message TEXT')
@cmdln.option('-r', '--revision', metavar='REV',
@ -478,216 +473,170 @@ class Osc(cmdln.Cmdln):
@cmdln.option('--nodevelproject', action='store_true',
help='do not follow a defined devel project ' \
'(primary project where a package is developed)')
@cmdln.option('-s', '--state', default='new',
help='only list requests in one of the comma separated given states [default=new]')
@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',
help='only show requests created by yourself')
@cmdln.alias("sr")
@cmdln.alias("submitrequest")
@cmdln.hide(1)
def do_submitreq(self, subcmd, opts, *args):
"""${cmd_name}: Handle requests to submit a package into another project
@cmdln.alias("submitreq")
def do_submitrequest(self, subcmd, opts, *args):
"""${cmd_name}: Create request to submit source into another Project
[See http://en.opensuse.org/Build_Service/Collaboration for information
on this topic.]
*************************************************************************
WARNING: the "submitreq" command is about to become obsolete. Please use
the "request" command instead !
*************************************************************************
See the "request" command for showing and modifing existing requests.
usage:
osc submitreq [-m TEXT]
osc submitreq [-m TEXT] DESTPRJ [DESTPKG]
osc submitreq [-m TEXT] SOURCEPRJ SOURCEPKG DESTPRJ [DESTPKG]
${cmd_option_list}
"""
print """
*************************************************************************
WARNING: the "submitreq" command is about to become obsolete. Please use
the "request" command instead !
*************************************************************************
"""
args = slash_split(args)
cmds = ['create', 'list', 'log', 'show', 'decline', 'accept', 'delete', 'revoke']
if not args or args[0] not in cmds:
raise oscerr.WrongArgs('Unknown submitreq action. Choose one of %s.' \
% ', '.join(cmds))
cmd = args[0]
del args[0]
if cmd in ['create']:
min_args, max_args = 0, 4
elif cmd in ['list']:
min_args, max_args = 0, 2
else:
min_args, max_args = 1, 1
if len(args) < min_args:
raise oscerr.WrongArgs('Too few arguments.')
if len(args) > max_args:
if len(args) > 4:
raise oscerr.WrongArgs('Too many arguments.')
apiurl = conf.config['apiurl']
# collect specific arguments
if cmd == 'create':
if len(args) <= 2:
# try using the working copy at hand
p = findpacs(os.curdir)[0]
src_project = p.prjname
src_package = p.name
if len(args) == 0 and p.islink():
dst_project = p.linkinfo.project
dst_package = p.linkinfo.package
apiurl = p.apiurl
elif len(args) > 0:
dst_project = args[0]
if len(args) == 2:
dst_package = args[1]
else:
dst_package = src_package
else:
sys.exit('Package \'%s\' is not a source link, so I cannot guess the submit target.\n'
'Please provide it the target via commandline arguments.' % p.name)
modified = [i for i in p.filenamelist if p.status(i) != ' ' and p.status(i) != '?']
if len(modified) > 0:
print 'Your working copy has local modifications.'
repl = raw_input('Proceed without committing the local changes? (y|N) ')
if repl != 'y':
sys.exit(1)
elif len(args) >= 3:
# get the arguments from the commandline
src_project, src_package, dst_project = args[0:3]
if len(args) == 4:
dst_package = args[3]
if len(args) <= 2:
# try using the working copy at hand
p = findpacs(os.curdir)[0]
src_project = p.prjname
src_package = p.name
if len(args) == 0 and p.islink():
dst_project = p.linkinfo.project
dst_package = p.linkinfo.package
apiurl = p.apiurl
elif len(args) > 0:
dst_project = args[0]
if len(args) == 2:
dst_package = args[1]
else:
dst_package = src_package
else:
raise oscerr.WrongArgs('Incorrect number of arguments.\n\n' \
+ self.get_cmd_help('submitreq'))
sys.exit('Package \'%s\' is not a source link, so I cannot guess the submit target.\n'
'Please provide it the target via commandline arguments.' % p.name)
elif cmd == 'list':
package = None
project = None
if len(args) > 0:
project = args[0]
elif not opts.mine:
project = store_read_project(os.curdir)
apiurl = store_read_apiurl(os.curdir)
try:
package = store_read_package(os.curdir)
except oscerr.NoWorkingCopy:
pass
modified = [i for i in p.filenamelist if p.status(i) != ' ' and p.status(i) != '?']
if len(modified) > 0:
print 'Your working copy has local modifications.'
repl = raw_input('Proceed without committing the local changes? (y|N) ')
if repl != 'y':
sys.exit(1)
elif len(args) >= 3:
# get the arguments from the commandline
src_project, src_package, dst_project = args[0:3]
if len(args) == 4:
dst_package = args[3]
else:
dst_package = src_package
else:
raise oscerr.WrongArgs('Incorrect number of arguments.\n\n' \
+ self.get_cmd_help('request'))
if len(args) > 1:
package = args[1]
elif cmd in ['log', 'show', 'decline', 'accept', 'delete', 'revoke']:
reqid = args[0]
# create
if cmd == 'create':
if not opts.nodevelproject:
devloc = None
try:
devloc = show_develproject(apiurl, dst_project, dst_package)
except urllib2.HTTPError:
print >>sys.stderr, """\
if not opts.nodevelproject:
devloc = None
try:
devloc = show_develproject(apiurl, dst_project, dst_package)
except urllib2.HTTPError:
print >>sys.stderr, """\
Warning: failed to fetch meta data for '%s' package '%s' (new package?) """ \
% (dst_project, dst_package)
pass
% (dst_project, dst_package)
pass
if devloc \
and dst_project != devloc \
and src_project != devloc:
print """\
if devloc \
and dst_project != devloc \
and src_project != devloc:
print """\
Sorry, but a different project, %s, is defined as the place where development
of the package %s primarily takes place.
Please submit there instead, or use --nodevelproject to force direct submission.""" \
% (devloc, dst_package)
sys.exit(1)
reqs = get_request_list(apiurl, dst_project, dst_package)
user = conf.get_apiurl_usr(apiurl)
myreqs = [ i for i in reqs if i.state.who == user ]
repl = ''
if len(myreqs) > 0:
print 'You already created the following requests: %s.' % \
', '.join([str(i.reqid) for i in myreqs ])
repl = raw_input('Revoke the old requests? (y/N) ')
% (devloc, dst_package)
sys.exit(1)
reqs = get_request_list(apiurl, dst_project, dst_package)
user = conf.get_apiurl_usr(apiurl)
myreqs = [ i for i in reqs if i.state.who == user ]
repl = ''
if len(myreqs) > 0:
print 'You already created the following submit request: %s.' % \
', '.join([str(i.reqid) for i in myreqs ])
repl = raw_input('Revoke the old requests? (y/N) ')
# since we have no support in the cli to specify different action types yet
# the default is a submit action
result = create_submit_request(apiurl,
src_project, src_package,
dst_project, dst_package,
opts.message, orev=opts.revision)
if repl == 'y':
for req in myreqs:
change_request_state(apiurl, str(req.reqid), 'revoked',
'superseded by %s' % result)
# since we have no support in the cli to specify different action types yet
# the default is a submit action
result = create_submit_request(apiurl,
src_project, src_package,
dst_project, dst_package,
opts.message, orev=opts.revision)
if repl == 'y':
for req in myreqs:
change_request_state(apiurl, str(req.reqid), 'revoked',
'superseded by %s' % result)
print 'created request id', result
print 'created request id', result
# list
elif cmd == 'list':
state_list = opts.state.split(',')
who = ''
if opts.mine:
who = conf.get_apiurl_usr(apiurl)
results = get_request_list(apiurl,
project, package, who, state_list)
results.sort(reverse=True)
for result in results:
print result.list_view()
elif cmd == 'log':
for l in get_request_log(conf.config['apiurl'], reqid):
print l
@cmdln.option('-m', '--message', metavar='TEXT',
help='specify message TEXT')
@cmdln.alias("dr")
@cmdln.alias("deletereq")
def do_deleterequest(self, subcmd, opts, *args):
"""${cmd_name}: Create request to delete a package or project
# show
elif cmd == 'show':
r = get_request(conf.config['apiurl'], reqid)
if opts.brief:
print r.list_view()
else:
print r
# fixme: will inevitably fail if the given target doesn't exist
if opts.diff:
try:
print server_diff(conf.config['apiurl'],
r.actions[0].dst_project, r.actions[0].dst_package, None,
r.actions[0].src_project, r.actions[0].src_package, r.actions[0].src_rev, opts.unified)
except urllib2.HTTPError, e:
e.osc_msg = 'Diff not possible'
raise
usage:
osc deletereq [-m TEXT] PROJECT [PACKAGE]
${cmd_option_list}
"""
args = slash_split(args)
if len(args) > 2:
raise oscerr.WrongArgs('Too many arguments.')
apiurl = conf.config['apiurl']
project = args[0]
package = None
if len(args) > 1:
package = args[1]
result = create_delete_request(apiurl, project, package, opts.message)
print result
# decline
elif cmd == 'decline':
r = change_request_state(conf.config['apiurl'],
reqid, 'declined', opts.message or '')
print r
@cmdln.option('-m', '--message', metavar='TEXT',
help='specify message TEXT')
@cmdln.alias("cr")
@cmdln.alias("changedevelreq")
def do_changedevelrequest(self, subcmd, opts, *args):
"""${cmd_name}: Handle requests to another project
[See http://en.opensuse.org/Build_Service/Collaboration for information
on this topic.]
See the "request" command for showing and modifing existing requests.
osc changedevelrequest PROJECT PACKAGE DEVEL_PROJECT [DEVEL_PACKAGE]
"""
if len(args) > 4:
raise oscerr.WrongArgs('Too many arguments.')
if len(args) < 3:
raise oscerr.WrongArgs('Too few arguments.')
apiurl = conf.config['apiurl']
devel_project = args[2]
project = args[0]
package = args[1]
devel_package = package
if len(args) > 3:
devel_package = args[3]
result = create_change_devel_request(apiurl,
devel_project, devel_package,
project, package,
opts.message)
print result
# accept
elif cmd == 'accept':
r = change_request_state(conf.config['apiurl'],
reqid, 'accepted', opts.message or '')
print r
# delete
elif cmd == 'delete':
r = change_request_state(conf.config['apiurl'],
reqid, 'deleted', opts.message or '')
print r
# revoke
elif cmd == 'revoke':
r = change_request_state(conf.config['apiurl'],
reqid, 'revoked', opts.message or '')
print r
@cmdln.option('-d', '--diff', action='store_true',
@ -696,11 +645,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
help='output the diff in the unified diff format')
@cmdln.option('-m', '--message', metavar='TEXT',
help='specify message TEXT')
@cmdln.option('-r', '--revision', metavar='REV',
help='for "create", specify a certain source revision ID (the md5 sum)')
@cmdln.option('--nodevelproject', action='store_true',
help='do not follow a defined devel project ' \
'(primary project where a package is developed)')
@cmdln.option('-s', '--state', default='new',
help='only list requests in one of the comma separated given states [default=new]')
@cmdln.option('-b', '--brief', action='store_true', default=False,
@ -709,21 +653,18 @@ Please submit there instead, or use --nodevelproject to force direct submission.
help='only show requests created by yourself')
@cmdln.alias("rq")
def do_request(self, subcmd, opts, *args):
"""${cmd_name}: Handle requests to another project
"""${cmd_name}: Show and modify requests
[See http://en.opensuse.org/Build_Service/Collaboration for information
on this topic.]
For "submit", there are two ways to use it. Either with a working copy
or without. If called with no arguments, osc will guess what to submit
where. If you don't have a working copy, you can give the respective
arguments on the command line (see below for an example).
Then, the DESTPAC name is optional; the source packages' name will be
used if DESTPAC is omitted.
With --message, a message can be attached.
With --revision, a revision MD5 of a package can be specified which is
to be submitted. The default is to request submission of the currently
checked in revision.
This command shows and modifies existing requests. To create new requests
you need to call one of the following:
osc submitrequest
osc deleterequest
osc changedevelrequest
This command has the following sub commands:
"list" lists open requests attached to a project or package.
@ -735,8 +676,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
"decline" will change the request state to "declined" and append a
message that you specify with the --message option.
"delete" will permanently delete a request and append a
message that you specify with the --message option.
"wipe" will permanently delete a request.
"revoke" will set the request state to "revoked" and append a
message that you specify with the --message option.
@ -747,23 +687,19 @@ Please submit there instead, or use --nodevelproject to force direct submission.
usage:
osc request submit [-m TEXT]
osc request submit [-m TEXT] DESTPRJ [DESTPKG]
osc request submit [-m TEXT] SOURCEPRJ SOURCEPKG DESTPRJ [DESTPKG]
osc request list [-M] [PRJ [PKG]]
osc request log ID
osc request show [-d] [-b] ID
osc request accept [-m TEXT] ID
osc request decline [-m TEXT] ID
osc request revoke [-m TEXT] ID
osc request delete [-m TEXT] DESTPRJ [DESTPKG]
osc request change_devel [-m TEXT] PROJECT PACKAGE DEVEL_PROJECT [DEVEL_PACKAGE]
osc request wipe ID
${cmd_option_list}
"""
args = slash_split(args)
cmds = ['submit', 'list', 'log', 'show', 'decline', 'accept', 'delete', 'revoke', 'change_devel']
cmds = ['list', 'log', 'show', 'decline', 'accept', 'wipe', 'revoke']
if not args or args[0] not in cmds:
raise oscerr.WrongArgs('Unknown request action. Choose one of %s.' \
% ', '.join(cmds))
@ -771,12 +707,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
cmd = args[0]
del args[0]
if cmd in ['submit']:
min_args, max_args = 0, 4
elif cmd in ['delete']:
min_args, max_args = 1, 2
elif cmd in ['change_devel']:
min_args, max_args = 3, 4
if cmd in ['wipe']:
min_args, max_args = 1, 1
elif cmd in ['list']:
min_args, max_args = 0, 2
else:
@ -788,45 +720,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
apiurl = conf.config['apiurl']
# collect specific arguments
if cmd == 'submit':
if len(args) <= 2:
# try using the working copy at hand
p = findpacs(os.curdir)[0]
src_project = p.prjname
src_package = p.name
if len(args) == 0 and p.islink():
dst_project = p.linkinfo.project
dst_package = p.linkinfo.package
apiurl = p.apiurl
elif len(args) > 0:
dst_project = args[0]
if len(args) == 2:
dst_package = args[1]
else:
dst_package = src_package
else:
sys.exit('Package \'%s\' is not a source link, so I cannot guess the submit target.\n'
'Please provide it the target via commandline arguments.' % p.name)
modified = [i for i in p.filenamelist if p.status(i) != ' ' and p.status(i) != '?']
if len(modified) > 0:
print 'Your working copy has local modifications.'
repl = raw_input('Proceed without committing the local changes? (y|N) ')
if repl != 'y':
sys.exit(1)
elif len(args) >= 3:
# get the arguments from the commandline
src_project, src_package, dst_project = args[0:3]
if len(args) == 4:
dst_package = args[3]
else:
dst_package = src_package
else:
raise oscerr.WrongArgs('Incorrect number of arguments.\n\n' \
+ self.get_cmd_help('request'))
elif cmd == 'list':
if cmd == 'list':
package = None
project = None
if len(args) > 0:
@ -841,78 +735,12 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if len(args) > 1:
package = args[1]
elif cmd in ['log', 'show', 'decline', 'accept', 'delete', 'revoke']:
elif cmd in ['log', 'show', 'decline', 'accept', 'wipe', 'revoke']:
reqid = args[0]
# create submit request
if cmd == 'submit':
if not opts.nodevelproject:
devloc = None
try:
devloc = show_develproject(apiurl, dst_project, dst_package)
except urllib2.HTTPError:
print >>sys.stderr, """\
Warning: failed to fetch meta data for '%s' package '%s' (new package?) """ \
% (dst_project, dst_package)
pass
if devloc \
and dst_project != devloc \
and src_project != devloc:
print """\
Sorry, but a different project, %s, is defined as the place where development
of the package %s primarily takes place.
Please submit there instead, or use --nodevelproject to force direct submission.""" \
% (devloc, dst_package)
sys.exit(1)
reqs = get_request_list(apiurl, dst_project, dst_package)
user = conf.get_apiurl_usr(apiurl)
myreqs = [ i for i in reqs if i.state.who == user ]
repl = ''
if len(myreqs) > 0:
print 'You already created the following submit request: %s.' % \
', '.join([str(i.reqid) for i in myreqs ])
repl = raw_input('Revoke the old requests? (y/N) ')
# since we have no support in the cli to specify different action types yet
# the default is a submit action
result = create_submit_request(apiurl,
src_project, src_package,
dst_project, dst_package,
opts.message, orev=opts.revision)
if repl == 'y':
for req in myreqs:
change_request_state(apiurl, str(req.reqid), 'revoked',
'superseded by %s' % result)
print 'created request id', result
# create delete request
elif cmd == 'delete':
project = args[0]
package = None
if len(args) > 1:
package = args[1]
result = create_delete_request(apiurl, project, package, opts.message)
print result
# request to change devel project
elif cmd == 'change_devel':
devel_project = args[2]
project = args[0]
package = args[1]
devel_package = package
if len(args) > 3:
devel_package = args[3]
result = create_change_devel_request(apiurl,
devel_project, devel_package,
project, package,
opts.message)
print result
# list
elif cmd == 'list':
if cmd == 'list':
state_list = opts.state.split(',')
who = ''
if opts.mine:
@ -954,12 +782,16 @@ Please submit there instead, or use --nodevelproject to force direct submission.
r = change_request_state(conf.config['apiurl'],
reqid, 'declined', opts.message or '')
print r
# accept
elif cmd == 'accept':
r = change_request_state(conf.config['apiurl'],
reqid, 'accepted', opts.message or '')
print r
# delete/wipe
elif cmd == 'wipe':
r = change_request_state(conf.config['apiurl'],
reqid, 'deleted', opts.message or '')
print r
# revoke
elif cmd == 'revoke':
r = change_request_state(conf.config['apiurl'],