1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-10 06:46:15 +01:00

submitreq:

- when requesting a submit, save the source package's revision id (looking up
   what it currently is)
 - give the user a way to override it, to submit an older revision
 - when using show --diff, take the actual old revision into account. Thus, the
   diff is against the source revision of the time of request creation.
This commit is contained in:
Dr. Peter Poeml 2008-03-12 23:37:35 +00:00
parent 94826d6402
commit 2bf92fce75
2 changed files with 35 additions and 10 deletions

View File

@ -356,27 +356,37 @@ class Osc(cmdln.Cmdln):
help='generate a diff')
@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)')
def do_submitreq(self, subcmd, opts, *args):
"""${cmd_name}: Handle requests to submit a package into another project
For "create", 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.
"list" lists open requests attached to a project or package.
"show" will show the request itself, and generate a diff for review, if
used with the --diff option.
decline, accept:
Not implemented. Requires more intelligence.
"decline" will change the request state to "declined" and append a
message that you specify with the --message option.
"accept" will change the request state to "accepted" and will trigger
the actual submit process. That would normally be a server-side copy of
the source package to the target package.
usage:
osc submitreq create [-m TEXT] SOURCEPRJ SOURCEPAC DESTPRJ [DESTPAC]
usage:
osc submitreq create [-m TEXT] SOURCEPRJ SOURCEPKG DESTPRJ [DESTPKG]
osc submitreq list PRJ [PKG]
osc submitreq show [-d] ID
osc submitreq decline ID
osc submitreq accept ID
osc submitreq decline [-m TEXT] ID
osc submitreq accept [-m TEXT] ID
${cmd_option_list}
"""
@ -426,7 +436,7 @@ class Osc(cmdln.Cmdln):
result = create_submit_request(conf.config['apiurl'],
src_project, src_package,
dst_project, dst_package,
opts.message)
opts.message, orev=opts.revision)
print 'created request id', result
@ -444,7 +454,7 @@ class Osc(cmdln.Cmdln):
# fixme: will inevitably fail if the given target doesn't exist
if opts.diff:
print pretty_diff(conf.config['apiurl'],
r.src_project, r.src_package, None,
r.src_project, r.src_package, r.src_md5,
r.dst_project, r.dst_package, None)

View File

@ -1037,6 +1037,7 @@ class SubmitReq:
self.last_author = None
self.src_project = None
self.src_package = None
self.src_md5 = None
self.dst_project = None
self.dst_package = None
self.descr = None
@ -1049,6 +1050,8 @@ class SubmitReq:
n = root.find('merge').find('source')
self.src_project = n.get('project')
self.src_package = n.get('package')
try: self.src_md5 = n.get('rev')
except: pass
# FIXME: the xml is not yet adjusted, 'submit' is still called 'merge'
n = root.find('merge').find('target')
@ -1090,8 +1093,12 @@ class SubmitReq:
def __str__(self):
s = """\
Request to submit (id %s):
%s/%s -> %s/%s
Source revision MD5:
%s
Message:
%s
@ -1101,6 +1108,7 @@ State: %-10s %s %s
self.src_package,
self.dst_project,
self.dst_package,
self.src_md5 or 'not given',
repr(self.descr) or '',
self.state.name,
self.state.when, self.state.who)
@ -1640,6 +1648,11 @@ def show_files_meta(apiurl, prj, pac, revision=None):
return f.readlines()
def show_upstream_srcmd5(apiurl, prj, pac):
m = show_files_meta(apiurl, prj, pac)
return ET.parse(StringIO(''.join(m))).getroot().get('srcmd5')
def show_upstream_rev(apiurl, prj, pac):
m = show_files_meta(apiurl, prj, pac)
return ET.parse(StringIO(''.join(m))).getroot().get('rev')
@ -1706,13 +1719,14 @@ def read_meta_from_spec(specfile, *args):
def create_submit_request(apiurl,
src_project, src_package,
dst_project, dst_package,
message):
message, orev=None):
import cgi
r = SubmitReq()
r.src_project = src_project
r.src_package = src_package
r.src_md5 = orev or show_upstream_srcmd5(apiurl, src_project, src_package)
r.dst_project = dst_project
r.dst_package = dst_package
r.descr = cgi.escape(message or '')
@ -1721,7 +1735,7 @@ def create_submit_request(apiurl,
xml = """\
<request type="merge">
<merge>
<source project="%s" package="%s" />
<source project="%s" package="%s" rev="%s"/>
<target project="%s" package="%s" />
</merge>
<state name="new"/>
@ -1729,6 +1743,7 @@ def create_submit_request(apiurl,
</request>
""" % (r.src_project,
r.src_package,
r.src_md5,
r.dst_project,
r.dst_package,
r.descr)