Fix references from opts.move and opts.from_
This commit is contained in:
parent
4f6e08247a
commit
703b580142
@ -263,7 +263,7 @@ def do_staging(self, subcmd, opts, *args):
|
||||
msg='Please recheck')
|
||||
elif cmd == 'select':
|
||||
tprj = api. prj_from_letter(args[1])
|
||||
return SelectCommand(api).perform(tprj, args[2:])
|
||||
return SelectCommand(api).perform(tprj, args[2:], opts.move, opts.from_)
|
||||
elif cmd == 'cleanup_rings':
|
||||
return CleanupRings(opts.apiurl).perform()
|
||||
elif cmd == 'list':
|
||||
|
@ -1,25 +1,26 @@
|
||||
from osclib.stagingapi import StagingAPI
|
||||
from osc import oscerr
|
||||
from osclib.request_finder import RequestFinder
|
||||
|
||||
class SelectCommand:
|
||||
|
||||
class SelectCommand(object):
|
||||
|
||||
def __init__(self, api):
|
||||
self.api = api
|
||||
|
||||
def select_request(self, rq, rq_prj):
|
||||
def select_request(self, rq, rq_prj, move, from_):
|
||||
if 'staging' not in rq_prj:
|
||||
# Normal 'select' command
|
||||
self.api.rq_to_prj(rq, self.tprj)
|
||||
elif 'staging' in rq_prj and opts.move:
|
||||
elif 'staging' in rq_prj and move:
|
||||
# 'select' command becomes a 'move'
|
||||
fprj = None
|
||||
if opts.from_:
|
||||
fprj = self.api.prj_from_letter(opts.from_)
|
||||
if from_:
|
||||
fprj = self.api.prj_from_letter(from_)
|
||||
else:
|
||||
fprj = rq_prj['staging']
|
||||
print('Moving "{}" from "{}" to "{}"'.format(rq, fprj, self.tprj))
|
||||
self.api.move_between_project(fprj, rq, self.tprj)
|
||||
elif 'staging' in rq_prj and not opts.move:
|
||||
elif 'staging' in rq_prj and not move:
|
||||
# Previously selected, but not explicit move
|
||||
msg = 'Request {} is actually in "{}".\n'
|
||||
msg = msg.format(rq, rq_prj['staging'])
|
||||
@ -29,12 +30,11 @@ class SelectCommand:
|
||||
else:
|
||||
raise oscerr.WrongArgs('Arguments for select are not correct.')
|
||||
|
||||
|
||||
def perform(self, tprj, requests):
|
||||
def perform(self, tprj, requests, move=False, from_=None):
|
||||
if not self.api.prj_frozen_enough(tprj):
|
||||
print('Freeze the prj first')
|
||||
return False
|
||||
self.tprj = tprj
|
||||
|
||||
for rq, rq_prj in RequestFinder.find_sr(requests, self.api.apiurl).items():
|
||||
self.select_request(rq, rq_prj)
|
||||
self.select_request(rq, rq_prj, move, from_)
|
||||
|
Loading…
x
Reference in New Issue
Block a user