1 |
Author: zmedico |
2 |
Date: 2008-05-03 08:21:02 +0000 (Sat, 03 May 2008) |
3 |
New Revision: 10132 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/_emerge/__init__.py |
7 |
Log: |
8 |
* Move circular deps and blocker displays to depgraph.display_problems(). |
9 |
* Always call display_problems() since calling it from inside display() |
10 |
can lead to unwanted recursion. |
11 |
|
12 |
|
13 |
Modified: main/trunk/pym/_emerge/__init__.py |
14 |
=================================================================== |
15 |
--- main/trunk/pym/_emerge/__init__.py 2008-05-03 06:00:02 UTC (rev 10131) |
16 |
+++ main/trunk/pym/_emerge/__init__.py 2008-05-03 08:21:02 UTC (rev 10132) |
17 |
@@ -1759,6 +1759,8 @@ |
18 |
self._missing_args = [] |
19 |
self._masked_installed = [] |
20 |
self._unsatisfied_deps_for_display = [] |
21 |
+ self._unsatisfied_blockers_for_display = None |
22 |
+ self._circular_deps_for_display = None |
23 |
self._dep_stack = [] |
24 |
self._unsatisfied_deps = [] |
25 |
self._ignored_deps = [] |
26 |
@@ -1777,6 +1779,8 @@ |
27 |
if not self._slot_collision_info: |
28 |
return |
29 |
|
30 |
+ self._show_merge_list() |
31 |
+ |
32 |
msg = [] |
33 |
msg.append("\n!!! Multiple versions within a single " + \ |
34 |
"package slot have been pulled\n") |
35 |
@@ -3721,43 +3725,7 @@ |
36 |
continue |
37 |
|
38 |
if not selected_nodes: |
39 |
- # No leaf nodes are available, so we have a circular |
40 |
- # dependency panic situation. Reduce the noise level to a |
41 |
- # minimum via repeated elimination of root nodes since they |
42 |
- # have no parents and thus can not be part of a cycle. |
43 |
- while True: |
44 |
- root_nodes = mygraph.root_nodes( |
45 |
- ignore_priority=DepPriority.MEDIUM_SOFT) |
46 |
- if not root_nodes: |
47 |
- break |
48 |
- for node in root_nodes: |
49 |
- mygraph.remove(node) |
50 |
- # Display the USE flags that are enabled on nodes that are part |
51 |
- # of dependency cycles in case that helps the user decide to |
52 |
- # disable some of them. |
53 |
- display_order = [] |
54 |
- tempgraph = mygraph.copy() |
55 |
- while not tempgraph.empty(): |
56 |
- nodes = tempgraph.leaf_nodes() |
57 |
- if not nodes: |
58 |
- node = tempgraph.order[0] |
59 |
- else: |
60 |
- node = nodes[0] |
61 |
- display_order.append(node) |
62 |
- tempgraph.remove(node) |
63 |
- display_order.reverse() |
64 |
- self.myopts.pop("--quiet", None) |
65 |
- self.myopts.pop("--verbose", None) |
66 |
- self.myopts["--tree"] = True |
67 |
- print |
68 |
- print |
69 |
- self.display(display_order) |
70 |
- print "!!! Error: circular dependencies:" |
71 |
- print |
72 |
- mygraph.debug_print() |
73 |
- print |
74 |
- print "!!! Note that circular dependencies can often be avoided by temporarily" |
75 |
- print "!!! disabling USE flags that trigger optional dependencies." |
76 |
+ self._circular_deps_for_display = mygraph |
77 |
raise self._unknown_internal_error() |
78 |
|
79 |
# At this point, we've succeeded in selecting one or more nodes, so |
80 |
@@ -3837,26 +3805,79 @@ |
81 |
|
82 |
if unsolvable_blockers and \ |
83 |
not self._accept_blocker_conflicts(): |
84 |
- quiet = "--quiet" in self.myopts |
85 |
- display_list = retlist[:] |
86 |
- if tree_mode: |
87 |
- display_list.reverse() |
88 |
- portage.writemsg("\n", noiselevel=-1) |
89 |
- self.display(display_list) |
90 |
- msg = "Error: The above package list contains " + \ |
91 |
- "packages which cannot be installed " + \ |
92 |
- "at the same time on the same system." |
93 |
- prefix = bad(" * ") |
94 |
- from textwrap import wrap |
95 |
- portage.writemsg("\n", noiselevel=-1) |
96 |
- for line in wrap(msg, 70): |
97 |
- portage.writemsg(prefix + line + "\n", noiselevel=-1) |
98 |
- if not quiet: |
99 |
- show_blocker_docs_link() |
100 |
+ self._unsatisfied_blockers_for_display = unsolvable_blockers |
101 |
+ self._serialized_tasks_cache = retlist[:] |
102 |
raise self._unknown_internal_error() |
103 |
|
104 |
+ if self._slot_collision_info and \ |
105 |
+ not self._accept_blocker_conflicts(): |
106 |
+ self._serialized_tasks_cache = retlist[:] |
107 |
+ raise self._unknown_internal_error() |
108 |
+ |
109 |
return retlist |
110 |
|
111 |
+ def _show_circular_deps(self, mygraph): |
112 |
+ # No leaf nodes are available, so we have a circular |
113 |
+ # dependency panic situation. Reduce the noise level to a |
114 |
+ # minimum via repeated elimination of root nodes since they |
115 |
+ # have no parents and thus can not be part of a cycle. |
116 |
+ while True: |
117 |
+ root_nodes = mygraph.root_nodes( |
118 |
+ ignore_priority=DepPriority.MEDIUM_SOFT) |
119 |
+ if not root_nodes: |
120 |
+ break |
121 |
+ mygraph.difference_update(root_nodes) |
122 |
+ # Display the USE flags that are enabled on nodes that are part |
123 |
+ # of dependency cycles in case that helps the user decide to |
124 |
+ # disable some of them. |
125 |
+ display_order = [] |
126 |
+ tempgraph = mygraph.copy() |
127 |
+ while not tempgraph.empty(): |
128 |
+ nodes = tempgraph.leaf_nodes() |
129 |
+ if not nodes: |
130 |
+ node = tempgraph.order[0] |
131 |
+ else: |
132 |
+ node = nodes[0] |
133 |
+ display_order.append(node) |
134 |
+ tempgraph.remove(node) |
135 |
+ display_order.reverse() |
136 |
+ self.myopts.pop("--quiet", None) |
137 |
+ self.myopts.pop("--verbose", None) |
138 |
+ self.myopts["--tree"] = True |
139 |
+ portage.writemsg("\n\n", noiselevel=-1) |
140 |
+ self.display(display_order) |
141 |
+ prefix = colorize("BAD", " * ") |
142 |
+ portage.writemsg("\n", noiselevel=-1) |
143 |
+ portage.writemsg(prefix + "Error: circular dependencies:\n", |
144 |
+ noiselevel=-1) |
145 |
+ portage.writemsg("\n", noiselevel=-1) |
146 |
+ mygraph.debug_print() |
147 |
+ portage.writemsg("\n", noiselevel=-1) |
148 |
+ portage.writemsg(prefix + "Note that circular dependencies " + \ |
149 |
+ "can often be avoided by temporarily\n", noiselevel=-1) |
150 |
+ portage.writemsg(prefix + "disabling USE flags that trigger " + \ |
151 |
+ "optional dependencies.\n", noiselevel=-1) |
152 |
+ |
153 |
+ def _show_merge_list(self): |
154 |
+ if self._serialized_tasks_cache is not None: |
155 |
+ display_list = self._serialized_tasks_cache[:] |
156 |
+ if "--tree" in self.myopts: |
157 |
+ display_list.reverse() |
158 |
+ self.display(display_list) |
159 |
+ |
160 |
+ def _show_unsatisied_blockers(self, blockers): |
161 |
+ self._show_merge_list() |
162 |
+ msg = "Error: The above package list contains " + \ |
163 |
+ "packages which cannot be installed " + \ |
164 |
+ "at the same time on the same system." |
165 |
+ prefix = colorize("BAD", " * ") |
166 |
+ from textwrap import wrap |
167 |
+ portage.writemsg("\n", noiselevel=-1) |
168 |
+ for line in wrap(msg, 70): |
169 |
+ portage.writemsg(prefix + line + "\n", noiselevel=-1) |
170 |
+ if "--quiet" not in self.myopts: |
171 |
+ show_blocker_docs_link() |
172 |
+ |
173 |
def display(self, mylist, favorites=[], verbosity=None): |
174 |
if verbosity is None: |
175 |
verbosity = ("--quiet" in self.myopts and 1 or \ |
176 |
@@ -4529,7 +4550,6 @@ |
177 |
sys.stdout.write(text) |
178 |
|
179 |
sys.stdout.flush() |
180 |
- self.display_problems() |
181 |
return os.EX_OK |
182 |
|
183 |
def display_problems(self): |
184 |
@@ -4541,17 +4561,16 @@ |
185 |
to ensure that the user is notified of problems with the graph. |
186 |
""" |
187 |
|
188 |
- task_list = self._serialized_tasks_cache |
189 |
+ if self._circular_deps_for_display is not None: |
190 |
+ self._show_circular_deps( |
191 |
+ self._circular_deps_for_display) |
192 |
|
193 |
- # Any blockers must be appended to the tail of the list, |
194 |
- # so we only need to check the last item. |
195 |
- have_blocker_conflict = bool(task_list and \ |
196 |
- (isinstance(task_list[-1], Blocker) and \ |
197 |
- not task_list[-1].satisfied)) |
198 |
- |
199 |
# The user is only notified of a slot conflict if |
200 |
# there are no unresolvable blocker conflicts. |
201 |
- if not have_blocker_conflict: |
202 |
+ if self._unsatisfied_blockers_for_display is not None: |
203 |
+ self._show_unsatisied_blockers( |
204 |
+ self._unsatisfied_blockers_for_display) |
205 |
+ else: |
206 |
self._show_slot_collision_notice() |
207 |
|
208 |
# TODO: Add generic support for "set problem" handlers so that |
209 |
@@ -7735,11 +7754,11 @@ |
210 |
except portage.exception.PackageNotFound, e: |
211 |
portage.writemsg("\n!!! %s\n" % str(e), noiselevel=-1) |
212 |
return 1 |
213 |
+ if show_spinner: |
214 |
+ print "\b\b... done!" |
215 |
if not retval: |
216 |
mydepgraph.display_problems() |
217 |
return 1 |
218 |
- if "--quiet" not in myopts and "--nodeps" not in myopts: |
219 |
- print "\b\b... done!" |
220 |
display = pretend or \ |
221 |
((ask or tree or verbose) and not (quiet and not ask)) |
222 |
if not display: |
223 |
@@ -7758,6 +7777,7 @@ |
224 |
retval = mydepgraph.display( |
225 |
mydepgraph.altlist(reversed=tree), |
226 |
favorites=favorites) |
227 |
+ mydepgraph.display_problems() |
228 |
if retval != os.EX_OK: |
229 |
return retval |
230 |
prompt="Would you like to resume merging these packages?" |
231 |
@@ -7765,6 +7785,7 @@ |
232 |
retval = mydepgraph.display( |
233 |
mydepgraph.altlist(reversed=("--tree" in myopts)), |
234 |
favorites=favorites) |
235 |
+ mydepgraph.display_problems() |
236 |
if retval != os.EX_OK: |
237 |
return retval |
238 |
mergecount=0 |
239 |
@@ -7808,12 +7829,14 @@ |
240 |
retval = mydepgraph.display( |
241 |
mydepgraph.altlist(reversed=tree), |
242 |
favorites=favorites) |
243 |
+ mydepgraph.display_problems() |
244 |
if retval != os.EX_OK: |
245 |
return retval |
246 |
else: |
247 |
retval = mydepgraph.display( |
248 |
mydepgraph.altlist(reversed=("--tree" in myopts)), |
249 |
favorites=favorites) |
250 |
+ mydepgraph.display_problems() |
251 |
if retval != os.EX_OK: |
252 |
return retval |
253 |
if "--buildpkgonly" in myopts: |
254 |
|
255 |
-- |
256 |
gentoo-commits@l.g.o mailing list |