Merge pull request #816 from jberry-suse/super-strategy
request_splitter: add super strategy for representing devel groups.
This commit is contained in:
commit
2cc76540fd
@ -204,7 +204,25 @@ def do_staging(self, subcmd, opts, *args):
|
||||
|
||||
select A
|
||||
|
||||
Interactive mode allows the proposal to be modified before application.
|
||||
Built in strategies may be specified as well. For example:
|
||||
|
||||
select --strategy devel
|
||||
select --strategy special
|
||||
select --strategy super
|
||||
|
||||
The default is none and custom is used with any filter-by or group-by
|
||||
arguments are provided.
|
||||
|
||||
To merge applicable requests into an existing staging.
|
||||
|
||||
select --merge A
|
||||
|
||||
To automatically try all available strategies.
|
||||
|
||||
select --try-strategies
|
||||
|
||||
These concepts can be combined and interactive mode allows the proposal
|
||||
to be modified before it is executed.
|
||||
|
||||
"unselect" will remove from the project - pushing them back to the backlog
|
||||
If a message is included the requests will be ignored first.
|
||||
@ -431,6 +449,7 @@ def do_staging(self, subcmd, opts, *args):
|
||||
temp.write(yaml.safe_dump(splitter.proposal, default_flow_style=False) + '\n\n')
|
||||
temp.write('# move requests between stagings or comment/remove them\n')
|
||||
temp.write('# change the target staging for a group\n')
|
||||
temp.write('# remove the group, requests, staging, or strategy to skip\n')
|
||||
temp.write('# stagings\n')
|
||||
if opts.merge:
|
||||
temp.write('# - merged: {}\n'
|
||||
|
@ -2,6 +2,7 @@ from datetime import datetime
|
||||
import dateutil.parser
|
||||
import hashlib
|
||||
from lxml import etree as ET
|
||||
import re
|
||||
|
||||
class RequestSplitter(object):
|
||||
def __init__(self, api, requests, in_ring):
|
||||
@ -52,8 +53,10 @@ class RequestSplitter(object):
|
||||
'contains("{requests}", concat(" ", ./action/target/@package, " "))'
|
||||
.format(requests=requests))
|
||||
|
||||
def group_by(self, xpath):
|
||||
def group_by(self, xpath, required=False):
|
||||
self.groups.append(ET.XPath(xpath))
|
||||
if required:
|
||||
self.filter_add(xpath)
|
||||
|
||||
def filter_only(self):
|
||||
ret = []
|
||||
@ -90,7 +93,7 @@ class RequestSplitter(object):
|
||||
def supplement(self, request):
|
||||
""" Provide additional information for grouping """
|
||||
if request.get('ignored'):
|
||||
# Only supliment once.
|
||||
# Only supplement once.
|
||||
return
|
||||
|
||||
history = request.find('history')
|
||||
@ -105,6 +108,7 @@ class RequestSplitter(object):
|
||||
devel = self.devel_project_get(target_project, target_package)
|
||||
if devel:
|
||||
target.set('devel_project', devel)
|
||||
StrategySuper.supplement(request)
|
||||
|
||||
ring = self.ring_get(target_package)
|
||||
if ring:
|
||||
@ -302,6 +306,7 @@ class RequestSplitter(object):
|
||||
def strategies_try(self):
|
||||
strategies = (
|
||||
'special',
|
||||
'super',
|
||||
'devel',
|
||||
)
|
||||
|
||||
@ -401,7 +406,7 @@ class StrategyDevel(StrategyNone):
|
||||
|
||||
def apply(self, splitter):
|
||||
super(StrategyDevel, self).apply(splitter)
|
||||
splitter.group_by('./action/target/@devel_project')
|
||||
splitter.group_by('./action/target/@devel_project', True)
|
||||
|
||||
def desirable(self, splitter):
|
||||
groups = []
|
||||
@ -410,6 +415,42 @@ class StrategyDevel(StrategyNone):
|
||||
groups.append(group)
|
||||
return groups
|
||||
|
||||
class StrategySuper(StrategyDevel):
|
||||
# Regex pattern prefix representing super devel projects that should be
|
||||
# grouped together. The whole pattern will be used and the last colon
|
||||
# stripped, otherwise the first match group.
|
||||
PATTERNS = [
|
||||
'KDE:',
|
||||
'GNOME:',
|
||||
'(multimedia):(?:libs|apps)',
|
||||
'zypp:'
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def init(cls):
|
||||
cls.patterns = []
|
||||
for pattern in cls.PATTERNS:
|
||||
cls.patterns.append(re.compile(pattern))
|
||||
|
||||
@classmethod
|
||||
def supplement(cls, request):
|
||||
if not hasattr(cls, 'patterns'):
|
||||
cls.init()
|
||||
|
||||
target = request.find('./action/target')
|
||||
devel_project = target.get('devel_project')
|
||||
for pattern in cls.patterns:
|
||||
match = pattern.match(devel_project)
|
||||
if match:
|
||||
prefix = match.group(0 if len(match.groups()) == 0 else 1).rstrip(':')
|
||||
target.set('devel_project_super', prefix)
|
||||
break
|
||||
|
||||
def apply(self, splitter):
|
||||
super(StrategySuper, self).apply(splitter)
|
||||
splitter.groups = []
|
||||
splitter.group_by('./action/target/@devel_project_super', True)
|
||||
|
||||
class StrategySpecial(StrategyNone):
|
||||
PACKAGES = [
|
||||
'boost',
|
||||
|
Loading…
x
Reference in New Issue
Block a user