Gentoo Archives: gentoo-commits

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