Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r10513 - main/trunk/pym/_emerge
Date: Sat, 31 May 2008 01:54:19
Message-Id: E1K2GIO-00074q-AO@stork.gentoo.org
1 Author: zmedico
2 Date: 2008-05-31 01:54:11 +0000 (Sat, 31 May 2008)
3 New Revision: 10513
4
5 Modified:
6 main/trunk/pym/_emerge/__init__.py
7 Log:
8 Optimize the new --skipfirst code so that in only has to build
9 a new depgraph one time when there are unsatisfied deps. This
10 works by recursively traversing the digraph to remove the parent
11 packages whose deps become unsatisfied when their dependencies are
12 pruned from the mergelist.
13
14
15 Modified: main/trunk/pym/_emerge/__init__.py
16 ===================================================================
17 --- main/trunk/pym/_emerge/__init__.py 2008-05-30 23:53:13 UTC (rev 10512)
18 +++ main/trunk/pym/_emerge/__init__.py 2008-05-31 01:54:11 UTC (rev 10513)
19 @@ -8369,18 +8369,47 @@
20 while True:
21 mydepgraph = depgraph(settings, trees,
22 myopts, myparams, spinner)
23 + graph = mydepgraph.digraph
24 try:
25 success = mydepgraph.loadResumeCommand(mtimedb["resume"])
26 except depgraph.UnsatisfiedResumeDep, e:
27 if "--skipfirst" not in myopts:
28 raise
29 - unsatisfied_parents = set(dep.parent for dep in e.value)
30 - pruned_mergelist = []
31 - for task in mergelist:
32 - if isinstance(task, list) and \
33 - tuple(task) in unsatisfied_parents:
34 +
35 + unsatisfied_parents = dict((dep.parent, dep.parent) \
36 + for dep in e.value)
37 + traversed_nodes = set()
38 + unsatisfied_stack = list(unsatisfied_parents)
39 + while unsatisfied_stack:
40 + pkg = unsatisfied_stack.pop()
41 + if pkg in traversed_nodes:
42 continue
43 - pruned_mergelist.append(task)
44 + traversed_nodes.add(pkg)
45 +
46 + # If this package was pulled in by a parent
47 + # package scheduled for merge, removing this
48 + # package may cause the the parent package's
49 + # dependency to become unsatisfied.
50 + for parent_node in graph.parent_nodes(pkg):
51 + if not isinstance(parent_node, Package) \
52 + or parent_node.operation != "merge":
53 + continue
54 + unsatisfied = \
55 + graph.child_nodes(parent_node,
56 + ignore_priority=DepPriority.SOFT)
57 + if pkg in unsatisfied:
58 + unsatisfied_parents[parent_node] = parent_node
59 + unsatisfied_stack.append(parent_node)
60 +
61 + pruned_mergelist = [x for x in mergelist \
62 + if isinstance(x, list) and \
63 + tuple(x) not in unsatisfied_parents]
64 +
65 + # It shouldn't happen, but if the size of mergelist
66 + # does not decrease for some reason then the loop
67 + # will be infinite. Therefore, if that case ever
68 + # occurs for some reason, raise the exception to
69 + # break out of the loop.
70 if not pruned_mergelist or \
71 len(pruned_mergelist) == len(mergelist):
72 raise
73
74 --
75 gentoo-commits@l.g.o mailing list