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

- do_changedevelrequest, do_deleterequest: use Request object to create the request

- removed: core.create_delete_request(), core.create_change_devel_request()
This commit is contained in:
Marcus Huewe 2011-01-25 20:41:42 +01:00
parent dda7d87374
commit db8818c30f
2 changed files with 28 additions and 84 deletions

View File

@ -1516,29 +1516,27 @@ Please submit there instead, or use --nodevelproject to force direct submission.
osc deletereq [-m TEXT] PROJECT [PACKAGE]
${cmd_option_list}
"""
import cgi
args = slash_split(args)
project = None
package = None
if len(args) < 1:
if is_project_dir(os.getcwd()):
project = store_read_project(os.curdir)
elif is_package_dir(os.getcwd()):
project = store_read_project(os.curdir)
package = store_read_package(os.curdir)
else:
raise oscerr.WrongArgs('Please specify at least a project.')
if len(args) > 2:
raise oscerr.WrongArgs('Too many arguments.')
elif len(args) == 1:
project = args[0]
elif len(args) > 1:
elif len(args) == 2:
project = args[0]
package = args[1]
elif len(args) > 2:
raise oscerr.WrongArgs('Too many arguments.')
apiurl = self.get_api_url()
elif is_project_dir(os.getcwd()):
project = store_read_project(os.curdir)
elif is_package_dir(os.getcwd()):
project = store_read_project(os.curdir)
package = store_read_package(os.curdir)
else:
raise oscerr.WrongArgs('Please specify at least a project.')
if not opts.message:
import textwrap
@ -1551,8 +1549,11 @@ Please submit there instead, or use --nodevelproject to force direct submission.
'please explain why you like to delete project %s' % project)
opts.message = edit_message(footer)
result = create_delete_request(apiurl, project, package, opts.message)
print result
r = Request()
r.add_action('delete', tgt_project=project, tgt_package=package)
r.description = cgi.escape(opts.message)
r.create(self.get_api_url())
print r.reqid
@cmdln.option('-m', '--message', metavar='TEXT',
@ -1569,26 +1570,23 @@ Please submit there instead, or use --nodevelproject to force direct submission.
osc changedevelrequest PROJECT PACKAGE DEVEL_PROJECT [DEVEL_PACKAGE]
"""
if len(args) > 4:
raise oscerr.WrongArgs('Too many arguments.')
apiurl = self.get_api_url()
import cgi
if len(args) == 0 and is_package_dir('.') and len(conf.config['getpac_default_project']):
wd = os.curdir
devel_project = store_read_project(wd)
devel_package = package = store_read_package(wd)
project = conf.config['getpac_default_project']
elif len(args) < 3:
raise oscerr.WrongArgs('Too few arguments.')
elif len(args) > 4:
raise oscerr.WrongArgs('Too many arguments.')
else:
if len(args) < 3:
raise oscerr.WrongArgs('Too few arguments.')
devel_project = args[2]
project = args[0]
package = args[1]
devel_package = package
if len(args) > 3:
if len(args) == 4:
devel_package = args[3]
if not opts.message:
@ -1598,11 +1596,12 @@ Please submit there instead, or use --nodevelproject to force direct submission.
% (project,package,devel_project,devel_package))
opts.message = edit_message(footer)
result = create_change_devel_request(apiurl,
devel_project, devel_package,
project, package,
opts.message)
print result
r = Request()
r.add_action('change_devel', src_project=devel_project, src_package=devel_package,
tgt_project=project, tgt_package=package)
r.description = cgi.escape(opts.message)
r.create(self.get_api_url())
print r.reqid
@cmdln.option('-d', '--diff', action='store_true',

View File

@ -3424,61 +3424,6 @@ def edit_message(footer='', template='', templatelen=30):
os.unlink(filename)
return msg
def create_delete_request(apiurl, project, package, message):
import cgi
if package:
package = """package="%s" """ % (package)
else:
package = ""
xml = """\
<request>
<action type="delete">
<target project="%s" %s/>
</action>
<state name="new"/>
<description>%s</description>
</request>
""" % (project, package,
cgi.escape(message or ''))
u = makeurl(apiurl, ['request'], query='cmd=create')
f = http_POST(u, data=xml)
root = ET.parse(f).getroot()
return root.get('id')
def create_change_devel_request(apiurl,
devel_project, devel_package,
project, package,
message):
import cgi
xml = """\
<request>
<action type="change_devel">
<source project="%s" package="%s" />
<target project="%s" package="%s" />
</action>
<state name="new"/>
<description>%s</description>
</request>
""" % (devel_project,
devel_package,
project,
package,
cgi.escape(message or ''))
u = makeurl(apiurl, ['request'], query='cmd=create')
f = http_POST(u, data=xml)
root = ET.parse(f).getroot()
return root.get('id')
def clone_request(apiurl, reqid, msg=None):
query = {'cmd': 'branch', 'request': reqid}
url = makeurl(apiurl, ['source'], query)