* [gentoo-commits] proj/portage:2.1.9 commit in: pym/portage/dep/, pym/portage/tests/dep/
@ 2011-02-05 0:59 Zac Medico
0 siblings, 0 replies; 5+ messages in thread
From: Zac Medico @ 2011-02-05 0:59 UTC (permalink / raw
To: gentoo-commits
commit: 5dc4bb046b871088923313bce4b66bde3c8e2e80
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 4 22:31:32 2011 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Feb 5 00:30:54 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=5dc4bb04
check_required_use: clarify operator logic
---
pym/portage/dep/__init__.py | 15 +++++++--------
pym/portage/tests/dep/testCheckRequiredUse.py | 5 +++++
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index b27d589..b429e56 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -2187,10 +2187,9 @@ def check_required_use(required_use, use, iuse_match):
if level > 0:
level -= 1
l = stack.pop()
- ignore = False
+ op = None
if stack[level]:
if stack[level][-1] in ("||", "^^"):
- ignore = True
op = stack[level].pop()
satisfied = is_satisfied(op, l)
stack[level].append(satisfied)
@@ -2198,13 +2197,12 @@ def check_required_use(required_use, use, iuse_match):
elif not isinstance(stack[level][-1], bool) and \
stack[level][-1][-1] == "?":
- if is_active(stack[level][-1][:-1]):
- op = stack[level].pop()
+ op = stack[level].pop()
+ if is_active(op[:-1]):
satisfied = is_satisfied(op, l)
stack[level].append(satisfied)
node._satisfied = satisfied
else:
- stack[level].pop()
node._satisfied = True
last_node = node._parent._children.pop()
if last_node is not node:
@@ -2212,12 +2210,13 @@ def check_required_use(required_use, use, iuse_match):
"node is not last child of parent")
node = node._parent
continue
- ignore = True
- if l and not ignore:
+ if op is None:
satisfied = False not in l
- stack[level].append(satisfied)
node._satisfied = satisfied
+ if l:
+ stack[level].append(satisfied)
+
if node._parent._operator not in ("||", "^^"):
last_node = node._parent._children.pop()
if last_node is not node:
diff --git a/pym/portage/tests/dep/testCheckRequiredUse.py b/pym/portage/tests/dep/testCheckRequiredUse.py
index c5a8f53..a0e10b1 100644
--- a/pym/portage/tests/dep/testCheckRequiredUse.py
+++ b/pym/portage/tests/dep/testCheckRequiredUse.py
@@ -195,6 +195,11 @@ class TestCheckRequiredUse(TestCase):
"|| ( ( ( ( a ) ) ( ( ( b c ) ) ) ) )",
[""],
"a b c"
+ ),
+ (
+ "|| ( ( a ( ( ) ( ) ) ( ( ) ) ( b ( ) c ) ) )",
+ [""],
+ "a b c"
)
)
for required_use, use, expected in test_cases:
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/portage:2.1.9 commit in: pym/portage/dep/, pym/portage/tests/dep/
@ 2011-02-08 0:54 Zac Medico
0 siblings, 0 replies; 5+ messages in thread
From: Zac Medico @ 2011-02-08 0:54 UTC (permalink / raw
To: gentoo-commits
commit: ca57018f8dd8d65f2df5c5df636c2cd7db8445d9
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 7 21:59:23 2011 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Feb 8 00:53:16 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=ca57018f
paren_reduce: allow parens in atoms, for EAPI 4
This will fix bug #354003.
---
pym/portage/dep/__init__.py | 2 +-
pym/portage/tests/dep/test_paren_reduce.py | 2 ++
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index cf83e0a..a8d05f1 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -178,7 +178,7 @@ def paren_reduce(mystr):
need_bracket = True
stack[level].append(token)
else:
- if need_bracket or "(" in token or ")" in token or "|" in token:
+ if need_bracket:
raise InvalidDependString(
_("malformed syntax: '%s'") % mystr)
diff --git a/pym/portage/tests/dep/test_paren_reduce.py b/pym/portage/tests/dep/test_paren_reduce.py
index 6aac955..a7bbf97 100644
--- a/pym/portage/tests/dep/test_paren_reduce.py
+++ b/pym/portage/tests/dep/test_paren_reduce.py
@@ -30,6 +30,8 @@ class TestParenReduce(TestCase):
( "|| ( ( A B ) C )", [ "||", [ ["A", "B"], "C"] ]),
( "|| ( ( A B ) ( C ) )", [ "||", [ ["A", "B"], "C"] ]),
+ # test USE dep defaults for bug #354003
+ ( ">=dev-lang/php-5.2[pcre(+)]", [ ">=dev-lang/php-5.2[pcre(+)]" ]),
)
test_cases_xfail = (
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/portage:2.1.9 commit in: pym/portage/dep/, pym/portage/tests/dep/
@ 2011-02-05 0:59 Zac Medico
0 siblings, 0 replies; 5+ messages in thread
From: Zac Medico @ 2011-02-05 0:59 UTC (permalink / raw
To: gentoo-commits
commit: b88dde55fae635e4d43634acb62711d8435fcd42
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 5 00:16:15 2011 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Feb 5 00:31:08 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b88dde55
REQUIRED_USE: fix parens display and test more
---
pym/portage/dep/__init__.py | 21 ++++++++++++---------
pym/portage/tests/dep/testCheckRequiredUse.py | 12 +++++++++++-
2 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 6b125f0..571f6c1 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -2217,7 +2217,8 @@ def check_required_use(required_use, use, iuse_match):
if l:
stack[level].append(satisfied)
- if node._parent._operator not in ("||", "^^"):
+ if len(node._children) <= 1 or \
+ node._parent._operator not in ("||", "^^"):
last_node = node._parent._children.pop()
if last_node is not node:
raise AssertionError(
@@ -2242,7 +2243,16 @@ def check_required_use(required_use, use, iuse_match):
if isinstance(node._children[0], _RequiredUseBranch):
node._children[0]._parent = node._parent
node = node._children[0]
-
+ if node._operator is None and \
+ node._parent._operator not in ("||", "^^"):
+ last_node = node._parent._children.pop()
+ if last_node is not node:
+ raise AssertionError(
+ "node is not last child of parent")
+ for child in node._children:
+ node._parent._children.append(child)
+ if isinstance(child, _RequiredUseBranch):
+ child._parent = node._parent
else:
for index, child in enumerate(node._children):
if isinstance(child, _RequiredUseBranch) and \
@@ -2287,13 +2297,6 @@ def check_required_use(required_use, use, iuse_match):
raise InvalidDependString(
_("malformed syntax: '%s'") % required_use)
- if len(tree._children) == 1:
- child = tree._children[0]
- if isinstance(child, _RequiredUseBranch) and \
- child._operator is None:
- tree = child
- tree._parent = None
-
tree._satisfied = False not in stack[0]
return tree
diff --git a/pym/portage/tests/dep/testCheckRequiredUse.py b/pym/portage/tests/dep/testCheckRequiredUse.py
index a0e10b1..54791e0 100644
--- a/pym/portage/tests/dep/testCheckRequiredUse.py
+++ b/pym/portage/tests/dep/testCheckRequiredUse.py
@@ -192,6 +192,11 @@ class TestCheckRequiredUse(TestCase):
""
),
(
+ "( ( ( a ) ) ( ( ( b c ) ) ) )",
+ [""],
+ "a b c"
+ ),
+ (
"|| ( ( ( ( a ) ) ( ( ( b c ) ) ) ) )",
[""],
"a b c"
@@ -200,7 +205,12 @@ class TestCheckRequiredUse(TestCase):
"|| ( ( a ( ( ) ( ) ) ( ( ) ) ( b ( ) c ) ) )",
[""],
"a b c"
- )
+ ),
+ (
+ "|| ( ( a b c ) ) || ( ( d e f ) )",
+ [""],
+ "a b c d e f"
+ ),
)
for required_use, use, expected in test_cases:
result = check_required_use(required_use, use, lambda k: True).tounicode()
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/portage:2.1.9 commit in: pym/portage/dep/, pym/portage/tests/dep/
@ 2011-02-04 21:41 Zac Medico
0 siblings, 0 replies; 5+ messages in thread
From: Zac Medico @ 2011-02-04 21:41 UTC (permalink / raw
To: gentoo-commits
commit: f465f3a21c4e814885d53ce29c7e6e4ab38db16f
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 4 21:07:52 2011 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Feb 4 21:41:34 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=f465f3a2
REQUIRED_USE: fix parens display and test more
---
pym/portage/dep/__init__.py | 44 +++++++++++++++++-------
pym/portage/tests/dep/testCheckRequiredUse.py | 5 +++
2 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 62e96d2..b27d589 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -1,5 +1,5 @@
# deps.py -- Portage dependency resolution functions
-# Copyright 2003-2010 Gentoo Foundation
+# Copyright 2003-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
__all__ = [
@@ -2206,7 +2206,10 @@ def check_required_use(required_use, use, iuse_match):
else:
stack[level].pop()
node._satisfied = True
- node._parent._children.remove(node)
+ last_node = node._parent._children.pop()
+ if last_node is not node:
+ raise AssertionError(
+ "node is not last child of parent")
node = node._parent
continue
ignore = True
@@ -2216,20 +2219,28 @@ def check_required_use(required_use, use, iuse_match):
stack[level].append(satisfied)
node._satisfied = satisfied
if node._parent._operator not in ("||", "^^"):
- offset = node._parent._children.index(node)
- node._parent._children.pop(offset)
- for i, child in enumerate(node._children):
- node._parent._children.insert(offset + i, child)
+ last_node = node._parent._children.pop()
+ if last_node is not node:
+ raise AssertionError(
+ "node is not last child of parent")
+ for child in node._children:
+ node._parent._children.append(child)
if isinstance(child, _RequiredUseBranch):
child._parent = node._parent
node = node._parent
continue
if not node._children:
- node._parent._children.remove(node)
+ last_node = node._parent._children.pop()
+ if last_node is not node:
+ raise AssertionError(
+ "node is not last child of parent")
elif len(node._children) == 1:
- index = node._parent._children.index(node)
- node._parent._children[index] = node._children[0]
+ last_node = node._parent._children.pop()
+ if last_node is not node:
+ raise AssertionError(
+ "node is not last child of parent")
+ node._parent._children.append(node._children[0])
if isinstance(node._children[0], _RequiredUseBranch):
node._children[0]._parent = node._parent
node = node._children[0]
@@ -2238,10 +2249,10 @@ def check_required_use(required_use, use, iuse_match):
if isinstance(child, _RequiredUseBranch) and \
child._operator is None and \
len(child._children) == 1:
- node._children[index] = child._children[0]
- if isinstance(node._children[index],
- _RequiredUseBranch):
- node._children[index]._parent = node
+ child = child._children[0]
+ node._children[index] = child
+ if isinstance(child, _RequiredUseBranch):
+ child._parent = node
node = node._parent
else:
@@ -2277,6 +2288,13 @@ def check_required_use(required_use, use, iuse_match):
raise InvalidDependString(
_("malformed syntax: '%s'") % required_use)
+ if len(tree._children) == 1:
+ child = tree._children[0]
+ if isinstance(child, _RequiredUseBranch) and \
+ child._operator is None:
+ tree = child
+ tree._parent = None
+
tree._satisfied = False not in stack[0]
return tree
diff --git a/pym/portage/tests/dep/testCheckRequiredUse.py b/pym/portage/tests/dep/testCheckRequiredUse.py
index 332c5a5..c5a8f53 100644
--- a/pym/portage/tests/dep/testCheckRequiredUse.py
+++ b/pym/portage/tests/dep/testCheckRequiredUse.py
@@ -190,6 +190,11 @@ class TestCheckRequiredUse(TestCase):
"^^ ( ( a b c ) ( b c !d ) )",
["a", "b", "c", "d"],
""
+ ),
+ (
+ "|| ( ( ( ( a ) ) ( ( ( b c ) ) ) ) )",
+ [""],
+ "a b c"
)
)
for required_use, use, expected in test_cases:
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/portage:2.1.9 commit in: pym/portage/dep/, pym/portage/tests/dep/
@ 2011-02-04 6:07 zmedico
0 siblings, 0 replies; 5+ messages in thread
From: zmedico @ 2011-02-04 6:07 UTC (permalink / raw
To: gentoo-commits
commit: 99e44795c9fcbdd9c5630b9b8fe0ebff8322fd68
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 4 05:42:18 2011 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Feb 4 06:07:33 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=99e44795c9fcbdd9c5630b9b8fe0ebff8322fd68
REQUIRED_USE: fix parens display and test more
---
pym/portage/dep/__init__.py | 35 ++++++++++++++++++++++--
pym/portage/tests/dep/testCheckRequiredUse.py | 17 +++++++++++-
2 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 0300b74..68e628b 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -2088,9 +2088,7 @@ class _RequiredUseBranch(object):
def tounicode(self):
- include_parens = self._parent is not None and \
- (self._operator is not None or \
- self._parent._operator is None)
+ include_parens = self._parent is not None
tokens = []
if self._operator is not None:
tokens.append(self._operator)
@@ -2197,6 +2195,7 @@ def check_required_use(required_use, use, iuse_match):
satisfied = is_satisfied(op, l)
stack[level].append(satisfied)
node._satisfied = satisfied
+
elif not isinstance(stack[level][-1], bool) and \
stack[level][-1][-1] == "?":
if is_active(stack[level][-1][:-1]):
@@ -2207,12 +2206,42 @@ def check_required_use(required_use, use, iuse_match):
else:
stack[level].pop()
node._satisfied = True
+ node._parent._children.remove(node)
+ node = node._parent
+ continue
ignore = True
if l and not ignore:
satisfied = False not in l
stack[level].append(satisfied)
node._satisfied = satisfied
+ if node._parent._operator not in ("||", "^^"):
+ offset = node._parent._children.index(node)
+ node._parent._children.remove(node)
+ for i, child in enumerate(node._children):
+ node._parent._children.insert(offset + i, child)
+ if isinstance(child, _RequiredUseBranch):
+ child._parent = node._parent
+ node = node._parent
+ continue
+
+ if not node._children:
+ node._parent._children.remove(node)
+ elif len(node._children) == 1:
+ index = node._parent._children.index(node)
+ node._parent._children[index] = node._children[0]
+ if isinstance(node._children[0], _RequiredUseBranch):
+ node._children[0]._parent = node._parent
+ node = node._children[0]
+ else:
+ for index, child in enumerate(node._children):
+ if isinstance(child, _RequiredUseBranch) and \
+ child._operator is None and \
+ len(child._children) == 1:
+ node._children[index] = child._children[0]
+ if isinstance(node._children[index],
+ _RequiredUseBranch):
+ node._children[index]._parent = node
node = node._parent
else:
diff --git a/pym/portage/tests/dep/testCheckRequiredUse.py b/pym/portage/tests/dep/testCheckRequiredUse.py
index 0fb9702..d6a9d0c 100644
--- a/pym/portage/tests/dep/testCheckRequiredUse.py
+++ b/pym/portage/tests/dep/testCheckRequiredUse.py
@@ -134,7 +134,7 @@ class TestCheckRequiredUse(TestCase):
(
"^^ ( || ( ( a b ) ) ( c ) )",
("a", "b", "c"),
- "^^ ( || ( a b ) c )"
+ "^^ ( ( a b ) c )"
),
(
"a? ( ( c e ) ( b d ) )",
@@ -147,6 +147,11 @@ class TestCheckRequiredUse(TestCase):
"a? ( d )"
),
(
+ "a? ( ( c e ) ( c e b c d e c ) )",
+ ("a", "c", "e"),
+ "a? ( b d )"
+ ),
+ (
"^^ ( || ( a b ) ^^ ( b c ) )",
("a", "b"),
"^^ ( || ( a b ) ^^ ( b c ) )"
@@ -165,6 +170,16 @@ class TestCheckRequiredUse(TestCase):
"^^ ( || ( a b ) ^^ ( b c ) )",
["a", "b", "c"],
""
+ ),
+ (
+ "^^ ( ( a b c ) ( b c d ) )",
+ ["a", "b", "c"],
+ ""
+ ),
+ (
+ "^^ ( ( a b c ) ( b c d ) )",
+ ["a", "b", "c", "d"],
+ "^^ ( ( a b c ) ( b c d ) )"
)
)
for required_use, use, expected in test_cases:
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-02-08 0:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-05 0:59 [gentoo-commits] proj/portage:2.1.9 commit in: pym/portage/dep/, pym/portage/tests/dep/ Zac Medico
-- strict thread matches above, loose matches on Subject: below --
2011-02-08 0:54 Zac Medico
2011-02-05 0:59 Zac Medico
2011-02-04 21:41 Zac Medico
2011-02-04 6:07 zmedico
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox