Gentoo Archives: gentoo-portage-dev

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

Replies