summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Luther <SebastianLuther@gmx.de>2010-08-07 10:51:51 +0200
committerZac Medico <zmedico@gentoo.org>2010-08-07 18:48:59 -0700
commit026f630247c7ec77f4bb46e01091b9f0c2b74201 (patch)
tree92c624efbd7734b6ab26e91da7b44b64281ebe09
parent7a0227049551d919d3bb766a57834d7dc3ccc9c8 (diff)
downloadportage-026f630247c7ec77f4bb46e01091b9f0c2b74201.tar.gz
portage-026f630247c7ec77f4bb46e01091b9f0c2b74201.tar.bz2
portage-026f630247c7ec77f4bb46e01091b9f0c2b74201.zip
autounmask: rename _needed_user_config_changes in _needed_unstable_keywords. Let the tests check for it.
-rw-r--r--pym/_emerge/depgraph.py43
-rw-r--r--pym/portage/tests/resolver/ResolverPlayground.py10
-rw-r--r--pym/portage/tests/resolver/test_autounmask.py56
3 files changed, 57 insertions, 52 deletions
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 1d78a0cbd..91b3a1548 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -111,7 +111,7 @@ class _frozen_depgraph_config(object):
class _dynamic_depgraph_config(object):
def __init__(self, depgraph, myparams, allow_backtracking,
- runtime_pkg_mask, needed_user_config_changes, needed_use_config_changes):
+ runtime_pkg_mask, needed_unstable_keywords, needed_use_config_changes):
self.myparams = myparams.copy()
self._vdb_loaded = False
self._allow_backtracking = allow_backtracking
@@ -188,12 +188,10 @@ class _dynamic_depgraph_config(object):
runtime_pkg_mask = dict((k, v.copy()) for (k, v) in \
runtime_pkg_mask.items())
- if needed_user_config_changes is None:
- self._needed_user_config_changes = {}
+ if needed_unstable_keywords is None:
+ self._needed_unstable_keywords = set()
else:
- self._needed_user_config_changes = \
- dict((k.copy(), v.copy()) for (k, v) in \
- needed_user_config_changes.items())
+ self._needed_unstable_keywords = needed_unstable_keywords.copy()
if needed_use_config_changes is None:
self._needed_use_config_changes = {}
@@ -274,14 +272,14 @@ class depgraph(object):
_dep_keys = ["DEPEND", "RDEPEND", "PDEPEND"]
def __init__(self, settings, trees, myopts, myparams, spinner,
- frozen_config=None, runtime_pkg_mask=None, needed_user_config_changes=None, \
+ frozen_config=None, runtime_pkg_mask=None, needed_unstable_keywords=None, \
needed_use_config_changes=None, allow_backtracking=False):
if frozen_config is None:
frozen_config = _frozen_depgraph_config(settings, trees,
myopts, spinner)
self._frozen_config = frozen_config
self._dynamic_config = _dynamic_depgraph_config(self, myparams,
- allow_backtracking, runtime_pkg_mask, needed_user_config_changes, needed_use_config_changes)
+ allow_backtracking, runtime_pkg_mask, needed_unstable_keywords, needed_use_config_changes)
self._select_atoms = self._select_atoms_highest_available
self._select_package = self._select_pkg_highest_available
@@ -1995,7 +1993,7 @@ class depgraph(object):
return False, myfavorites
if set(self._dynamic_config.digraph.nodes.keys()).intersection( \
- set(self._dynamic_config._needed_user_config_changes.keys())) or \
+ set(self._dynamic_config._needed_unstable_keywords)) or \
set(self._dynamic_config.digraph.nodes.keys()).intersection( \
set(self._dynamic_config._needed_use_config_changes.keys())) :
#We failed if the user needs to change the configuration
@@ -2553,7 +2551,7 @@ class depgraph(object):
pkg = None
if pkg is not None and not pkg.visible:
- self._dynamic_config._needed_user_config_changes.setdefault(pkg, set()).add("unstable keyword")
+ self._dynamic_config._needed_unstable_keywords.add(pkg)
if self._dynamic_config._need_restart:
return None, None
@@ -2566,13 +2564,10 @@ class depgraph(object):
return pkg, existing
def _pkg_visibility_check(self, pkg, allow_unstable_keywords=False):
-
if pkg.visible:
return True
- pending_keyword_change = self._dynamic_config._needed_user_config_changes.get(pkg)
- if pending_keyword_change is not None and \
- "unstable keyword" in pending_keyword_change:
+ if pkg in self._dynamic_config._needed_unstable_keywords:
return True
if not allow_unstable_keywords:
@@ -5289,16 +5284,12 @@ class depgraph(object):
return msg
unstable_keyword_msg = []
- for pkg, changes in self._dynamic_config._needed_user_config_changes.items():
+ for pkg in self._dynamic_config._needed_unstable_keywords:
self._show_merge_list()
if pkg in self._dynamic_config.digraph.nodes.keys():
- for change in changes:
- if change == "unstable keyword":
- pkgsettings = self._frozen_config.pkgsettings[pkg.root]
- unstable_keyword_msg.append(get_dep_chain(pkg))
- unstable_keyword_msg.append("=%s ~%s\n" % (pkg.cpv, pkgsettings["ACCEPT_KEYWORDS"]))
- else:
- raise NotImplementedError()
+ pkgsettings = self._frozen_config.pkgsettings[pkg.root]
+ unstable_keyword_msg.append(get_dep_chain(pkg))
+ unstable_keyword_msg.append("=%s ~%s\n" % (pkg.cpv, pkgsettings["ACCEPT_KEYWORDS"]))
use_changes_msg = []
for pkg, needed_use_config_change in self._dynamic_config._needed_use_config_changes.items():
@@ -5716,8 +5707,8 @@ class depgraph(object):
def get_backtrack_parameters(self):
return {
- "needed_user_config_changes":
- self._dynamic_config._needed_user_config_changes.copy(), \
+ "needed_unstable_keywords":
+ self._dynamic_config._needed_unstable_keywords.copy(), \
"runtime_pkg_mask":
self._dynamic_config._runtime_pkg_mask.copy(),
"needed_use_config_changes":
@@ -5955,7 +5946,7 @@ def _backtrack_depgraph(settings, trees, myopts, myparams,
backtrack_max = myopts.get('--backtrack', 5)
backtrack_parameters = {}
- needed_user_config_changes = None
+ needed_unstable_keywords = None
allow_backtracking = backtrack_max > 0
backtracked = 0
frozen_config = _frozen_depgraph_config(settings, trees,
@@ -5978,7 +5969,7 @@ def _backtrack_depgraph(settings, trees, myopts, myparams,
# Backtracking failed, so disable it and do
# a plain dep calculation + error message.
allow_backtracking = False
- #Don't reset needed_user_config_changes here, since we don't want to
+ #Don't reset needed_unstable_keywords here, since we don't want to
#send the user through a "one step at a time" unmasking session for
#no good reason.
backtrack_parameters.pop('runtime_pkg_mask', None)
diff --git a/pym/portage/tests/resolver/ResolverPlayground.py b/pym/portage/tests/resolver/ResolverPlayground.py
index 6f658d8c1..b4ff4180c 100644
--- a/pym/portage/tests/resolver/ResolverPlayground.py
+++ b/pym/portage/tests/resolver/ResolverPlayground.py
@@ -203,7 +203,8 @@ class ResolverPlaygroundResult(object):
self.depgraph = mydepgraph
self.favorites = favorites
self.mergelist = None
- self.use_changes = None
+ self.use_changes = None
+ self.unstable_keywords = None
if self.depgraph._dynamic_config._serialized_tasks_cache is not None:
self.mergelist = []
@@ -212,10 +213,15 @@ class ResolverPlaygroundResult(object):
self.mergelist.append(x.atom)
else:
self.mergelist.append(x.cpv)
-
+
if self.depgraph._dynamic_config._needed_use_config_changes:
self.use_changes = {}
for pkg, needed_use_config_changes in \
self.depgraph._dynamic_config._needed_use_config_changes.items():
new_use, changes = needed_use_config_changes
self.use_changes[pkg.cpv] = changes
+
+ if self.depgraph._dynamic_config._needed_unstable_keywords:
+ self.unstable_keywords = set()
+ for pkg in self.depgraph._dynamic_config._needed_unstable_keywords:
+ self.unstable_keywords.add(pkg.cpv)
diff --git a/pym/portage/tests/resolver/test_autounmask.py b/pym/portage/tests/resolver/test_autounmask.py
index 74cd98bea..d528f9077 100644
--- a/pym/portage/tests/resolver/test_autounmask.py
+++ b/pym/portage/tests/resolver/test_autounmask.py
@@ -41,68 +41,76 @@ class AutounmaskTestCase(TestCase):
#Test USE changes.
#The simple case.
- (["dev-libs/A:1"], {"--autounmask": "n"}, None, False, None, None),
+ (["dev-libs/A:1"], {"--autounmask": "n"}, None, False, None, None, None),
(["dev-libs/A:1"], {"--autounmask": True}, None, False, \
- ["dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1"], { "dev-libs/B-1": {"foo": True} }),
+ ["dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1"], { "dev-libs/B-1": {"foo": True} }, None),
#Make sure we restart if needed.
(["dev-libs/B", "dev-libs/A:1"], {"--autounmask": True}, None, False, \
- ["dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1"], { "dev-libs/B-1": {"foo": True} }),
+ ["dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1"], { "dev-libs/B-1": {"foo": True} }, None),
(["dev-libs/A:1", "dev-libs/B"], {"--autounmask": True}, None, False, \
- ["dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1"], { "dev-libs/B-1": {"foo": True} }),
+ ["dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1"], { "dev-libs/B-1": {"foo": True} }, None),
(["dev-libs/A:1", "dev-libs/A:2"], {"--autounmask": True}, None, False, \
- ["dev-libs/D-1", "dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1", "dev-libs/A-2"], { "dev-libs/B-1": {"foo": True, "bar": True} }),
+ ["dev-libs/D-1", "dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1", "dev-libs/A-2"], \
+ { "dev-libs/B-1": {"foo": True, "bar": True} }, None),
(["dev-libs/B", "dev-libs/A:1", "dev-libs/A:2"], {"--autounmask": True}, None, False, \
- ["dev-libs/D-1", "dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1", "dev-libs/A-2"], { "dev-libs/B-1": {"foo": True, "bar": True} }),
+ ["dev-libs/D-1", "dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1", "dev-libs/A-2"], \
+ { "dev-libs/B-1": {"foo": True, "bar": True} }, None),
(["dev-libs/A:1", "dev-libs/B", "dev-libs/A:2"], {"--autounmask": True}, None, False, \
- ["dev-libs/D-1", "dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1", "dev-libs/A-2"], { "dev-libs/B-1": {"foo": True, "bar": True} }),
+ ["dev-libs/D-1", "dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1", "dev-libs/A-2"], \
+ { "dev-libs/B-1": {"foo": True, "bar": True} }, None),
(["dev-libs/A:1", "dev-libs/A:2", "dev-libs/B"], {"--autounmask": True}, None, False, \
- ["dev-libs/D-1", "dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1", "dev-libs/A-2"], { "dev-libs/B-1": {"foo": True, "bar": True} }),
+ ["dev-libs/D-1", "dev-libs/C-1", "dev-libs/B-1", "dev-libs/A-1", "dev-libs/A-2"], \
+ { "dev-libs/B-1": {"foo": True, "bar": True} }, None),
#Test keywording.
#The simple case.
- (["app-misc/Z"], {"--autounmask": "n"}, None, False, None, None),
+ (["app-misc/Z"], {"--autounmask": "n"}, None, False, None, None, None),
(["app-misc/Z"], {"--autounmask": True}, None, False, \
- ["app-misc/Y-1", "app-misc/Z-1"], None),
+ ["app-misc/Y-1", "app-misc/Z-1"], None, ["app-misc/Y-1", "app-misc/Z-1"]),
#Make sure that the backtracking for slot conflicts handles our mess.
(["=app-misc/V-1", "app-misc/W"], {"--autounmask": True}, None, False, \
- ["app-misc/W-2", "app-misc/V-1"], None),
+ ["app-misc/W-2", "app-misc/V-1"], None, ["app-misc/W-2", "app-misc/V-1"]),
(["app-misc/W", "=app-misc/V-1"], {"--autounmask": True}, None, False, \
- ["app-misc/W-2", "app-misc/V-1"], None),
+ ["app-misc/W-2", "app-misc/V-1"], None, ["app-misc/W-2", "app-misc/V-1"]),
#Mixed testing
#Make sure we don't change use for something in a || dep if there is another choice
#that needs no change.
(["=sci-libs/K-1"], {"--autounmask": True}, None, True, \
- ["sci-libs/P-1", "sci-libs/K-1"], None),
+ ["sci-libs/P-1", "sci-libs/K-1"], None, None),
(["=sci-libs/K-2"], {"--autounmask": True}, None, True, \
- ["sci-libs/P-1", "sci-libs/K-2"], None),
+ ["sci-libs/P-1", "sci-libs/K-2"], None, None),
(["=sci-libs/K-3"], {"--autounmask": True}, None, True, \
- ["sci-libs/P-1", "sci-libs/K-3"], None),
+ ["sci-libs/P-1", "sci-libs/K-3"], None, None),
(["=sci-libs/K-4"], {"--autounmask": True}, None, True, \
- ["sci-libs/P-1", "sci-libs/K-4"], None),
+ ["sci-libs/P-1", "sci-libs/K-4"], None, None),
(["=sci-libs/K-5"], {"--autounmask": True}, None, True, \
- ["sci-libs/P-1", "sci-libs/K-5"], None),
+ ["sci-libs/P-1", "sci-libs/K-5"], None, None),
(["=sci-libs/K-6"], {"--autounmask": True}, None, True, \
- ["sci-libs/P-1", "sci-libs/K-6"], None),
+ ["sci-libs/P-1", "sci-libs/K-6"], None, None),
#Make sure we prefer use changes over keyword changes.
(["=sci-libs/K-7"], {"--autounmask": True}, None, False, \
- ["sci-libs/L-1", "sci-libs/K-7"], { "sci-libs/L-1": { "bar": True } }),
+ ["sci-libs/L-1", "sci-libs/K-7"], { "sci-libs/L-1": { "bar": True } }, None),
(["=sci-libs/K-8"], {"--autounmask": True}, None, False, \
- ["sci-libs/L-1", "sci-libs/K-8"], { "sci-libs/L-1": { "bar": True } }),
+ ["sci-libs/L-1", "sci-libs/K-8"], { "sci-libs/L-1": { "bar": True } }, None),
)
playground = ResolverPlayground(ebuilds=ebuilds)
try:
- for atoms, options, action, \
- expected_result, expected_mergelist, expected_use_changes in requests:
+ for atoms, options, action, expected_result, expected_mergelist, \
+ expected_use_changes, expected_unstable_keywords in requests:
result = playground.run(atoms, options, action)
- self.assertEqual((result.success, result.mergelist, result.use_changes),
- (expected_result, expected_mergelist, expected_use_changes))
+ if expected_unstable_keywords is not None:
+ expected_unstable_keywords = set(expected_unstable_keywords)
+ self.assertEqual(
+ (result.success, result.mergelist, result.use_changes, result.unstable_keywords),
+ (expected_result, expected_mergelist, expected_use_changes, expected_unstable_keywords)
+ )
finally:
playground.cleanup()