Skip to content

Commit

Permalink
support request diffing relative to a former request
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianschroeter authored and dmach committed Mar 16, 2022
1 parent 80c9b6e commit c568cf7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
11 changes: 10 additions & 1 deletion osc/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2090,6 +2090,8 @@ def do_changedevelrequest(self, subcmd, opts, *args):

@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',
Expand Down Expand Up @@ -2512,8 +2514,15 @@ def do_request(self, subcmd, opts, *args):
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'):
Expand Down
7 changes: 5 additions & 2 deletions osc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4896,8 +4896,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()
Expand Down

0 comments on commit c568cf7

Please sign in to comment.