Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r10050 - main/trunk/pym/_emerge
Date: Thu, 01 May 2008 04:17:39
Message-Id: E1JrQEi-0007Y1-4e@stork.gentoo.org
1 Author: zmedico
2 Date: 2008-05-01 04:17:34 +0000 (Thu, 01 May 2008)
3 New Revision: 10050
4
5 Modified:
6 main/trunk/pym/_emerge/__init__.py
7 Log:
8 * Add a Package.operation attribute and use it to distinguish "uninstall"
9 operations.
10
11
12 Modified: main/trunk/pym/_emerge/__init__.py
13 ===================================================================
14 --- main/trunk/pym/_emerge/__init__.py 2008-04-30 19:45:54 UTC (rev 10049)
15 +++ main/trunk/pym/_emerge/__init__.py 2008-05-01 04:17:34 UTC (rev 10050)
16 @@ -1268,7 +1268,8 @@
17
18 class Package(Task):
19 __slots__ = ("built", "cpv", "depth",
20 - "installed", "metadata", "root", "onlydeps", "type_name",
21 + "installed", "metadata", "onlydeps", "operation",
22 + "root", "type_name",
23 "cp", "cpv_slot", "pv_split", "slot_atom")
24 def __init__(self, **kwargs):
25 Task.__init__(self, **kwargs)
26 @@ -1280,11 +1281,12 @@
27 def _get_hash_key(self):
28 hash_key = getattr(self, "_hash_key", None)
29 if hash_key is None:
30 - operation = "merge"
31 - if self.onlydeps or self.installed:
32 - operation = "nomerge"
33 + if self.operation is None:
34 + self.operation = "merge"
35 + if self.onlydeps or self.installed:
36 + self.operation = "nomerge"
37 self._hash_key = \
38 - (self.type_name, self.root, self.cpv, operation)
39 + (self.type_name, self.root, self.cpv, self.operation)
40 return self._hash_key
41
42 def __lt__(self, other):
43 @@ -1315,15 +1317,6 @@
44 return True
45 return False
46
47 -class Uninstall(Package):
48 - __slots__ = ()
49 - def _get_hash_key(self):
50 - hash_key = getattr(self, "_hash_key", None)
51 - if hash_key is None:
52 - self._hash_key = \
53 - (self.type_name, self.root, self.cpv, "uninstall")
54 - return self._hash_key
55 -
56 class DependencyArg(object):
57 def __init__(self, arg=None, root_config=None):
58 self.arg = arg
59 @@ -3370,9 +3363,10 @@
60
61 if not unresolved_blocks and depends_on_order:
62 for inst_pkg, inst_task in depends_on_order:
63 - uninst_task = Uninstall(built=inst_pkg.built,
64 + uninst_task = Package(built=inst_pkg.built,
65 cpv=inst_pkg.cpv, installed=inst_pkg.installed,
66 - metadata=inst_pkg.metadata, root=inst_pkg.root,
67 + metadata=inst_pkg.metadata,
68 + operation="uninstall", root=inst_pkg.root,
69 type_name=inst_pkg.type_name)
70 self._pkg_cache[uninst_task] = uninst_task
71 # Enforce correct merge order with a hard dep.
72 @@ -3485,7 +3479,8 @@
73 since those should be executed as late as possible.
74 """
75 return [node for node in mygraph.leaf_nodes(**kwargs) \
76 - if not isinstance(node, Uninstall)]
77 + if isinstance(node, Package) and \
78 + node.operation != "uninstall"]
79 if True:
80 for node in mygraph.order:
81 if node.root == "/" and \
82 @@ -3812,7 +3807,8 @@
83 # and uninstallation tasks.
84 solved_blockers = set()
85 uninst_task = None
86 - if isinstance(node, Uninstall):
87 + if isinstance(node, Package) and \
88 + "uninstall" == node.operation:
89 have_uninstall_task = True
90 uninst_task = node
91 else:
92 @@ -3842,7 +3838,8 @@
93 if node[-1] != "nomerge":
94 retlist.append(node)
95
96 - if isinstance(node, Uninstall):
97 + if isinstance(node, Package) and \
98 + "uninstall" == node.operation:
99 # Include satisfied blockers in the merge list so
100 # that the user can see why the package had to be
101 # uninstalled in advance rather than through
102 @@ -4796,13 +4793,10 @@
103 metadata["USE"] = pkgsettings["PORTAGE_USE"]
104 installed = action == "uninstall"
105 built = pkg_type != "ebuild"
106 - if installed:
107 - pkg_constructor = Uninstall
108 - else:
109 - pkg_constructor = Package
110 - pkg = pkg_constructor(built=built, cpv=pkg_key,
111 + pkg = Package(built=built, cpv=pkg_key,
112 installed=installed, metadata=metadata,
113 - root=myroot, type_name=pkg_type)
114 + operation=action, root=myroot,
115 + type_name=pkg_type)
116 self._pkg_cache[pkg] = pkg
117 fakedb[myroot].cpv_inject(pkg)
118 self.spinner.update()
119 @@ -5199,7 +5193,7 @@
120 if "--resume" not in self.myopts:
121 mymergelist = mylist
122 mtimedb["resume"]["mergelist"] = [list(x) for x in mymergelist \
123 - if isinstance(x, (Package, Uninstall))]
124 + if isinstance(x, Package)]
125 mtimedb.commit()
126
127 myfeat = self.settings.features[:]
128 @@ -5256,11 +5250,9 @@
129 mymergelist = [x for x in mymergelist if x[-1] == "merge"]
130 mergecount=0
131 for x in task_list:
132 - pkg_type = x[0]
133 - if pkg_type == "blocks":
134 + if x[0] == "blocks":
135 continue
136 - myroot=x[1]
137 - pkg_key = x[2]
138 + pkg_type, myroot, pkg_key, operation = x
139 pkgindex=2
140 built = pkg_type != "ebuild"
141 installed = pkg_type == "installed"
142 @@ -5296,14 +5288,12 @@
143 # isn't installed anymore. Since it's already
144 # been uninstalled, move on to the next task.
145 continue
146 - if installed:
147 - pkg_constructor = Uninstall
148 - else:
149 - pkg_constructor = Package
150 + if not installed:
151 mergecount += 1
152 - pkg = pkg_constructor(type_name=pkg_type, root=myroot,
153 - cpv=pkg_key, built=built, installed=installed,
154 - metadata=metadata)
155 + pkg = Package(cpv=pkg_key, built=built,
156 + installed=installed, metadata=metadata,
157 + operation=operation, root=myroot,
158 + type_name=pkg_type)
159 if pkg.installed:
160 if not (buildpkgonly or fetchonly or pretend):
161 self._uninstall_queue.append(pkg)
162
163 --
164 gentoo-commits@l.g.o mailing list