1 |
Author: zmedico |
2 |
Date: 2008-04-30 08:50:44 +0000 (Wed, 30 Apr 2008) |
3 |
New Revision: 10044 |
4 |
|
5 |
Modified: |
6 |
main/branches/2.1.2/bin/emerge |
7 |
main/branches/2.1.2/pym/portage.py |
8 |
Log: |
9 |
* Fix dep_check() so that it doesn't expand virtual blockers since the |
10 |
un-expanded virtual atom is more useful for maintaining a cache of |
11 |
blocker atoms. |
12 |
|
13 |
* Expand virtual blockers in depgraph.validate_blockers(), since it's |
14 |
not done by dep_check() anymore. |
15 |
|
16 |
* If blocker data from the graph is available, use it to validate the |
17 |
blocker cache and update the cache if it seems invalid. |
18 |
|
19 |
* Make BlockerCache._load() more tolerant to installs/uninstalls so |
20 |
so that cache isn't rebuilt so often. |
21 |
(trunk r10040:10043) |
22 |
|
23 |
|
24 |
Modified: main/branches/2.1.2/bin/emerge |
25 |
=================================================================== |
26 |
--- main/branches/2.1.2/bin/emerge 2008-04-30 08:46:34 UTC (rev 10043) |
27 |
+++ main/branches/2.1.2/bin/emerge 2008-04-30 08:50:44 UTC (rev 10044) |
28 |
@@ -1392,8 +1392,12 @@ |
29 |
return str(self._get_hash_key()) |
30 |
|
31 |
class Blocker(Task): |
32 |
- __slots__ = ("root", "atom", "satisfied") |
33 |
+ __slots__ = ("root", "atom", "cp", "satisfied") |
34 |
|
35 |
+ def __init__(self, **kwargs): |
36 |
+ Task.__init__(self, **kwargs) |
37 |
+ self.cp = portage.dep_getkey(self.atom) |
38 |
+ |
39 |
def _get_hash_key(self): |
40 |
hash_key = getattr(self, "_hash_key", None) |
41 |
if hash_key is None: |
42 |
@@ -1533,14 +1537,22 @@ |
43 |
cache_valid = self._cache_data and \ |
44 |
isinstance(self._cache_data, dict) and \ |
45 |
self._cache_data.get("version") == self._cache_version and \ |
46 |
- self._cache_data.get("virtuals") == self._virtuals and \ |
47 |
- set(self._cache_data.get("blockers", [])) == self._installed_pkgs |
48 |
+ isinstance(self._cache_data.get("blockers"), dict) |
49 |
if cache_valid: |
50 |
- for pkg in self._installed_pkgs: |
51 |
- if long(self._vardb.aux_get(pkg, ["COUNTER"])[0]) != \ |
52 |
- self[pkg].counter: |
53 |
- cache_valid = False |
54 |
- break |
55 |
+ invalid_cache = set() |
56 |
+ for cpv, value \ |
57 |
+ in self._cache_data["blockers"].iteritems(): |
58 |
+ if not (isinstance(value, tuple) and len(value) == 2): |
59 |
+ invalid_cache.add(cpv) |
60 |
+ continue |
61 |
+ counter, atoms = value |
62 |
+ if counter != long(self._vardb.aux_get(cpv, ["COUNTER"])[0]): |
63 |
+ invalid_cache.add(cpv) |
64 |
+ continue |
65 |
+ for cpv in invalid_cache: |
66 |
+ del self._cache_data["blockers"][cpv] |
67 |
+ if not self._cache_data["blockers"]: |
68 |
+ cache_valid = False |
69 |
if not cache_valid: |
70 |
self._cache_data = {"version":self._cache_version} |
71 |
self._cache_data["blockers"] = {} |
72 |
@@ -3293,12 +3305,42 @@ |
73 |
node = Package(cpv=pkg, built=True, |
74 |
installed=True, metadata=metadata, |
75 |
type_name="installed", root=myroot) |
76 |
+ |
77 |
+ |
78 |
+ blockers = None |
79 |
if self.digraph.contains(node): |
80 |
- continue |
81 |
+ try: |
82 |
+ blockers = self._blocker_parents.child_nodes(node) |
83 |
+ except KeyError: |
84 |
+ blockers = [] |
85 |
+ if blockers is not None: |
86 |
+ blockers = set("!" + blocker.atom \ |
87 |
+ for blocker in blockers) |
88 |
+ |
89 |
# If this node has any blockers, create a "nomerge" |
90 |
# node for it so that they can be enforced. |
91 |
self.spinner.update() |
92 |
blocker_data = blocker_cache.get(pkg) |
93 |
+ |
94 |
+ # If blocker data from the graph is available, use |
95 |
+ # it to validate the cache and update the cache if |
96 |
+ # it seems invalid. |
97 |
+ if blocker_data is not None and \ |
98 |
+ blockers is not None: |
99 |
+ if not blockers.symmetric_difference( |
100 |
+ blocker_data.atoms): |
101 |
+ continue |
102 |
+ blocker_data = None |
103 |
+ |
104 |
+ if blocker_data is None and \ |
105 |
+ blockers is not None: |
106 |
+ # Re-use the blockers from the graph. |
107 |
+ blocker_atoms = sorted(blockers) |
108 |
+ counter = long(node.metadata["COUNTER"]) |
109 |
+ blocker_data = \ |
110 |
+ blocker_cache.BlockerData(counter, blocker_atoms) |
111 |
+ blocker_cache[pkg] = blocker_data |
112 |
+ |
113 |
if blocker_data: |
114 |
blocker_atoms = blocker_data.atoms |
115 |
else: |
116 |
@@ -3352,11 +3394,35 @@ |
117 |
|
118 |
for blocker in self._blocker_parents.leaf_nodes(): |
119 |
self.spinner.update() |
120 |
+ root_config = self.roots[blocker.root] |
121 |
+ virtuals = root_config.settings.getvirtuals() |
122 |
mytype, myroot, mydep = blocker |
123 |
initial_db = self.trees[myroot]["vartree"].dbapi |
124 |
final_db = self.mydbapi[myroot] |
125 |
- blocked_initial = initial_db.match(mydep) |
126 |
- blocked_final = final_db.match(mydep) |
127 |
+ |
128 |
+ provider_virtual = False |
129 |
+ if blocker.cp in virtuals and \ |
130 |
+ not self._have_new_virt(blocker.root, blocker.cp): |
131 |
+ provider_virtual = True |
132 |
+ |
133 |
+ if provider_virtual: |
134 |
+ atoms = [] |
135 |
+ for provider_entry in virtuals[blocker.cp]: |
136 |
+ provider_cp = \ |
137 |
+ portage.dep_getkey(provider_entry) |
138 |
+ atoms.append(blocker.atom.replace( |
139 |
+ blocker.cp, provider_cp)) |
140 |
+ else: |
141 |
+ atoms = [blocker.atom] |
142 |
+ |
143 |
+ blocked_initial = [] |
144 |
+ for atom in atoms: |
145 |
+ blocked_initial.extend(initial_db.match(atom)) |
146 |
+ |
147 |
+ blocked_final = [] |
148 |
+ for atom in atoms: |
149 |
+ blocked_final.extend(final_db.match(atom)) |
150 |
+ |
151 |
if not blocked_initial and not blocked_final: |
152 |
parent_pkgs = self._blocker_parents.parent_nodes(blocker) |
153 |
self._blocker_parents.remove(blocker) |
154 |
|
155 |
Modified: main/branches/2.1.2/pym/portage.py |
156 |
=================================================================== |
157 |
--- main/branches/2.1.2/pym/portage.py 2008-04-30 08:46:34 UTC (rev 10043) |
158 |
+++ main/branches/2.1.2/pym/portage.py 2008-04-30 08:50:44 UTC (rev 10044) |
159 |
@@ -5368,6 +5368,12 @@ |
160 |
continue |
161 |
mychoices = myvirtuals.get(mykey, []) |
162 |
isblocker = x.startswith("!") |
163 |
+ if isblocker: |
164 |
+ # Virtual blockers are no longer expanded here since |
165 |
+ # the un-expanded virtual atom is more useful for |
166 |
+ # maintaining a cache of blocker atoms. |
167 |
+ newsplit.append(x) |
168 |
+ continue |
169 |
match_atom = x |
170 |
if isblocker: |
171 |
match_atom = x[1:] |
172 |
|
173 |
-- |
174 |
gentoo-commits@l.g.o mailing list |