Remove jump/stops options from readFullInheritance
Fixes: https://pagure.io/koji/issue/2656
This commit is contained in:
parent
da9e9310f7
commit
d45158ae97
3 changed files with 35 additions and 62 deletions
|
|
@ -8,7 +8,6 @@ import logging
|
|||
import os
|
||||
import pprint
|
||||
import random
|
||||
import re
|
||||
import stat
|
||||
import sys
|
||||
import textwrap
|
||||
|
|
@ -22,7 +21,7 @@ import six.moves.xmlrpc_client
|
|||
from six.moves import filter, map, range, zip
|
||||
|
||||
import koji
|
||||
from koji.util import base64encode, md5_constructor, to_list, deprecated
|
||||
from koji.util import base64encode, md5_constructor, to_list
|
||||
from koji_cli.lib import (
|
||||
TimeOption,
|
||||
_,
|
||||
|
|
@ -4196,8 +4195,8 @@ def anon_handle_list_tag_inheritance(goptions, session, args):
|
|||
parser = OptionParser(usage=get_usage_str(usage))
|
||||
parser.add_option("--reverse", action="store_true",
|
||||
help=_("Process tag's children instead of its parents"))
|
||||
parser.add_option("--stop", help=_("Stop processing inheritance at this tag"))
|
||||
parser.add_option("--jump", help=_("Jump from one tag to another when processing inheritance"))
|
||||
parser.add_option("--stop", help=SUPPRESS_HELP)
|
||||
parser.add_option("--jump", help=SUPPRESS_HELP)
|
||||
parser.add_option("--event", type='int', metavar="EVENT#", help=_("query at event"))
|
||||
parser.add_option("--ts", type='int', metavar="TIMESTAMP",
|
||||
help=_("query at last event before timestamp"))
|
||||
|
|
@ -4219,30 +4218,9 @@ def anon_handle_list_tag_inheritance(goptions, session, args):
|
|||
|
||||
opts = {}
|
||||
opts['reverse'] = options.reverse or False
|
||||
opts['stops'] = {}
|
||||
opts['jumps'] = {}
|
||||
if event:
|
||||
opts['event'] = event['id']
|
||||
|
||||
if options.jump:
|
||||
deprecated("--jump option is deprecated and will be removed in 1.26")
|
||||
match = re.match(r'^(.*)/(.*)$', options.jump)
|
||||
if match:
|
||||
tag1 = session.getTagID(match.group(1))
|
||||
if not tag1:
|
||||
parser.error(_("No such tag: %s") % match.group(1))
|
||||
tag2 = session.getTagID(match.group(2))
|
||||
if not tag2:
|
||||
parser.error(_("No such tag: %s") % match.group(2))
|
||||
opts['jumps'][str(tag1)] = tag2
|
||||
|
||||
if options.stop:
|
||||
deprecated("--stop option is deprecated and will be removed in 1.26")
|
||||
tag1 = session.getTagID(options.stop)
|
||||
if not tag1:
|
||||
parser.error(_("No such tag: %s") % options.stop)
|
||||
opts['stops'] = {str(tag1): 1}
|
||||
|
||||
sys.stdout.write(' %s (%i)\n' % (tag['name'], tag['id']))
|
||||
data = session.getFullInheritance(tag['id'], **opts)
|
||||
_printInheritance(data, None, opts['reverse'])
|
||||
|
|
|
|||
|
|
@ -773,26 +773,15 @@ def _writeInheritanceData(tag_id, changes, clear=False):
|
|||
insert.execute()
|
||||
|
||||
|
||||
def readFullInheritance(tag_id, event=None, reverse=False, stops=None, jumps=None):
|
||||
def readFullInheritance(tag_id, event=None, reverse=False):
|
||||
"""Returns a list representing the full, ordered inheritance from tag"""
|
||||
if not stops:
|
||||
stops = {}
|
||||
else:
|
||||
logger.warning(
|
||||
"readFullInheritance stops option is deprecated and will be removed in 1.26")
|
||||
if not jumps:
|
||||
jumps = {}
|
||||
else:
|
||||
logger.warning(
|
||||
"readFullInheritance jumps option is deprecated and will be removed in 1.26")
|
||||
order = []
|
||||
readFullInheritanceRecurse(tag_id, event, order, stops, {}, {}, 0, None, False, [], reverse,
|
||||
jumps)
|
||||
readFullInheritanceRecurse(tag_id, event, order, {}, {}, 0, None, False, [], reverse)
|
||||
return order
|
||||
|
||||
|
||||
def readFullInheritanceRecurse(tag_id, event, order, prunes, top, hist, currdepth, maxdepth,
|
||||
noconfig, pfilter, reverse, jumps):
|
||||
def readFullInheritanceRecurse(tag_id, event, order, top, hist, currdepth, maxdepth, noconfig,
|
||||
pfilter, reverse):
|
||||
if maxdepth is not None and maxdepth < 1:
|
||||
return
|
||||
# note: maxdepth is relative to where we are, but currdepth is absolute from
|
||||
|
|
@ -809,8 +798,6 @@ def readFullInheritanceRecurse(tag_id, event, order, prunes, top, hist, currdept
|
|||
id = link['tag_id']
|
||||
else:
|
||||
id = link['parent_id']
|
||||
if id in jumps:
|
||||
id = jumps[id]
|
||||
if id in top:
|
||||
# LOOP!
|
||||
if event is None:
|
||||
|
|
@ -818,16 +805,9 @@ def readFullInheritanceRecurse(tag_id, event, order, prunes, top, hist, currdept
|
|||
log_error("Warning: INHERITANCE LOOP detected at %s -> %s, pruning" % (tag_id, id))
|
||||
# auto prune
|
||||
continue
|
||||
if id in prunes:
|
||||
# ignore pruned tags
|
||||
continue
|
||||
if link['intransitive'] and len(top) > 1 and not reverse:
|
||||
# ignore intransitive inheritance links, except at root
|
||||
continue
|
||||
if link['priority'] < 0:
|
||||
# negative priority indicates pruning, rather than inheritance
|
||||
prunes[id] = 1
|
||||
continue
|
||||
if reverse:
|
||||
# maxdepth logic is different in this case. no propagation
|
||||
if link['maxdepth'] is not None and link['maxdepth'] < currdepth - 1:
|
||||
|
|
@ -884,8 +864,8 @@ def readFullInheritanceRecurse(tag_id, event, order, prunes, top, hist, currdept
|
|||
if link['intransitive'] and reverse:
|
||||
# add link, but don't follow it
|
||||
continue
|
||||
readFullInheritanceRecurse(id, event, order, prunes, top, hist, currdepth, nextdepth,
|
||||
noconfig, filter, reverse, jumps)
|
||||
readFullInheritanceRecurse(id, event, order, top, hist, currdepth, nextdepth, noconfig,
|
||||
filter, reverse)
|
||||
|
||||
# tag-package operations
|
||||
# add
|
||||
|
|
@ -11612,28 +11592,19 @@ class RootExports(object):
|
|||
context.session.assertPerm('tag')
|
||||
return writeInheritanceData(tag, data, clear=clear)
|
||||
|
||||
def getFullInheritance(self, tag, event=None, reverse=False, stops=None, jumps=None):
|
||||
def getFullInheritance(self, tag, event=None, reverse=False):
|
||||
"""
|
||||
:param int|str tag: tag ID | name
|
||||
:param int event: event ID
|
||||
:param bool reverse: return reversed tree (descendants instead of
|
||||
parents)
|
||||
:param dict stops: dict of tag ids which should be ignored
|
||||
:param dict jumps: dict of tag ids which should be skipped
|
||||
|
||||
:returns: list of node dicts
|
||||
"""
|
||||
if stops is None:
|
||||
stops = {}
|
||||
if jumps is None:
|
||||
jumps = {}
|
||||
if not isinstance(tag, int):
|
||||
# lookup tag id
|
||||
tag = get_tag_id(tag, strict=True)
|
||||
for mapping in [stops, jumps]:
|
||||
for key in list(mapping.keys()):
|
||||
mapping[int(key)] = mapping[key]
|
||||
return readFullInheritance(tag, event, reverse, stops, jumps)
|
||||
return readFullInheritance(tag, event, reverse)
|
||||
|
||||
listRPMs = staticmethod(list_rpms)
|
||||
|
||||
|
|
|
|||
|
|
@ -55,3 +55,27 @@ class TestListTagInheritance(utils.CliTestCase):
|
|||
anon_handle_list_tag_inheritance(self.options, self.session, [self.tag])
|
||||
self.assertExitCode(ex, 2)
|
||||
self.assert_console_message(stderr, expected)
|
||||
|
||||
def test_help(self):
|
||||
self.assert_help(
|
||||
anon_handle_list_tag_inheritance,
|
||||
"""Usage: %s list-tag-inheritance [options] <tag>
|
||||
|
||||
Prints tag inheritance with basic information about links.
|
||||
Four flags could be seen in the output:
|
||||
M - maxdepth - limits inheritance to n-levels
|
||||
F - package filter (packages ignored for inheritance)
|
||||
I - intransitive link - inheritance immediately stops here
|
||||
N - noconfig - if tag is used in buildroot, its configuration values will not be used
|
||||
|
||||
Exact values for maxdepth and package filter can be inquired by taginfo command.
|
||||
|
||||
(Specify the --help global option for a list of other help options)
|
||||
|
||||
Options:
|
||||
-h, --help show this help message and exit
|
||||
--reverse Process tag's children instead of its parents
|
||||
--event=EVENT# query at event
|
||||
--ts=TIMESTAMP query at last event before timestamp
|
||||
--repo=REPO# query at event for a repo
|
||||
""" % self.progname)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue