From 52eb890d76fc74e95cb0cb5a12cbc41250b32baa Mon Sep 17 00:00:00 2001 From: Jimmy Berry Date: Wed, 31 Oct 2018 16:24:16 -0500 Subject: [PATCH] osclib/request_splitter: provide stageable option and make default True. Without this, the relative rarer types of requests seen in projects with staging and handled by list command will be included in staging proposal. However, since they are not stageable the select operation will fail. This change ensures that a filter is always present when stageable is True to exclude non-stableable requests. The list command sets stageable to false in order to list out the non-stageable requests of interest. This was not observed in openSUSE since the main non-stageable request was change_devel and that was exluded in StrategyNone. That filter could be replaced with the stageable filter, but having an always on filter seems to make more sense since generally operating in one of two modes. --- osclib/list_command.py | 2 +- osclib/request_splitter.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/osclib/list_command.py b/osclib/list_command.py index 33169d7f..160cef75 100644 --- a/osclib/list_command.py +++ b/osclib/list_command.py @@ -29,7 +29,6 @@ class ListCommand: if not len(requests): return splitter = RequestSplitter(self.api, requests, in_ring=True) - splitter.filter_add('./action[@type="submit" or @type="delete"]') splitter.group_by('./action/target/@devel_project') splitter.split() @@ -68,6 +67,7 @@ class ListCommand: print 'Not in a ring:', ' '.join(sorted(non_ring_packages)) # Print requests not handled by staging process to highlight them. + splitter.stageable = False for request_type in ('change_devel', 'set_bugowner'): splitter.reset() splitter.filter_add('./action[@type="{}"]'.format(request_type)) diff --git a/osclib/request_splitter.py b/osclib/request_splitter.py index f748a44d..837ec7e0 100644 --- a/osclib/request_splitter.py +++ b/osclib/request_splitter.py @@ -9,10 +9,11 @@ from osclib.core import request_age import re class RequestSplitter(object): - def __init__(self, api, requests, in_ring): + def __init__(self, api, requests, in_ring, stageable=True): self.api = api self.requests = requests self.in_ring = in_ring + self.stageable = stageable self.config = conf.config[self.api.project] # 55 minutes to avoid two staging bot loops of 30 minutes @@ -38,6 +39,10 @@ class RequestSplitter(object): self.other = [] self.grouped = {} + if self.stageable: + # Require requests to be stageable (submit or delete package). + self.filter_add('./action[@type="submit" or (@type="delete" and ./target[@package])]') + def strategy_set(self, name, **kwargs): self.reset() @@ -393,7 +398,6 @@ class Strategy(object): class StrategyNone(Strategy): def apply(self, splitter): - splitter.filter_add('./action[not(@type="add_role" or @type="change_devel")]') # All other strategies that inherit this are not restricted by age as # the age restriction is used to allow other strategies to be observed. if type(self) is StrategyNone: