Work on adi command

This commit is contained in:
Stephan Kulow 2019-10-09 13:40:59 +02:00
parent 4921751ef2
commit b6e68f81e9
4 changed files with 14 additions and 24 deletions

View File

@ -1,16 +1,10 @@
from __future__ import print_function
import json
try:
from urllib.error import HTTPError
except ImportError:
#python 2.x
from urllib2 import HTTPError
from urllib.error import HTTPError
from colorama import Fore
from osc import oscerr
from osc.core import get_request
from osc.core import delete_project
from osc.core import show_package_meta
from osc import conf
@ -83,7 +77,14 @@ class AdiCommand:
def create_new_adi(self, wanted_requests, by_dp=False, split=False):
source_projects_expand = self.config.get('source_projects_expand', '').split()
# if we don't call it, there is no invalidate function added
requests = self.api.get_open_requests()
if len(wanted_requests):
requests = []
rf = RequestFinder(self.api)
for p in wanted_requests:
requests.append(rf.load_request(p))
splitter = RequestSplitter(self.api, requests, in_ring=False)
splitter.filter_add('./action[@type="submit"]')
if len(wanted_requests):

View File

@ -1,11 +1,7 @@
try:
from urllib.parse import quote
from urllib.error import HTTPError
except ImportError:
#python 2.x
from urllib2 import HTTPError, quote
from urllib.parse import quote
from urllib.error import HTTPError
from xml.etree import cElementTree as ET
from lxml import etree as ET
from osc import oscerr
from osc.core import makeurl
@ -60,7 +56,7 @@ class RequestFinder(object):
"""
root = self.load_request(request_id)
if not root:
if root is None:
return False
project = root.find('action').find('target').get('project')

View File

@ -83,7 +83,6 @@ class RequestSplitter(object):
def split(self):
for request in self.requests:
self.supplement(request)
if not self.filter_check(request):
continue

View File

@ -576,18 +576,12 @@ class StagingAPI(object):
# Remove the old request
self.rm_from_prj(stage_info['prj'],
request_id=stage_info['rq_id'],
msg='Replaced by sr#{}'.format(request_id),
review='declined')
msg='Replaced by sr#{}'.format(request_id))
if code is None:
# Add the new request that should be replacing the old one.
self.rq_to_prj(request_id, stage_info['prj'])
self._invalidate_get_open_requests()
# Skip over supersede for purpose of diff comments.
meta = self.get_prj_pseudometa(stage_info['prj'])
meta['requests_comment'] = self.get_prj_meta_revision(stage_info['prj'])
self.set_prj_pseudometa(stage_info['prj'], meta)
return stage_info, code
@memoize(session=True)