* [gentoo-portage-dev] [PATCH] depgraph._want_update_pkg: handle _UNREACHABLE_DEPTH (bug 554928)
@ 2015-07-15 8:12 Zac Medico
2015-07-15 14:36 ` Brian Dolbec
0 siblings, 1 reply; 2+ messages in thread
From: Zac Medico @ 2015-07-15 8:12 UTC (permalink / raw
To: gentoo-portage-dev; +Cc: Zac Medico
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
---
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:
--
2.3.6
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [gentoo-portage-dev] [PATCH] depgraph._want_update_pkg: handle _UNREACHABLE_DEPTH (bug 554928)
2015-07-15 8:12 [gentoo-portage-dev] [PATCH] depgraph._want_update_pkg: handle _UNREACHABLE_DEPTH (bug 554928) Zac Medico
@ 2015-07-15 14:36 ` Brian Dolbec
0 siblings, 0 replies; 2+ messages in thread
From: Brian Dolbec @ 2015-07-15 14:36 UTC (permalink / raw
To: gentoo-portage-dev
On Wed, 15 Jul 2015 01:12:35 -0700
Zac Medico <zmedico@gentoo.org> wrote:
> 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
> ---
> 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:
looks good.
When you first submitted that earlier patch that this fixes. I
scratched my head about the mismatched types which seemed to work
anyway.
--
Brian Dolbec <dolsen>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-07-15 14:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-15 8:12 [gentoo-portage-dev] [PATCH] depgraph._want_update_pkg: handle _UNREACHABLE_DEPTH (bug 554928) Zac Medico
2015-07-15 14:36 ` Brian Dolbec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox