Gentoo Archives: gentoo-portage-dev

From: Brian Dolbec <dolsen@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH] depgraph._want_update_pkg: handle _UNREACHABLE_DEPTH (bug 554928)
Date: Wed, 15 Jul 2015 14:37:02
Message-Id: 20150715073655.738a0070.dolsen@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH] depgraph._want_update_pkg: handle _UNREACHABLE_DEPTH (bug 554928) by Zac Medico
1 On Wed, 15 Jul 2015 01:12:35 -0700
2 Zac Medico <zmedico@g.o> wrote:
3
4 > Since commit 336ab90212c80ce9548362bf4fbdafd388c3515c, package depth
5 > can refer to _UNREACHABLE_DEPTH which is not an integer. Add
6 > _too_deep and _increment_depth methods to handle depth operations.
7 >
8 > Fixes: 336ab90212c8 ("depgraph._add_dep: fix bug #52095")
9 > X-Gentoo-Bug: 554928
10 > X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=554928
11 > ---
12 > pym/_emerge/depgraph.py | 34 ++++++++++++++++++++++++++++++----
13 > 1 file changed, 30 insertions(+), 4 deletions(-)
14 >
15 > diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
16 > index ba897d0..1683280 100644
17 > --- a/pym/_emerge/depgraph.py
18 > +++ b/pym/_emerge/depgraph.py
19 > @@ -2799,7 +2799,7 @@ class depgraph(object):
20 >
21 > dep.want_update = (not
22 > self._dynamic_config._complete_mode and (arg_atoms or update) and
23 > - not (deep is not True and depth > deep))
24 > + not self._too_deep(depth))
25 >
26 > dep.child = pkg
27 > if not pkg.onlydeps and dep.atom and (
28 > @@ -2807,7 +2807,8 @@ class depgraph(object):
29 > dep.atom.slot_operator == "="):
30 > self._add_slot_operator_dep(dep)
31 >
32 > - recurse = deep is True or depth + 1 <= deep
33 > + recurse = (deep is True or
34 > + not
35 > self._too_deep(self._depth_increment(depth, n=1))) dep_stack =
36 > self._dynamic_config._dep_stack if "recurse" not in
37 > self._dynamic_config.myparams: return 1
38 > @@ -5348,12 +5349,37 @@ class depgraph(object):
39 > depth = 0
40 > break
41 >
42 > - deep = self._dynamic_config.myparams.get("deep", 0)
43 > update = "--update" in self._frozen_config.myopts
44 >
45 > return (not self._dynamic_config._complete_mode and
46 > (arg_atoms or update) and
47 > - not (deep is not True and depth > deep))
48 > + not self._too_deep(depth))
49 > +
50 > + def _too_deep(self, depth):
51 > + """
52 > + Check if a package depth is deeper than the max
53 > allowed depth. +
54 > + @param depth: the depth of a particular package
55 > + @type depth: int or _UNREACHABLE_DEPTH
56 > + @rtype: bool
57 > + @return: True if the package is deeper than the max
58 > allowed depth
59 > + """
60 > + deep = self._dynamic_config.myparams.get("deep", 0)
61 > + return depth is self._UNREACHABLE_DEPTH or (
62 > + isinstance(deep, int) and isinstance(depth,
63 > int) and depth > deep) +
64 > + def _depth_increment(self, depth, n=1):
65 > + """
66 > + Return depth + n if depth is an int, otherwise
67 > return depth. +
68 > + @param depth: the depth of a particular package
69 > + @type depth: int or _UNREACHABLE_DEPTH
70 > + @param n: number to add (default is 1)
71 > + @type n: int
72 > + @rtype: int or _UNREACHABLE_DEPTH
73 > + @return: depth + 1 or _UNREACHABLE_DEPTH
74 > + """
75 > + return depth + n if isinstance(depth, int) else depth
76 >
77 > def _equiv_ebuild_visible(self, pkg, autounmask_level=None):
78 > try:
79
80 looks good.
81
82 When you first submitted that earlier patch that this fixes. I
83 scratched my head about the mismatched types which seemed to work
84 anyway.
85
86 --
87 Brian Dolbec <dolsen>