This fixes a case with --onlydeps were dep_zapdeps would pull in an
avoidable direct circular dependency on an onlydeps node. The logic
changes only apply to --onlydeps, so there's no chance of regressions
for cases when --onlydeps is not enabled.

X-Gentoo-Bug: 524916
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=524916
---
 pym/portage/dep/dep_check.py                       |  9 ++--
 .../tests/resolver/test_onlydeps_circular.py       | 49 ++++++++++++++++++++++
 2 files changed, 53 insertions(+), 5 deletions(-)
 create mode 100644 pym/portage/tests/resolver/test_onlydeps_circular.py

diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py
index 4386b5e..5dbe283 100644
--- a/pym/portage/dep/dep_check.py
+++ b/pym/portage/dep/dep_check.py
@@ -429,11 +429,10 @@ def dep_zapdeps(unreduced, reduced, myroot, 
use_binaries=0, trees=None):
                                                all_in_graph = False
                                                break
                                circular_atom = None
-                               if all_in_graph:
-                                       if parent is None or priority is None:
-                                               pass
-                                       elif priority.buildtime and \
-                                               not (priority.satisfied or 
priority.optional):
+                               if not (parent is None or priority is None) and 
\
+                                       (parent.onlydeps or
+                                       (all_in_graph and priority.buildtime 
and \
+                                       not (priority.satisfied or 
priority.optional))):
                                                # Check if the atom would 
result in a direct circular
                                                # dependency and try to avoid 
that if it seems likely
                                                # to be unresolvable. This is 
only relevant for
diff --git a/pym/portage/tests/resolver/test_onlydeps_circular.py 
b/pym/portage/tests/resolver/test_onlydeps_circular.py
new file mode 100644
index 0000000..f7cd0a2
--- /dev/null
+++ b/pym/portage/tests/resolver/test_onlydeps_circular.py
@@ -0,0 +1,49 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+from portage.tests import TestCase
+from portage.tests.resolver.ResolverPlayground import ResolverPlayground, 
ResolverPlaygroundTestCase
+
+class OnlydepsTestCase(TestCase):
+
+       def testOnlydeps(self):
+               ebuilds = {
+                       "app-misc/A-1": {
+                               "EAPI": "5",
+                               "SLOT": "1",
+                               "DEPEND": "|| ( app-misc/B app-misc/A:1 )"
+                       },
+                       "app-misc/A-2": {
+                               "EAPI": "5",
+                               "SLOT": "2",
+                       },
+                       "app-misc/B-0": {
+                               "EAPI": "5",
+                       }
+               }
+
+               installed = {
+                       "app-misc/A-2": {
+                               "EAPI": "5",
+                               "SLOT": "2",
+                       }
+               }
+
+               test_cases = (
+                       # bug 524916 - direct circular dep should not pull
+                       # in an onlydeps node when possible
+                       ResolverPlaygroundTestCase(
+                               ["app-misc/A:1"],
+                               success = True,
+                               options = { "--onlydeps": True },
+                               mergelist = ["app-misc/B-0"]),
+               )
+
+               playground = ResolverPlayground(ebuilds=ebuilds,
+                       installed=installed, debug=False)
+               try:
+                       for test_case in test_cases:
+                               playground.run_TestCase(test_case)
+                               self.assertEqual(test_case.test_success, True, 
test_case.fail_msg)
+               finally:
+                       playground.cleanup()
-- 
2.0.4


Reply via email to