1 |
commit: 3791c8aa4cb242aa2b507b6bac368925aad067b1 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Feb 4 21:07:52 2011 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Feb 4 21:07:52 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=3791c8aa |
7 |
|
8 |
REQUIRED_USE: fix parens display and test more |
9 |
|
10 |
--- |
11 |
pym/portage/dep/__init__.py | 44 +++++++++++++++++------- |
12 |
pym/portage/tests/dep/testCheckRequiredUse.py | 5 +++ |
13 |
2 files changed, 36 insertions(+), 13 deletions(-) |
14 |
|
15 |
diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py |
16 |
index 62e96d2..b27d589 100644 |
17 |
--- a/pym/portage/dep/__init__.py |
18 |
+++ b/pym/portage/dep/__init__.py |
19 |
@@ -1,5 +1,5 @@ |
20 |
# deps.py -- Portage dependency resolution functions |
21 |
-# Copyright 2003-2010 Gentoo Foundation |
22 |
+# Copyright 2003-2011 Gentoo Foundation |
23 |
# Distributed under the terms of the GNU General Public License v2 |
24 |
|
25 |
__all__ = [ |
26 |
@@ -2206,7 +2206,10 @@ def check_required_use(required_use, use, iuse_match): |
27 |
else: |
28 |
stack[level].pop() |
29 |
node._satisfied = True |
30 |
- node._parent._children.remove(node) |
31 |
+ last_node = node._parent._children.pop() |
32 |
+ if last_node is not node: |
33 |
+ raise AssertionError( |
34 |
+ "node is not last child of parent") |
35 |
node = node._parent |
36 |
continue |
37 |
ignore = True |
38 |
@@ -2216,20 +2219,28 @@ def check_required_use(required_use, use, iuse_match): |
39 |
stack[level].append(satisfied) |
40 |
node._satisfied = satisfied |
41 |
if node._parent._operator not in ("||", "^^"): |
42 |
- offset = node._parent._children.index(node) |
43 |
- node._parent._children.pop(offset) |
44 |
- for i, child in enumerate(node._children): |
45 |
- node._parent._children.insert(offset + i, child) |
46 |
+ last_node = node._parent._children.pop() |
47 |
+ if last_node is not node: |
48 |
+ raise AssertionError( |
49 |
+ "node is not last child of parent") |
50 |
+ for child in node._children: |
51 |
+ node._parent._children.append(child) |
52 |
if isinstance(child, _RequiredUseBranch): |
53 |
child._parent = node._parent |
54 |
node = node._parent |
55 |
continue |
56 |
|
57 |
if not node._children: |
58 |
- node._parent._children.remove(node) |
59 |
+ last_node = node._parent._children.pop() |
60 |
+ if last_node is not node: |
61 |
+ raise AssertionError( |
62 |
+ "node is not last child of parent") |
63 |
elif len(node._children) == 1: |
64 |
- index = node._parent._children.index(node) |
65 |
- node._parent._children[index] = node._children[0] |
66 |
+ last_node = node._parent._children.pop() |
67 |
+ if last_node is not node: |
68 |
+ raise AssertionError( |
69 |
+ "node is not last child of parent") |
70 |
+ node._parent._children.append(node._children[0]) |
71 |
if isinstance(node._children[0], _RequiredUseBranch): |
72 |
node._children[0]._parent = node._parent |
73 |
node = node._children[0] |
74 |
@@ -2238,10 +2249,10 @@ def check_required_use(required_use, use, iuse_match): |
75 |
if isinstance(child, _RequiredUseBranch) and \ |
76 |
child._operator is None and \ |
77 |
len(child._children) == 1: |
78 |
- node._children[index] = child._children[0] |
79 |
- if isinstance(node._children[index], |
80 |
- _RequiredUseBranch): |
81 |
- node._children[index]._parent = node |
82 |
+ child = child._children[0] |
83 |
+ node._children[index] = child |
84 |
+ if isinstance(child, _RequiredUseBranch): |
85 |
+ child._parent = node |
86 |
|
87 |
node = node._parent |
88 |
else: |
89 |
@@ -2277,6 +2288,13 @@ def check_required_use(required_use, use, iuse_match): |
90 |
raise InvalidDependString( |
91 |
_("malformed syntax: '%s'") % required_use) |
92 |
|
93 |
+ if len(tree._children) == 1: |
94 |
+ child = tree._children[0] |
95 |
+ if isinstance(child, _RequiredUseBranch) and \ |
96 |
+ child._operator is None: |
97 |
+ tree = child |
98 |
+ tree._parent = None |
99 |
+ |
100 |
tree._satisfied = False not in stack[0] |
101 |
return tree |
102 |
|
103 |
|
104 |
diff --git a/pym/portage/tests/dep/testCheckRequiredUse.py b/pym/portage/tests/dep/testCheckRequiredUse.py |
105 |
index 332c5a5..c5a8f53 100644 |
106 |
--- a/pym/portage/tests/dep/testCheckRequiredUse.py |
107 |
+++ b/pym/portage/tests/dep/testCheckRequiredUse.py |
108 |
@@ -190,6 +190,11 @@ class TestCheckRequiredUse(TestCase): |
109 |
"^^ ( ( a b c ) ( b c !d ) )", |
110 |
["a", "b", "c", "d"], |
111 |
"" |
112 |
+ ), |
113 |
+ ( |
114 |
+ "|| ( ( ( ( a ) ) ( ( ( b c ) ) ) ) )", |
115 |
+ [""], |
116 |
+ "a b c" |
117 |
) |
118 |
) |
119 |
for required_use, use, expected in test_cases: |