* [gentoo-commits] proj/portage:2.1.9 commit in: pym/portage/dep/, pym/_emerge/
@ 2011-02-14 4:31 Zac Medico
0 siblings, 0 replies; 3+ messages in thread
From: Zac Medico @ 2011-02-14 4:31 UTC (permalink / raw
To: gentoo-commits
commit: a81a22889c1eaec729badb498adc3b381b77818e
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 12 00:09:22 2011 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Feb 14 04:25:08 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=a81a2288
depgraph: fix distorted display of virtuals
As mentioned in bug #353933, comment #4, special new-style virtual
atoms generated/distorted by _expand_new_virtuals() can prevent
extract_affecting_use() from working properly. This is fixed by
saving the original atoms so that the depgraph can map them back
into place at the appropriate step in dependency evaluation.
---
pym/_emerge/depgraph.py | 13 +++++++++++++
pym/portage/dep/dep_check.py | 6 ++++++
2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 004103c..fc84be6 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -1259,6 +1259,12 @@ class depgraph(object):
for atom, child in self._minimize_children(
pkg, dep_priority, root_config, selected_atoms[pkg]):
+ # If this was a specially generated virtual atom
+ # from dep_check, map it back to the original, in
+ # order to avoid distortion in places like display
+ # or conflict resolution code.
+ atom = getattr(atom, '_orig_atom', atom)
+
if ignore_blockers and atom.blocker:
# For --with-bdeps, ignore build-time only blockers
# that originate from built packages.
@@ -1309,6 +1315,13 @@ class depgraph(object):
for atom, child in self._minimize_children(
pkg, self._priority(runtime=True), root_config, atoms):
+
+ # If this was a specially generated virtual atom
+ # from dep_check, map it back to the original, in
+ # order to avoid distortion in places like display
+ # or conflict resolution code.
+ atom = getattr(atom, '_orig_atom', atom)
+
# This is a GLEP 37 virtual, so its deps are all runtime.
mypriority = self._priority(runtime=True)
if not atom.blocker:
diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py
index 6d2d99d..ed85be6 100644
--- a/pym/portage/dep/dep_check.py
+++ b/pym/portage/dep/dep_check.py
@@ -135,6 +135,12 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
pkg_use_enabled(parent))
else:
virt_atom = Atom(virt_atom)
+
+ # Allow the depgraph to map this atom back to the
+ # original, in order to avoid distortion in places
+ # like display or conflict resolution code.
+ virt_atom.__dict__['_orig_atom'] = x
+
# According to GLEP 37, RDEPEND is the only dependency
# type that is valid for new-style virtuals. Repoman
# should enforce this.
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-commits] proj/portage:2.1.9 commit in: pym/portage/dep/, pym/_emerge/
@ 2011-02-14 4:31 Zac Medico
0 siblings, 0 replies; 3+ messages in thread
From: Zac Medico @ 2011-02-14 4:31 UTC (permalink / raw
To: gentoo-commits
commit: e76062cf65fb2cee414035f45acef66661c9f71d
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 13 01:52:11 2011 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Feb 14 04:25:42 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=e76062cf
depgraph: return virtual edges from select_atoms
---
pym/_emerge/depgraph.py | 78 ++++++++++++++++++++++-------------------
pym/portage/dep/dep_check.py | 7 ++--
2 files changed, 46 insertions(+), 39 deletions(-)
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 22d9314..58dd451 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -12,7 +12,7 @@ import textwrap
from itertools import chain
import portage
-from portage import os
+from portage import os, OrderedDict
from portage import _unicode_decode
from portage.const import PORTAGE_PACKAGE_ATOM
from portage.dbapi import dbapi
@@ -1296,31 +1296,16 @@ class depgraph(object):
# by dep_zapdeps. We preserve actual parent/child relationships
# here in order to avoid distorting the dependency graph like
# <=portage-2.1.6.x did.
- while selected_atoms:
-
- # Since _select_atoms currently doesn't return parent
- # info for recursively traversed virtuals, the parent
- # is not known here. However, this package may have
- # already been added to graph above, so we add packages
- # with parents first. This way, parents are already
- # recorded before a given package is added, which allows
- # us to avoid triggering a slot conflict before the
- # parent is known.
- for virt_pkg, atoms in selected_atoms.items():
- try:
- if self._dynamic_config.digraph.parent_nodes(virt_pkg):
- break
- except KeyError:
- pass
+ for virt_dep, atoms in selected_atoms.items():
- selected_atoms.pop(virt_pkg)
+ virt_pkg = virt_dep.child
if debug:
writemsg_level("Candidates: %s: %s\n" % \
(virt_pkg.cpv, [str(x) for x in atoms]),
noiselevel=-1, level=logging.DEBUG)
- if not self._add_pkg(virt_pkg, None):
+ if not self._add_pkg(virt_pkg, virt_dep):
return 0
for atom, child in self._minimize_children(
@@ -2176,26 +2161,47 @@ class depgraph(object):
selected_atoms = mycheck[1]
else:
chosen_atoms = frozenset(mycheck[1])
- selected_atoms = {parent : []}
- for node in atom_graph:
- if isinstance(node, Atom):
- continue
+ selected_atoms = OrderedDict()
+ node_stack = [(parent, None, None)]
+ traversed_nodes = set()
+ while node_stack:
+ node, node_parent, parent_atom = node_stack.pop()
+ traversed_nodes.add(node)
if node is parent:
- pkg = parent
+ k = parent
else:
- pkg, virt_atom = node
- if virt_atom not in chosen_atoms:
- continue
- if not portage.match_from_list(virt_atom, [pkg]):
- # Typically this means that the atom
- # specifies USE deps that are unsatisfied
- # by the selected package. The caller will
- # record this as an unsatisfied dependency
- # when necessary.
+ if node_parent is parent:
+ if priority is None:
+ node_priority = None
+ else:
+ node_priority = priority.copy()
+ else:
+ # virtuals only have runtime deps
+ node_priority = self._priority(runtime=True)
+ k = Dependency(atom=parent_atom,
+ blocker=parent_atom.blocker, child=node,
+ depth=node.depth, parent=node_parent,
+ priority=node_priority, root=node.root)
+
+ child_atoms = atom_graph.child_nodes(node)
+ selected_atoms[k] = [atom for atom in \
+ child_atoms if atom in chosen_atoms]
+ for child_atom in child_atoms:
+ if child_atom not in chosen_atoms:
continue
-
- selected_atoms[pkg] = [atom for atom in \
- atom_graph.child_nodes(node) if atom in chosen_atoms]
+ for child_node in atom_graph.child_nodes(child_atom):
+ if child_node in traversed_nodes:
+ continue
+ if not portage.match_from_list(
+ child_atom, [child_node]):
+ # Typically this means that the atom
+ # specifies USE deps that are unsatisfied
+ # by the selected package. The caller will
+ # record this as an unsatisfied dependency
+ # when necessary.
+ continue
+ child_node.depth = node.depth + 1
+ node_stack.append((child_node, node, child_atom))
return selected_atoms
diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py
index ed85be6..200f016 100644
--- a/pym/portage/dep/dep_check.py
+++ b/pym/portage/dep/dep_check.py
@@ -36,7 +36,7 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
if parent is not None:
if virt_parent is not None:
graph_parent = virt_parent
- parent = virt_parent[0]
+ parent = virt_parent
else:
graph_parent = parent
eapi = parent.metadata["EAPI"]
@@ -154,7 +154,7 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
% (depstring,), noiselevel=-1, level=logging.DEBUG)
# Set EAPI used for validation in dep_check() recursion.
- mytrees["virt_parent"] = (pkg, virt_atom)
+ mytrees["virt_parent"] = pkg
try:
mycheck = dep_check(depstring, mydbapi, mysettings,
@@ -175,6 +175,7 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
a.append(mycheck[1])
if atom_graph is not None:
atom_graph.add(virt_atom, graph_parent)
+ atom_graph.add(pkg, virt_atom)
# Plain old-style virtuals. New-style virtuals are preferred.
if not pkgs:
for y in mychoices:
@@ -560,7 +561,7 @@ def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None,
eapi = None
if parent is not None:
if virt_parent is not None:
- current_parent = virt_parent[0]
+ current_parent = virt_parent
else:
current_parent = parent
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-commits] proj/portage:2.1.9 commit in: pym/portage/dep/, pym/_emerge/
@ 2011-02-14 4:31 Zac Medico
0 siblings, 0 replies; 3+ messages in thread
From: Zac Medico @ 2011-02-14 4:31 UTC (permalink / raw
To: gentoo-commits
commit: 38d668d8734de42e6c27affe16dd0e2a21af35d3
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 13 07:36:07 2011 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Feb 14 04:26:00 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=38d668d8
depgraph: avoid atom hash collisions in dep_check
Atoms are stored in the graph as (atom, id(atom)) tuples since each
atom is considered to be a unique entity. For example, atoms that
appear identical may behave differently in USE matching, depending on
their unevaluated form. Also, specially generated virtual atoms may
appear identical while having different _orig_atom attributes.
---
pym/_emerge/depgraph.py | 15 ++++++++-------
pym/portage/dep/dep_check.py | 24 ++++++++++++++++--------
2 files changed, 24 insertions(+), 15 deletions(-)
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 58dd451..8f1e00a 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -2160,7 +2160,7 @@ class depgraph(object):
if parent is None:
selected_atoms = mycheck[1]
else:
- chosen_atoms = frozenset(mycheck[1])
+ chosen_atom_ids = frozenset(id(atom) for atom in mycheck[1])
selected_atoms = OrderedDict()
node_stack = [(parent, None, None)]
traversed_nodes = set()
@@ -2183,13 +2183,14 @@ class depgraph(object):
depth=node.depth, parent=node_parent,
priority=node_priority, root=node.root)
- child_atoms = atom_graph.child_nodes(node)
- selected_atoms[k] = [atom for atom in \
- child_atoms if atom in chosen_atoms]
- for child_atom in child_atoms:
- if child_atom not in chosen_atoms:
+ child_atoms = []
+ selected_atoms[k] = child_atoms
+ for atom_node in atom_graph.child_nodes(node):
+ child_atom = atom_node[0]
+ if id(child_atom) not in chosen_atom_ids:
continue
- for child_node in atom_graph.child_nodes(child_atom):
+ child_atoms.append(child_atom)
+ for child_node in atom_graph.child_nodes(atom_node):
if child_node in traversed_nodes:
continue
if not portage.match_from_list(
diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py
index 200f016..4d26f51 100644
--- a/pym/portage/dep/dep_check.py
+++ b/pym/portage/dep/dep_check.py
@@ -28,6 +28,12 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
mytrees = trees[myroot]
portdb = mytrees["porttree"].dbapi
pkg_use_enabled = mytrees.get("pkg_use_enabled")
+ # Atoms are stored in the graph as (atom, id(atom)) tuples
+ # since each atom is considered to be a unique entity. For
+ # example, atoms that appear identical may behave differently
+ # in USE matching, depending on their unevaluated form. Also,
+ # specially generated virtual atoms may appear identical while
+ # having different _orig_atom attributes.
atom_graph = mytrees.get("atom_graph")
parent = mytrees.get("parent")
virt_parent = mytrees.get("virt_parent")
@@ -67,7 +73,7 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
if not mykey.startswith("virtual/"):
newsplit.append(x)
if atom_graph is not None:
- atom_graph.add(x, graph_parent)
+ atom_graph.add((x, id(x)), graph_parent)
continue
mychoices = myvirtuals.get(mykey, [])
if x.blocker:
@@ -76,7 +82,7 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
# maintaining a cache of blocker atoms.
newsplit.append(x)
if atom_graph is not None:
- atom_graph.add(x, graph_parent)
+ atom_graph.add((x, id(x)), graph_parent)
continue
if repoman or not hasattr(portdb, 'match_pkgs') or \
@@ -115,7 +121,7 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
# dependency that needs to be satisfied.
newsplit.append(x)
if atom_graph is not None:
- atom_graph.add(x, graph_parent)
+ atom_graph.add((x, id(x)), graph_parent)
continue
a = []
@@ -174,8 +180,9 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
mycheck[1].append(virt_atom)
a.append(mycheck[1])
if atom_graph is not None:
- atom_graph.add(virt_atom, graph_parent)
- atom_graph.add(pkg, virt_atom)
+ virt_atom_node = (virt_atom, id(virt_atom))
+ atom_graph.add(virt_atom_node, graph_parent)
+ atom_graph.add(pkg, virt_atom_node)
# Plain old-style virtuals. New-style virtuals are preferred.
if not pkgs:
for y in mychoices:
@@ -187,7 +194,8 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
portdb.aux_get(matches[-1], ['PROVIDE'])[0].split():
a.append(new_atom)
if atom_graph is not None:
- atom_graph.add(new_atom, graph_parent)
+ atom_graph.add((new_atom, id(new_atom)),
+ graph_parent)
if not a and mychoices:
# Check for a virtual package.provided match.
@@ -197,12 +205,12 @@ def _expand_new_virtuals(mysplit, edebug, mydbapi, mysettings, myroot="/",
pprovideddict.get(new_atom.cp, [])):
a.append(new_atom)
if atom_graph is not None:
- atom_graph.add(new_atom, graph_parent)
+ atom_graph.add((new_atom, id(new_atom)), graph_parent)
if not a:
newsplit.append(x)
if atom_graph is not None:
- atom_graph.add(x, graph_parent)
+ atom_graph.add((x, id(x)), graph_parent)
elif len(a) == 1:
newsplit.append(a[0])
else:
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-02-14 4:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-14 4:31 [gentoo-commits] proj/portage:2.1.9 commit in: pym/portage/dep/, pym/_emerge/ Zac Medico
-- strict thread matches above, loose matches on Subject: below --
2011-02-14 4:31 Zac Medico
2011-02-14 4:31 Zac Medico
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox