Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r9985 - main/branches/2.1.2/bin
Date: Sun, 27 Apr 2008 00:23:07
Message-Id: E1JpufY-000649-KY@stork.gentoo.org
1 Author: zmedico
2 Date: 2008-04-27 00:23:03 +0000 (Sun, 27 Apr 2008)
3 New Revision: 9985
4
5 Modified:
6 main/branches/2.1.2/bin/emerge
7 Log:
8 * Add a Blocker class to use instead of tuples.
9 * Fix the Task constructor to properly traverse __slots__ of all inherited
10 classes.
11 (trunk r9979)
12
13
14 Modified: main/branches/2.1.2/bin/emerge
15 ===================================================================
16 --- main/branches/2.1.2/bin/emerge 2008-04-27 00:21:24 UTC (rev 9984)
17 +++ main/branches/2.1.2/bin/emerge 2008-04-27 00:23:03 UTC (rev 9985)
18 @@ -1348,11 +1348,18 @@
19 __slots__ = ("__weakref__", "_hash_key",)
20
21 def __init__(self, **kwargs):
22 - for myattr in self.__slots__:
23 - if myattr == "__weakref__":
24 + classes = [self.__class__]
25 + while classes:
26 + c = classes.pop()
27 + if c is Task:
28 continue
29 - myvalue = kwargs.get(myattr, None)
30 - setattr(self, myattr, myvalue)
31 + classes.extend(c.__bases__)
32 + slots = getattr(c, "__slots__", None)
33 + if not slots:
34 + continue
35 + for myattr in slots:
36 + myvalue = kwargs.get(myattr, None)
37 + setattr(self, myattr, myvalue)
38
39 def _get_hash_key(self):
40 try:
41 @@ -1384,6 +1391,17 @@
42 def __str__(self):
43 return str(self._get_hash_key())
44
45 +class Blocker(Task):
46 + __slots__ = ("root", "atom")
47 +
48 + def _get_hash_key(self):
49 + try:
50 + return self._hash_key
51 + except AttributeError:
52 + self._hash_key = \
53 + ("blocks", self.root, self.atom)
54 + return self._hash_key
55 +
56 class Package(Task):
57 __slots__ = ("built", "cpv", "depth",
58 "installed", "metadata", "root", "onlydeps", "type_name",
59 @@ -1424,6 +1442,7 @@
60 return False
61
62 class Uninstall(Package):
63 + __slots__ = ()
64 def _get_hash_key(self):
65 try:
66 return self._hash_key
67 @@ -2010,7 +2029,7 @@
68 # The blocker applies to the root where
69 # the parent is or will be installed.
70 self.blocker_parents.setdefault(
71 - ("blocks", dep.parent.root, dep.atom), set()).add(
72 + Blocker(atom=dep.atom, root=dep.parent.root), set()).add(
73 dep.parent)
74 return 1
75 dep_pkg, existing_node = self._select_package(dep.root, dep.atom,
76
77 --
78 gentoo-commits@l.g.o mailing list