diff --git a/osc/commandline.py b/osc/commandline.py index ea939f04..09d3933d 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -2150,6 +2150,8 @@ Please submit there instead, or use --nodevelproject to force direct submission. @cmdln.option('-d', '--diff', action='store_true', help='generate a diff') + @cmdln.option('-S', '--superseded-request', metavar='SUPERSEDED_REQUEST', + help='Create the diff relative to a given former request') @cmdln.option('-u', '--unified', action='store_true', help='output the diff in the unified diff format') @cmdln.option('--no-devel', action='store_true', @@ -2575,8 +2577,15 @@ Please submit there instead, or use --nodevelproject to force direct submission. diff = b'' try: # works since OBS 2.1 - diff = request_diff(apiurl, reqid) + diff = request_diff(apiurl, reqid, opts.superseded_request) except HTTPError as e: + if e.code == 404: + # Any referenced object does not exist, eg. the superseded request + root = ET.fromstring(e.read()) + summary = root.find('summary') + print(summary.text, file=sys.stderr) + raise oscerr.WrongOptions("Object does not exist") + # for OBS 2.0 and before sr_actions = r.get_actions('submit') if not r.get_actions('submit') and not r.get_actions('maintenance_incident') and not r.get_actions('maintenance_release'): diff --git a/osc/core.py b/osc/core.py index d8eb7be9..90cd316c 100644 --- a/osc/core.py +++ b/osc/core.py @@ -4952,8 +4952,11 @@ def server_diff_noex(apiurl, return rdiff -def request_diff(apiurl, reqid): - u = makeurl(apiurl, ['request', reqid], query={'cmd': 'diff'} ) +def request_diff(apiurl, reqid, superseded_reqid=None): + query = {'cmd': 'diff'} + if superseded_reqid: + query['diff_to_superseded'] = superseded_reqid + u = makeurl(apiurl, ['request', reqid], query) f = http_POST(u) return f.read()