Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/tests/resolver/, pym/portage/dep/, pym/_emerge/
Date: Tue, 30 Jul 2013 05:07:58
Message-Id: 1375160666.94130821ab21186aeca7c514236a60acf6a71082.zmedico@gentoo
1 commit: 94130821ab21186aeca7c514236a60acf6a71082
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Tue Jul 30 05:04:26 2013 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Tue Jul 30 05:04:26 2013 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=94130821
7
8 Pull in new slots when appropriate, bug #478188.
9
10 ---
11 pym/_emerge/depgraph.py | 27 ++++++++++++++++++++++
12 pym/portage/dep/dep_check.py | 33 +++++++++++++++++++++++----
13 pym/portage/tests/resolver/test_or_choices.py | 16 ++++++++++++-
14 3 files changed, 70 insertions(+), 6 deletions(-)
15
16 diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
17 index a7316f0..c1f1ab0 100644
18 --- a/pym/_emerge/depgraph.py
19 +++ b/pym/_emerge/depgraph.py
20 @@ -454,6 +454,7 @@ class _dynamic_depgraph_config(object):
21 self._graph_trees[myroot]["vartree"] = graph_tree
22 self._graph_trees[myroot]["graph_db"] = graph_tree.dbapi
23 self._graph_trees[myroot]["graph"] = self.digraph
24 + self._graph_trees[myroot]["want_update_pkg"] = depgraph._want_update_pkg
25 def filtered_tree():
26 pass
27 filtered_tree.dbapi = _dep_check_composite_db(depgraph, myroot)
28 @@ -480,6 +481,7 @@ class _dynamic_depgraph_config(object):
29 self._filtered_trees[myroot]["graph"] = self.digraph
30 self._filtered_trees[myroot]["vartree"] = \
31 depgraph._frozen_config.trees[myroot]["vartree"]
32 + self._filtered_trees[myroot]["want_update_pkg"] = depgraph._want_update_pkg
33
34 dbs = []
35 # (db, pkg_type, built, installed, db_keys)
36 @@ -4314,6 +4316,31 @@ class depgraph(object):
37
38 return not arg
39
40 + def _want_update_pkg(self, parent, pkg):
41 + arg_atoms = None
42 + try:
43 + arg_atoms = list(self._iter_atoms_for_pkg(pkg))
44 + except InvalidDependString:
45 + if not pkg.installed:
46 + # should have been masked before it was selected
47 + raise
48 +
49 + depth = parent.depth or 0
50 + depth += 1
51 +
52 + if arg_atoms:
53 + for arg, atom in arg_atoms:
54 + if arg.reset_depth:
55 + depth = 0
56 + break
57 +
58 + deep = self._dynamic_config.myparams.get("deep", 0)
59 + update = "--update" in self._frozen_config.myopts
60 +
61 + return (not self._dynamic_config._complete_mode and
62 + (arg_atoms or update) and
63 + not (deep is not True and depth > deep))
64 +
65 def _equiv_ebuild_visible(self, pkg, autounmask_level=None):
66 try:
67 pkg_eb = self._pkg(
68
69 diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py
70 index 48df869..0349853 100644
71 --- a/pym/portage/dep/dep_check.py
72 +++ b/pym/portage/dep/dep_check.py
73 @@ -317,6 +317,7 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
74 priority = trees[myroot].get("priority")
75 graph_db = trees[myroot].get("graph_db")
76 graph = trees[myroot].get("graph")
77 + want_update_pkg = trees[myroot].get("want_update_pkg")
78 vardb = None
79 if "vartree" in trees[myroot]:
80 vardb = trees[myroot]["vartree"].dbapi
81 @@ -325,6 +326,13 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
82 else:
83 mydbapi = trees[myroot]["porttree"].dbapi
84
85 + try:
86 + mydbapi_match_pkgs = mydbapi.match_pkgs
87 + except AttributeError:
88 + def mydbapi_match_pkgs(atom):
89 + return [mydbapi._pkg_str(cpv, atom.repo)
90 + for cpv in mydbapi.match(atom)]
91 +
92 # Sort the deps into installed, not installed but already
93 # in the graph and other, not installed and not in the graph
94 # and other, with values of [[required_atom], availablility]
95 @@ -348,10 +356,9 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
96 continue
97 # Ignore USE dependencies here since we don't want USE
98 # settings to adversely affect || preference evaluation.
99 - avail_pkg = mydbapi.match(atom.without_use)
100 + avail_pkg = mydbapi_match_pkgs(atom.without_use)
101 if avail_pkg:
102 avail_pkg = avail_pkg[-1] # highest (ascending order)
103 - avail_pkg = mydbapi._pkg_str(avail_pkg, atom.repo)
104 avail_slot = Atom("%s:%s" % (atom.cp, avail_pkg.slot))
105 if not avail_pkg:
106 all_available = False
107 @@ -359,7 +366,7 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
108 break
109
110 if atom.use:
111 - avail_pkg_use = mydbapi.match(atom)
112 + avail_pkg_use = mydbapi_match_pkgs(atom)
113 if not avail_pkg_use:
114 all_use_satisfied = False
115 else:
116 @@ -367,7 +374,6 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
117 avail_pkg_use = avail_pkg_use[-1]
118 if avail_pkg_use != avail_pkg:
119 avail_pkg = avail_pkg_use
120 - avail_pkg = mydbapi._pkg_str(avail_pkg, atom.repo)
121 avail_slot = Atom("%s:%s" % (atom.cp, avail_pkg.slot))
122
123 slot_map[avail_slot] = avail_pkg
124 @@ -458,8 +464,25 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None):
125 elif all_installed:
126 if all_installed_slots:
127 preferred_installed.append(this_choice)
128 - else:
129 + elif parent is None or want_update_pkg is None:
130 preferred_any_slot.append(this_choice)
131 + else:
132 + # When appropriate, prefer a slot that is not
133 + # installed yet for bug #478188.
134 + want_update = True
135 + for slot_atom, avail_pkg in slot_map.items():
136 + # New-style virtuals have zero cost to install.
137 + if slot_atom.startswith("virtual/") or \
138 + vardb.match(slot_atom):
139 + continue
140 + if not want_update_pkg(parent, avail_pkg):
141 + want_update = False
142 + break
143 +
144 + if want_update:
145 + preferred_installed.append(this_choice)
146 + else:
147 + preferred_any_slot.append(this_choice)
148 else:
149 preferred_non_installed.append(this_choice)
150 else:
151
152 diff --git a/pym/portage/tests/resolver/test_or_choices.py b/pym/portage/tests/resolver/test_or_choices.py
153 index 3bc67bc..ca02112 100644
154 --- a/pym/portage/tests/resolver/test_or_choices.py
155 +++ b/pym/portage/tests/resolver/test_or_choices.py
156 @@ -47,12 +47,26 @@ class OrChoicesTestCase(TestCase):
157 world = ["dev-libs/gobject-introspection", "sys-apps/systemd-ui"]
158
159 test_cases = (
160 - # Demonstrate that vala:0.20 update is not pulled in, as in bug #478188
161 + # Demonstrate that vala:0.20 update is pulled in, for bug #478188
162 ResolverPlaygroundTestCase(
163 ["@world"],
164 options = {"--update": True, "--deep": True},
165 success=True,
166 all_permutations = True,
167 + mergelist = ['dev-lang/vala-0.20.0']),
168 + # Verify that vala:0.20 is not pulled in without --deep
169 + ResolverPlaygroundTestCase(
170 + ["@world"],
171 + options = {"--update": True},
172 + success=True,
173 + all_permutations = True,
174 + mergelist = []),
175 + # Verify that vala:0.20 is not pulled in without --update
176 + ResolverPlaygroundTestCase(
177 + ["@world"],
178 + options = {"--selective": True, "--deep": True},
179 + success=True,
180 + all_permutations = True,
181 mergelist = []),
182 )