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
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 = {}
_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
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
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
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:
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():
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":
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,
# 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)
#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()