From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1PoZ7H-000803-7L for garchives@archives.gentoo.org; Sun, 13 Feb 2011 10:23:48 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D9652E09CA; Sun, 13 Feb 2011 10:23:35 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 9C818E09CA for ; Sun, 13 Feb 2011 10:23:35 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 1C5201B4032 for ; Sun, 13 Feb 2011 10:23:35 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 84CC48006A for ; Sun, 13 Feb 2011 10:23:34 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <5655b4dcfe5e9dae5e9d6352d791c3d04953baf7.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/tests/resolver/, pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/depgraph.py pym/portage/tests/resolver/test_depth.py X-VCS-Directories: pym/portage/tests/resolver/ pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 5655b4dcfe5e9dae5e9d6352d791c3d04953baf7 Date: Sun, 13 Feb 2011 10:23:34 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 57a4720c97aff7941400ec2acba5709f commit: 5655b4dcfe5e9dae5e9d6352d791c3d04953baf7 Author: Zac Medico gentoo org> AuthorDate: Sun Feb 13 10:20:24 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Sun Feb 13 10:20:24 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D5655b4dc depgraph: fix and test --deep control of depth Control over recursion depth hasn't behaved properly since commit 6503980e0e3bcfce9fbaff85c33d87f616e955a9. Now it is fixed and tested. --- pym/_emerge/depgraph.py | 44 +++++++++++++++++++++++-= - pym/portage/tests/resolver/test_depth.py | 53 ++++++++++++++++++++++++= ++++++ 2 files changed, 94 insertions(+), 3 deletions(-) diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index bec9ffd..72fc1ae 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -18,7 +18,7 @@ from portage.const import PORTAGE_PACKAGE_ATOM from portage.dbapi import dbapi from portage.dep import Atom, extract_affecting_use, check_required_use,= human_readable_required_use, _repo_separator from portage.eapi import eapi_has_strong_blocks, eapi_has_required_use -from portage.exception import InvalidAtom +from portage.exception import InvalidAtom, InvalidDependString from portage.output import colorize, create_color_func, \ darkgreen, green bad =3D create_color_func("BAD") @@ -1206,6 +1206,8 @@ class depgraph(object): def _add_pkg_dep_string(self, pkg, dep_root, dep_priority, dep_string, allow_unsatisfied, ignore_blockers=3DFalse): depth =3D pkg.depth + 1 + deep =3D self._dynamic_config.myparams.get("deep", 0) + recurse_satisfied =3D deep is True or depth <=3D deep debug =3D "--debug" in self._frozen_config.myopts strict =3D pkg.type_name !=3D "installed" =20 @@ -1244,6 +1246,7 @@ class depgraph(object): # from dep_check, map it back to the original, in # order to avoid distortion in places like display # or conflict resolution code. + is_virt =3D hasattr(atom, '_orig_atom') atom =3D getattr(atom, '_orig_atom', atom) =20 if ignore_blockers and atom.blocker: @@ -1264,9 +1267,44 @@ class depgraph(object): # none visible, so use highest mypriority.satisfied =3D inst_pkgs[0] =20 - if not self._add_dep(Dependency(atom=3Datom, + dep =3D Dependency(atom=3Datom, blocker=3Datom.blocker, child=3Dchild, depth=3Ddepth, parent=3Dpkg, - priority=3Dmypriority, root=3Ddep_root), + priority=3Dmypriority, root=3Ddep_root) + + # In some cases, dep_check will return deps that shouldn't + # be proccessed any further, so they are identified and + # discarded here. Try to discard as few as possible since + # discarded dependencies reduce the amount of information + # available for optimization of merge order. + ignored =3D False + if not atom.blocker and \ + not is_virt and \ + not recurse_satisfied and \ + mypriority.satisfied and \ + mypriority.satisfied.visible and \ + dep.child is not None and \ + not dep.child.installed: + myarg =3D None + if dep.root =3D=3D self._frozen_config.target_root: + try: + myarg =3D next(self._iter_atoms_for_pkg(dep.child)) + except StopIteration: + pass + except InvalidDependString: + if not dep.child.installed: + # This shouldn't happen since the package + # should have been masked. + raise + + if myarg is None: + # Existing child selection may not be valid unless + # it's added to the graph immediately, since "complete" + # mode may select a different child later. + ignored =3D True + dep.child =3D None + self._dynamic_config._ignored_deps.append(dep) + + if not ignored and not self._add_dep(dep, allow_unsatisfied=3Dallow_unsatisfied): return 0 =20 diff --git a/pym/portage/tests/resolver/test_depth.py b/pym/portage/tests= /resolver/test_depth.py new file mode 100644 index 0000000..5a30941 --- /dev/null +++ b/pym/portage/tests/resolver/test_depth.py @@ -0,0 +1,53 @@ +# Copyright 2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +from portage.tests import TestCase +from portage.tests.resolver.ResolverPlayground import (ResolverPlaygroun= d, + ResolverPlaygroundTestCase) + +class ResolverDepthTestCase(TestCase): + + def testResolverDepth(self): + + ebuilds =3D { + "dev-libs/A-1": {"RDEPEND" : "dev-libs/B"}, + "dev-libs/A-2": {"RDEPEND" : "dev-libs/B"}, + "dev-libs/B-1": {"RDEPEND" : "dev-libs/C"}, + "dev-libs/B-2": {"RDEPEND" : "dev-libs/C"}, + "dev-libs/C-1": {}, + "dev-libs/C-2": {}, + } + + installed =3D { + "dev-libs/A-1": {"RDEPEND" : "dev-libs/B"}, + "dev-libs/B-1": {"RDEPEND" : "dev-libs/C"}, + "dev-libs/C-1": {}, + } + + test_cases =3D ( + ResolverPlaygroundTestCase( + ["dev-libs/A"], + options =3D {"--update": True, "--deep": 0}, + success =3D True, + mergelist =3D ["dev-libs/A-2"]), + + ResolverPlaygroundTestCase( + ["dev-libs/A"], + options =3D {"--update": True, "--deep": 1}, + success =3D True, + mergelist =3D ["dev-libs/B-2", "dev-libs/A-2"]), + + ResolverPlaygroundTestCase( + ["dev-libs/A"], + options =3D {"--update": True, "--deep": 3}, + success =3D True, + mergelist =3D ["dev-libs/C-2", "dev-libs/B-2", "dev-libs/A-2"]), + ) + + playground =3D ResolverPlayground(ebuilds=3Debuilds, installed=3Dinsta= lled) + 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()