#2847 Remove jump/stops options from readFullInheritance
Merged 2 years ago by tkopecek. Opened 2 years ago by jcupova.
jcupova/koji issue-2656  into  master

file modified
+3 -25
@@ -8,7 +8,6 @@ 

  import os

  import pprint

  import random

- import re

  import stat

  import sys

  import textwrap
@@ -22,7 +21,7 @@ 

  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,

      _,
@@ -4180,8 +4179,8 @@ 

      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"))
@@ -4203,30 +4202,9 @@ 

  

      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'])

file modified
+8 -37
@@ -787,26 +787,15 @@ 

          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
@@ -823,8 +812,6 @@ 

              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:
@@ -832,16 +819,9 @@ 

                  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:
@@ -898,8 +878,8 @@ 

          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
@@ -11603,28 +11583,19 @@ 

          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 @@ 

              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)

Don't remove it completely, just use help=SUPRESS_HELP, so we don't break existing scripts.

rebased onto 01704db

2 years ago

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

2 years ago

Metadata Update from @mfilip:
- Pull-request tagged with: testing-done

2 years ago

Commit 750b13e fixes this pull-request

Pull-Request has been merged by tkopecek

2 years ago