Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r10515 - main/branches/2.1.2/bin
Date: Sat, 31 May 2008 02:08:33
Message-Id: E1K2GWA-0003qA-EQ@stork.gentoo.org
1 Author: zmedico
2 Date: 2008-05-31 02:08:25 +0000 (Sat, 31 May 2008)
3 New Revision: 10515
4
5 Modified:
6 main/branches/2.1.2/bin/emerge
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. (trunk r10512:10514)
13
14
15 Modified: main/branches/2.1.2/bin/emerge
16 ===================================================================
17 --- main/branches/2.1.2/bin/emerge 2008-05-31 02:06:01 UTC (rev 10514)
18 +++ main/branches/2.1.2/bin/emerge 2008-05-31 02:08:25 UTC (rev 10515)
19 @@ -8314,19 +8314,49 @@
20 except depgraph.UnsatisfiedResumeDep, e:
21 if "--skipfirst" not in myopts:
22 raise
23 - unsatisfied_parents = set(dep.parent for dep in e.value)
24 - pruned_mergelist = []
25 - for task in mergelist:
26 - if isinstance(task, list) and \
27 - tuple(task) in unsatisfied_parents:
28 +
29 + graph = mydepgraph.digraph
30 + unsatisfied_parents = dict((dep.parent, dep.parent) \
31 + for dep in e.value)
32 + traversed_nodes = set()
33 + unsatisfied_stack = list(unsatisfied_parents)
34 + while unsatisfied_stack:
35 + pkg = unsatisfied_stack.pop()
36 + if pkg in traversed_nodes:
37 continue
38 - pruned_mergelist.append(task)
39 + traversed_nodes.add(pkg)
40 +
41 + # If this package was pulled in by a parent
42 + # package scheduled for merge, removing this
43 + # package may cause the the parent package's
44 + # dependency to become unsatisfied.
45 + for parent_node in graph.parent_nodes(pkg):
46 + if not isinstance(parent_node, Package) \
47 + or parent_node.operation != "merge":
48 + continue
49 + unsatisfied = \
50 + graph.child_nodes(parent_node,
51 + ignore_priority=DepPriority.SOFT)
52 + if pkg in unsatisfied:
53 + unsatisfied_parents[parent_node] = parent_node
54 + unsatisfied_stack.append(parent_node)
55 +
56 + pruned_mergelist = [x for x in mergelist \
57 + if isinstance(x, list) and \
58 + tuple(x) not in unsatisfied_parents]
59 +
60 + # It shouldn't happen, but if the size of mergelist
61 + # does not decrease for some reason then the loop
62 + # will be infinite. Therefore, if that case ever
63 + # occurs for some reason, raise the exception to
64 + # break out of the loop.
65 if not pruned_mergelist or \
66 len(pruned_mergelist) == len(mergelist):
67 raise
68 mergelist[:] = pruned_mergelist
69 dropped_tasks.update(unsatisfied_parents)
70 - del e, unsatisfied_parents
71 + del e, graph, traversed_nodes, \
72 + unsatisfied_parents, unsatisfied_stack
73 continue
74 else:
75 break
76
77 --
78 gentoo-commits@l.g.o mailing list