commit: cc8724b80ec7da713baed3d3a88c0bb99fc368b7
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 15 06:58:54 2015 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Jul 15 19:27:52 2015 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=cc8724b8
depgraph._want_update_pkg: handle _UNREACHABLE_DEPTH (bug 554928)
Since commit 336ab90212c80ce9548362bf4fbdafd388c3515c, package depth
can refer to _UNREACHABLE_DEPTH which is not an integer. Add
_too_deep and _increment_depth methods to handle depth operations.
Fixes: 336ab90212c8 ("depgraph._add_dep: fix bug #52095")
X-Gentoo-Bug: 554928
X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=554928
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>
pym/_emerge/depgraph.py | 34 ++++++++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index ba897d0..1683280 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -2799,7 +2799,7 @@ class depgraph(object):
dep.want_update = (not self._dynamic_config._complete_mode and
(arg_atoms or update) and
- not (deep is not True and depth > deep))
+ not self._too_deep(depth))
dep.child = pkg
if not pkg.onlydeps and dep.atom and (
@@ -2807,7 +2807,8 @@ class depgraph(object):
dep.atom.slot_operator == "="):
self._add_slot_operator_dep(dep)
- recurse = deep is True or depth + 1 <= deep
+ recurse = (deep is True or
+ not self._too_deep(self._depth_increment(depth, n=1)))
dep_stack = self._dynamic_config._dep_stack
if "recurse" not in self._dynamic_config.myparams:
return 1
@@ -5348,12 +5349,37 @@ class depgraph(object):
depth = 0
break
- deep = self._dynamic_config.myparams.get("deep", 0)
update = "--update" in self._frozen_config.myopts
return (not self._dynamic_config._complete_mode and
(arg_atoms or update) and
- not (deep is not True and depth > deep))
+ not self._too_deep(depth))
+
+ def _too_deep(self, depth):
+ """
+ Check if a package depth is deeper than the max allowed depth.
+
+ @param depth: the depth of a particular package
+ @type depth: int or _UNREACHABLE_DEPTH
+ @rtype: bool
+ @return: True if the package is deeper than the max allowed
depth
+ """
+ deep = self._dynamic_config.myparams.get("deep", 0)
+ return depth is self._UNREACHABLE_DEPTH or (
+ isinstance(deep, int) and isinstance(depth, int) and
depth > deep)
+
+ def _depth_increment(self, depth, n=1):
+ """
+ Return depth + n if depth is an int, otherwise return depth.
+
+ @param depth: the depth of a particular package
+ @type depth: int or _UNREACHABLE_DEPTH
+ @param n: number to add (default is 1)
+ @type n: int
+ @rtype: int or _UNREACHABLE_DEPTH
+ @return: depth + 1 or _UNREACHABLE_DEPTH
+ """
+ return depth + n if isinstance(depth, int) else depth
def _equiv_ebuild_visible(self, pkg, autounmask_level=None):
try: