Skip to content
This repository
Browse code

- maintenance requests accept package lists as source and target inci…

…dents to be merged in
  • Loading branch information...
commit 11be969b773596fe17b7a74795667d18c5181509 1 parent 0bdd0a6
Adrian Schröter adrianschroeter authored

Showing 3 changed files with 21 additions and 11 deletions. Show diff stats Hide diff stats

  1. +1 0  NEWS
  2. +13 8 osc/commandline.py
  3. +7 3 osc/core.py
1  NEWS
@@ -5,6 +5,7 @@
5 5 # Features which requires OBS 2.3
6 6 #
7 7 - support dryrun of branching to preview the expected result. "osc sm" is doing this now by default.
  8 + - maintenance requests accept package lists as source and target incidents to be merged in
8 9
9 10 0.133
10 11 - add --meta option also to "list", "cat" and "less" commands
21 osc/commandline.py
@@ -2617,6 +2617,10 @@ def do_createincident(self, subcmd, opts, *args):
2617 2617 help='specify message TEXT')
2618 2618 @cmdln.option('--no-cleanup', action='store_true',
2619 2619 help='do not remove source project on accept')
  2620 + @cmdln.option('--incident', metavar='INCIDENT',
  2621 + help='specify incident number to merge in')
  2622 + @cmdln.option('--incident-project', metavar='INCIDENT_PROJECT',
  2623 + help='specify incident project to merge in')
2620 2624 def do_maintenancerequest(self, subcmd, opts, *args):
2621 2625 """${cmd_name}: Create a request for starting a maintenance incident.
2622 2626
@@ -2628,7 +2632,7 @@ def do_maintenancerequest(self, subcmd, opts, *args):
2628 2632 the "patchinfo" command how add the required maintenance update information.
2629 2633
2630 2634 usage:
2631   - osc maintenancerequest [ SOURCEPROJECT [ TARGETPROJECT ] ]
  2635 + osc maintenancerequest [ SOURCEPROJECT [ SOURCEPACKAGES ] ]
2632 2636 ${cmd_option_list}
2633 2637 """
2634 2638
@@ -2638,22 +2642,21 @@ def do_maintenancerequest(self, subcmd, opts, *args):
2638 2642 if opts.attribute:
2639 2643 maintenance_attribute = opts.attribute
2640 2644
2641   - source_project = target_project = opt_sourceupdate = None
  2645 + source_project = source_packages = target_project = opt_sourceupdate = None
2642 2646 if not opts.no_cleanup:
2643 2647 opt_sourceupdate = 'cleanup'
2644 2648
2645   - if len(args) > 2:
2646   - raise oscerr.WrongArgs('Too many arguments.')
2647   -
2648 2649 if len(args) == 0 and is_project_dir(os.curdir):
2649 2650 source_project = store_read_project(os.curdir)
2650 2651 elif len(args) == 0:
2651 2652 raise oscerr.WrongArgs('Too few arguments.')
2652 2653 if len(args) > 0:
2653 2654 source_project = args[0]
2654   -
2655 2655 if len(args) > 1:
2656   - target_project = args[1]
  2656 + source_packages = args[1:]
  2657 +
  2658 + if opts.incident_project:
  2659 + target_project = opts.incident_project
2657 2660 else:
2658 2661 xpath = 'attribute/@name = \'%s\'' % maintenance_attribute
2659 2662 res = search(apiurl, project_id=xpath)
@@ -2662,12 +2665,14 @@ def do_maintenancerequest(self, subcmd, opts, *args):
2662 2665 if project is None:
2663 2666 sys.exit('Unable to find defined OBS:MaintenanceProject project on server.')
2664 2667 target_project = project.get('name')
  2668 + if opts.incident:
  2669 + target_project += ":" + opts.incident
2665 2670 print 'Using target project \'%s\'' % target_project
2666 2671
2667 2672 if not opts.message:
2668 2673 opts.message = edit_message()
2669 2674
2670   - r = create_maintenance_request(apiurl, source_project, target_project, opt_sourceupdate, opts.message)
  2675 + r = create_maintenance_request(apiurl, source_project, source_packages, target_project, opt_sourceupdate, opts.message)
2671 2676 print r.reqid
2672 2677
2673 2678
10 osc/core.py
@@ -2196,7 +2196,7 @@ class Action:
2196 2196 'add_role': ('tgt_project', 'tgt_package', 'person_name', 'person_role', 'group_name', 'group_role'),
2197 2197 'set_bugowner': ('tgt_project', 'tgt_package', 'person_name'), # obsoleted by add_role
2198 2198 'maintenance_release': ('src_project', 'src_package', 'src_rev', 'tgt_project', 'tgt_package', 'person_name'),
2199   - 'maintenance_incident': ('src_project', 'tgt_project', 'person_name', 'opt_sourceupdate'),
  2199 + 'maintenance_incident': ('src_project', 'src_package', 'src_rev', 'tgt_project', 'person_name', 'opt_sourceupdate'),
2200 2200 'delete': ('tgt_project', 'tgt_package'),
2201 2201 'change_devel': ('src_project', 'src_package', 'tgt_project', 'tgt_package')}
2202 2202 # attribute prefix to element name map (only needed for abbreviated attributes)
@@ -3418,10 +3418,14 @@ def create_release_request(apiurl, src_project, message=''):
3418 3418 return r
3419 3419
3420 3420 # create a maintenance incident per request
3421   -def create_maintenance_request(apiurl, src_project, tgt_project, opt_sourceupdate, message=''):
  3421 +def create_maintenance_request(apiurl, src_project, src_packages, tgt_project, opt_sourceupdate, message=''):
3422 3422 import cgi
3423 3423 r = Request()
3424   - r.add_action('maintenance_incident', src_project=src_project, tgt_project=tgt_project, opt_sourceupdate = opt_sourceupdate)
  3424 + if src_packages:
  3425 + for p in src_packages:
  3426 + r.add_action('maintenance_incident', src_project=src_project, src_package=p, tgt_project=tgt_project, opt_sourceupdate = opt_sourceupdate)
  3427 + else:
  3428 + r.add_action('maintenance_incident', src_project=src_project, tgt_project=tgt_project, opt_sourceupdate = opt_sourceupdate)
3425 3429 # XXX: clarify why we need the unicode(...) stuff
3426 3430 r.description = cgi.escape(unicode(message, 'utf8'))
3427 3431 r.create(apiurl)

0 comments on commit 11be969

Please sign in to comment.
Something went wrong with that request. Please try again.