From b6e68f81e9145d41cbcd7c2febfb51e7c78cd9c6 Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Wed, 9 Oct 2019 13:40:59 +0200 Subject: [PATCH] Work on adi command --- osclib/adi_command.py | 17 +++++++++-------- osclib/request_finder.py | 12 ++++-------- osclib/request_splitter.py | 1 - osclib/stagingapi.py | 8 +------- 4 files changed, 14 insertions(+), 24 deletions(-) diff --git a/osclib/adi_command.py b/osclib/adi_command.py index 1a99f0d1..1ab85281 100644 --- a/osclib/adi_command.py +++ b/osclib/adi_command.py @@ -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): diff --git a/osclib/request_finder.py b/osclib/request_finder.py index 26e1db6b..993201b5 100644 --- a/osclib/request_finder.py +++ b/osclib/request_finder.py @@ -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') diff --git a/osclib/request_splitter.py b/osclib/request_splitter.py index 196ae914..cc533285 100644 --- a/osclib/request_splitter.py +++ b/osclib/request_splitter.py @@ -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 diff --git a/osclib/stagingapi.py b/osclib/stagingapi.py index 93a0cb2b..1fe1034f 100644 --- a/osclib/stagingapi.py +++ b/osclib/stagingapi.py @@ -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)