Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r13657 - main/trunk/pym/_emerge
Date: Sat, 20 Jun 2009 19:16:54
Message-Id: E1MI63Y-0005hU-8P@stork.gentoo.org
1 Author: zmedico
2 Date: 2009-06-20 19:16:51 +0000 (Sat, 20 Jun 2009)
3 New Revision: 13657
4
5 Modified:
6 main/trunk/pym/_emerge/__init__.py
7 Log:
8 Factor duplicate code out of depgraph._add_pkg and _pop_disjunction.
9
10
11 Modified: main/trunk/pym/_emerge/__init__.py
12 ===================================================================
13 --- main/trunk/pym/_emerge/__init__.py 2009-06-20 18:53:01 UTC (rev 13656)
14 +++ main/trunk/pym/_emerge/__init__.py 2009-06-20 19:16:51 UTC (rev 13657)
15 @@ -5394,41 +5394,11 @@
16
17 dep_string = portage.dep.paren_enclose(dep_string)
18
19 - vardb = self.roots[dep_root].trees["vartree"].dbapi
20 - try:
21 - selected_atoms = self._select_atoms(dep_root,
22 - dep_string, myuse=myuse, parent=pkg, strict=strict,
23 - priority=dep_priority)
24 - except portage.exception.InvalidDependString, e:
25 - show_invalid_depstring_notice(jbigkey, dep_string, str(e))
26 + if not self._add_pkg_dep_string(
27 + pkg, dep_root, dep_priority, dep_string,
28 + allow_unsatisfied):
29 return 0
30 - if debug:
31 - print "Candidates:", selected_atoms
32
33 - for atom in selected_atoms:
34 - try:
35 -
36 - atom = portage.dep.Atom(atom)
37 -
38 - mypriority = dep_priority.copy()
39 - if not atom.blocker and vardb.match(atom):
40 - mypriority.satisfied = True
41 -
42 - if not self._add_dep(Dependency(atom=atom,
43 - blocker=atom.blocker, depth=depth, parent=pkg,
44 - priority=mypriority, root=dep_root),
45 - allow_unsatisfied=allow_unsatisfied):
46 - return 0
47 -
48 - except portage.exception.InvalidAtom, e:
49 - show_invalid_depstring_notice(
50 - pkg, dep_string, str(e))
51 - del e
52 - if not pkg.installed:
53 - return 0
54 -
55 - if debug:
56 - print "Exiting...", jbigkey
57 except portage.exception.AmbiguousPackageName, e:
58 pkgs = e.args[0]
59 portage.writemsg("\n\n!!! An atom in the dependencies " + \
60 @@ -5452,56 +5422,11 @@
61 portage.dep._dep_check_strict = True
62 return 1
63
64 - def _queue_disjunctive_deps(self, pkg, dep_root, dep_priority, dep_struct):
65 - """
66 - Queue disjunctive (virtual and ||) deps in self._dep_disjunctive_stack.
67 - Yields non-disjunctive deps. Raises InvalidDependString when
68 - necessary.
69 - """
70 - i = 0
71 - while i < len(dep_struct):
72 - x = dep_struct[i]
73 - if isinstance(x, list):
74 - for y in self._queue_disjunctive_deps(
75 - pkg, dep_root, dep_priority, x):
76 - yield y
77 - elif x == "||":
78 - self._queue_disjunction(pkg, dep_root, dep_priority,
79 - [ x, dep_struct[ i + 1 ] ] )
80 - i += 1
81 - else:
82 - try:
83 - x = portage.dep.Atom(x)
84 - except portage.exception.InvalidAtom:
85 - if not pkg.installed:
86 - raise portage.exception.InvalidDependString(
87 - "invalid atom: '%s'" % x)
88 - else:
89 - # Note: Eventually this will check for PROPERTIES=virtual
90 - # or whatever other metadata gets implemented for this
91 - # purpose.
92 - if x.cp.startswith('virtual/'):
93 - self._queue_disjunction( pkg, dep_root,
94 - dep_priority, [ str(x) ] )
95 - else:
96 - yield str(x)
97 - i += 1
98 -
99 - def _queue_disjunction(self, pkg, dep_root, dep_priority, dep_struct):
100 - self._dep_disjunctive_stack.append(
101 - (pkg, dep_root, dep_priority, dep_struct))
102 -
103 - def _pop_disjunction(self, allow_unsatisfied):
104 - """
105 - Pop one disjunctive dep from self._dep_disjunctive_stack, and use it to
106 - populate self._dep_stack.
107 - """
108 - pkg, dep_root, dep_priority, dep_struct = \
109 - self._dep_disjunctive_stack.pop()
110 + def _add_pkg_dep_string(self, pkg, dep_root, dep_priority, dep_string,
111 + allow_unsatisfied):
112 depth = pkg.depth + 1
113 debug = "--debug" in self.myopts
114 strict = pkg.type_name != "installed"
115 - dep_string = portage.dep.paren_enclose(dep_struct)
116
117 if debug:
118 print
119 @@ -5552,6 +5477,58 @@
120
121 return 1
122
123 + def _queue_disjunctive_deps(self, pkg, dep_root, dep_priority, dep_struct):
124 + """
125 + Queue disjunctive (virtual and ||) deps in self._dep_disjunctive_stack.
126 + Yields non-disjunctive deps. Raises InvalidDependString when
127 + necessary.
128 + """
129 + i = 0
130 + while i < len(dep_struct):
131 + x = dep_struct[i]
132 + if isinstance(x, list):
133 + for y in self._queue_disjunctive_deps(
134 + pkg, dep_root, dep_priority, x):
135 + yield y
136 + elif x == "||":
137 + self._queue_disjunction(pkg, dep_root, dep_priority,
138 + [ x, dep_struct[ i + 1 ] ] )
139 + i += 1
140 + else:
141 + try:
142 + x = portage.dep.Atom(x)
143 + except portage.exception.InvalidAtom:
144 + if not pkg.installed:
145 + raise portage.exception.InvalidDependString(
146 + "invalid atom: '%s'" % x)
147 + else:
148 + # Note: Eventually this will check for PROPERTIES=virtual
149 + # or whatever other metadata gets implemented for this
150 + # purpose.
151 + if x.cp.startswith('virtual/'):
152 + self._queue_disjunction( pkg, dep_root,
153 + dep_priority, [ str(x) ] )
154 + else:
155 + yield str(x)
156 + i += 1
157 +
158 + def _queue_disjunction(self, pkg, dep_root, dep_priority, dep_struct):
159 + self._dep_disjunctive_stack.append(
160 + (pkg, dep_root, dep_priority, dep_struct))
161 +
162 + def _pop_disjunction(self, allow_unsatisfied):
163 + """
164 + Pop one disjunctive dep from self._dep_disjunctive_stack, and use it to
165 + populate self._dep_stack.
166 + """
167 + pkg, dep_root, dep_priority, dep_struct = \
168 + self._dep_disjunctive_stack.pop()
169 + dep_string = portage.dep.paren_enclose(dep_struct)
170 + if not self._add_pkg_dep_string(
171 + pkg, dep_root, dep_priority, dep_string, allow_unsatisfied):
172 + return 0
173 + return 1
174 +
175 def _priority(self, **kwargs):
176 if "remove" in self.myparams:
177 priority_constructor = UnmergeDepPriority