public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/portage/tests/dep/
@ 2011-02-04  5:42 zmedico
  0 siblings, 0 replies; 15+ messages in thread
From: zmedico @ 2011-02-04  5:42 UTC (permalink / raw
  To: gentoo-commits

commit:     39fe4fcfebab8ce9406165bac511302f01a8ca0e
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 05:42:18 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=39fe4fcfebab8ce9406165bac511302f01a8ca0e

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] 15+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/portage/tests/dep/
@ 2011-02-04 21:07 zmedico
  0 siblings, 0 replies; 15+ messages in thread
From: zmedico @ 2011-02-04 21:07 UTC (permalink / raw
  To: gentoo-commits

commit:     3791c8aa4cb242aa2b507b6bac368925aad067b1
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:07:52 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=3791c8aa

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] 15+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/portage/tests/dep/
@ 2011-02-04 22:32 Zac Medico
  0 siblings, 0 replies; 15+ messages in thread
From: Zac Medico @ 2011-02-04 22:32 UTC (permalink / raw
  To: gentoo-commits

commit:     9ba0d885cddeb7de649e09a2c9276f25c4190b5e
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: Fri Feb  4 22:31:32 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=9ba0d885

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] 15+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/portage/tests/dep/
@ 2011-02-05  0:16 Zac Medico
  0 siblings, 0 replies; 15+ messages in thread
From: Zac Medico @ 2011-02-05  0:16 UTC (permalink / raw
  To: gentoo-commits

commit:     6c9cbe5ab35ba4fd666924fbac4ad63d8f820719
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:16:15 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=6c9cbe5a

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] 15+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/portage/tests/dep/
@ 2011-02-07 22:00 Zac Medico
  0 siblings, 0 replies; 15+ messages in thread
From: Zac Medico @ 2011-02-07 22:00 UTC (permalink / raw
  To: gentoo-commits

commit:     8735222b77e66850213e2aa6a7ea48e744ba0d4f
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: Mon Feb  7 21:59:23 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=8735222b

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] 15+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/portage/tests/dep/
@ 2011-06-09 14:24 Zac Medico
  0 siblings, 0 replies; 15+ messages in thread
From: Zac Medico @ 2011-06-09 14:24 UTC (permalink / raw
  To: gentoo-commits

commit:     1faa9bddc2859c73ce8984b43eca816c30bdb5f1
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Gentoo <DOT> Org>
AuthorDate: Thu Jun  9 14:23:28 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Jun  9 14:23:28 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=1faa9bdd

use_reduce: disallow empty parens

This will fix bug #370565.

---
 pym/portage/dep/__init__.py              |    3 +++
 pym/portage/tests/dep/test_use_reduce.py |    6 +++---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 8621543..ba37324 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -369,6 +369,9 @@ def use_reduce(depstr, uselist=[], masklist=[], matchall=False, excludeall=[], i
 			if need_simple_token:
 				raise InvalidDependString(
 					_("expected: file name, got: '%s', token %s") % (token, pos+1))
+			if len(mysplit) >= pos+2 and mysplit[pos+1] == ")":
+				raise InvalidDependString(
+					_("expected: dependency string, got: ')', token %s") % (pos+1,))
 			need_bracket = False
 			stack.append([])
 			level += 1

diff --git a/pym/portage/tests/dep/test_use_reduce.py b/pym/portage/tests/dep/test_use_reduce.py
index 7c7286a..b89752f 100644
--- a/pym/portage/tests/dep/test_use_reduce.py
+++ b/pym/portage/tests/dep/test_use_reduce.py
@@ -217,7 +217,7 @@ class UseReduce(TestCase):
 				uselist = ["foo", "bar"],
 				expected_result = [ "||", [ "A", "B" ] ]),
 			UseReduceTestCase(
-				"A || ( ) foo? ( ) B",
+				"A || ( bar? ( C ) ) foo? ( bar? ( C ) ) B",
 				expected_result = ["A", "B"]),
 			UseReduceTestCase(
 				"|| ( A ) || ( B )",
@@ -350,7 +350,7 @@ class UseReduce(TestCase):
 				opconvert = True,
 				expected_result = [['||', 'A', 'B']]),
 			UseReduceTestCase(
-				"A || ( ) foo? ( ) B",
+				"A || ( bar? ( C ) ) foo? ( bar? ( C ) ) B",
 				opconvert = True,
 				expected_result = ["A", "B"]),
 			UseReduceTestCase(
@@ -509,7 +509,7 @@ class UseReduce(TestCase):
 				flat = True,
 				expected_result = [ "||", "||", "A", "||", "B" ]),
 			UseReduceTestCase(
-				"A || ( ) foo? ( ) B",
+				"A || ( bar? ( C ) ) foo? ( bar? ( C ) ) B",
 				flat = True,
 				expected_result = ["A", "||", "B"]),
 			UseReduceTestCase(



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/portage/tests/dep/
@ 2011-06-09 18:48 Zac Medico
  0 siblings, 0 replies; 15+ messages in thread
From: Zac Medico @ 2011-06-09 18:48 UTC (permalink / raw
  To: gentoo-commits

commit:     d85506e8a37778e0935f43f9e7cc62bb8b933063
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Jun  9 18:48:19 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Jun  9 18:48:19 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=d85506e8

useflag/dep_re: less strict if eapi None

When eapi is None then validation is not as strict, since we want the
same to work for multiple EAPIs that may have slightly different rules.

---
 pym/portage/dep/__init__.py              |   19 +++++++++++++++----
 pym/portage/tests/dep/test_use_reduce.py |    2 +-
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index ba37324..b9020a7 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -641,13 +641,15 @@ _usedep_re = {
 
 def _get_usedep_re(eapi):
 	"""
+	When eapi is None then validation is not as strict, since we want the
+	same to work for multiple EAPIs that may have slightly different rules.
 	@param eapi: The EAPI
 	@type eapi: String or None
 	@rtype: regular expression object
-	@return: A regular expression object that matches valid USE flags for the
-		given eapi. If eapi is None then the latest supported EAPI is assumed.
+	@return: A regular expression object that matches valid USE deps for the
+		given eapi.
 	"""
-	if eapi in ("4-python",):
+	if eapi in (None, "4-python",):
 		return _usedep_re["4-python"]
 	else:
 		return _usedep_re["0"]
@@ -1625,7 +1627,16 @@ _useflag_re = {
 }
 
 def _get_useflag_re(eapi):
-	if eapi in ("4-python",):
+	"""
+	When eapi is None then validation is not as strict, since we want the
+	same to work for multiple EAPIs that may have slightly different rules.
+	@param eapi: The EAPI
+	@type eapi: String or None
+	@rtype: regular expression object
+	@return: A regular expression object that matches valid USE flags for the
+		given eapi.
+	"""
+	if eapi in (None, "4-python",):
 		return _useflag_re["4-python"]
 	else:
 		return _useflag_re["0"]

diff --git a/pym/portage/tests/dep/test_use_reduce.py b/pym/portage/tests/dep/test_use_reduce.py
index ac81563..1618430 100644
--- a/pym/portage/tests/dep/test_use_reduce.py
+++ b/pym/portage/tests/dep/test_use_reduce.py
@@ -8,7 +8,7 @@ from portage.dep import Atom, use_reduce
 class UseReduceTestCase(object):
 	def __init__(self, deparray, uselist=[], masklist=[], \
 		matchall=0, excludeall=[], is_src_uri=False, \
-		eapi=None, opconvert=False, flat=False, expected_result=None, \
+		eapi="0", opconvert=False, flat=False, expected_result=None, \
 			is_valid_flag=None, token_class=None):
 		self.deparray = deparray
 		self.uselist = uselist



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/portage/tests/dep/
@ 2011-10-04  4:45 Zac Medico
  0 siblings, 0 replies; 15+ messages in thread
From: Zac Medico @ 2011-10-04  4:45 UTC (permalink / raw
  To: gentoo-commits

commit:     b33ab8168a18391cc8ebe3d0b8bbcdc53a1a1c3d
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Oct  4 04:44:46 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Oct  4 04:44:46 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b33ab816

best_match_to_list: order by version number

This should fix the issue shown in bug 375265, comment #10.

---
 pym/portage/dep/__init__.py                      |   36 +++++++++++++++++++++-
 pym/portage/tests/dep/test_best_match_to_list.py |    4 ++
 2 files changed, 39 insertions(+), 1 deletions(-)

diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 21e2fac..8c65d66 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -30,13 +30,19 @@ __all__ = [
 import re, sys
 import warnings
 from itertools import chain
+
+import portage
+portage.proxy.lazyimport.lazyimport(globals(),
+	'portage.util:cmp_sort_key',
+)
+
 from portage import _unicode_decode
 from portage.eapi import eapi_has_slot_deps, eapi_has_src_uri_arrows, \
 	eapi_has_use_deps, eapi_has_strong_blocks, eapi_has_use_dep_defaults
 from portage.exception import InvalidAtom, InvalidData, InvalidDependString
 from portage.localization import _
 from portage.versions import catpkgsplit, catsplit, \
-	pkgcmp, ververify, _cp, _cpv
+	pkgcmp, vercmp, ververify, _cp, _cpv
 import portage.cache.mappings
 
 if sys.hexversion >= 0x3000000:
@@ -1798,6 +1804,7 @@ def best_match_to_list(mypkg, mylist):
 		'>':2, '<':2, '>=':2, '<=':2, None:1}
 	maxvalue = -2
 	bestm  = None
+	mypkg_cpv = None
 	for x in match_to_list(mypkg, mylist):
 		if x.extended_syntax:
 			if dep_getslot(x) is not None:
@@ -1817,6 +1824,33 @@ def best_match_to_list(mypkg, mylist):
 		if op_val > maxvalue:
 			maxvalue = op_val
 			bestm  = x
+		elif op_val == maxvalue and op_val == 2:
+			# For >, <, >=, and <=, the one with the version
+			# closest to mypkg is the best match.
+			if mypkg_cpv is None:
+				mypkg_cpv = getattr(mypkg, "cpv", None)
+				if mypkg_cpv is None:
+					mypkg_cpv = remove_slot(mypkg)
+			if bestm.cpv == mypkg_cpv or bestm.cpv == x.cpv:
+				pass
+			elif x.cpv == mypkg_cpv:
+				bestm = x
+			else:
+				# Sort the cpvs to find the one closest to mypkg_cpv
+				cpv_list = [bestm.cpv, mypkg_cpv, x.cpv]
+				ver_map = {}
+				for cpv in cpv_list:
+					ver_map[cpv] = '-'.join(catpkgsplit(cpv)[2:])
+				def cmp_cpv(cpv1, cpv2):
+					return vercmp(ver_map[cpv1], ver_map[cpv2])
+				cpv_list.sort(key=cmp_sort_key(cmp_cpv))
+				if cpv_list[0] is mypkg_cpv or cpv_list[-1] is mypkg_cpv:
+					if cpv_list[1] is x.cpv:
+						bestm = x
+				else:
+					# TODO: handle the case where mypkg_cpv is in the middle
+					pass
+
 	return bestm
 
 def match_from_list(mydep, candidate_list):

diff --git a/pym/portage/tests/dep/test_best_match_to_list.py b/pym/portage/tests/dep/test_best_match_to_list.py
index d050adc..9cf5abd 100644
--- a/pym/portage/tests/dep/test_best_match_to_list.py
+++ b/pym/portage/tests/dep/test_best_match_to_list.py
@@ -25,6 +25,10 @@ class Test_best_match_to_list(TestCase):
 
 	def testBest_match_to_list(self):
 		tests = [
+					("dev-libs/A-4", [Atom(">=dev-libs/A-3"), Atom(">=dev-libs/A-2")], \
+						[Atom(">=dev-libs/A-3"), Atom(">=dev-libs/A-2")]),
+					("dev-libs/A-4", [Atom("<=dev-libs/A-5"), Atom("<=dev-libs/A-6")], \
+						[Atom("<=dev-libs/A-5"), Atom("<=dev-libs/A-6")]),
 					("dev-libs/A-1", [Atom("dev-libs/A"), Atom("=dev-libs/A-1")], \
 						[Atom("=dev-libs/A-1"), Atom("dev-libs/A")]),
 					("dev-libs/A-1", [Atom("dev-libs/B"), Atom("=dev-libs/A-1:0")], \



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/portage/tests/dep/
@ 2012-05-13 20:11 Zac Medico
  0 siblings, 0 replies; 15+ messages in thread
From: Zac Medico @ 2012-05-13 20:11 UTC (permalink / raw
  To: gentoo-commits

commit:     e8b6b0c64b081d919398a1afcb3cb97852c77a29
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun May 13 20:10:52 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun May 13 20:10:52 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=e8b6b0c6

cpvequal: use _pkg_str

---
 pym/portage/dep/__init__.py             |   27 +++++++++++++++++++--------
 pym/portage/tests/dep/testStandalone.py |    5 +++--
 2 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 31ec75c..0c92857 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -76,16 +76,27 @@ def cpvequal(cpv1, cpv2):
 
 	"""
 
-	split1 = catpkgsplit(cpv1)
-	split2 = catpkgsplit(cpv2)
-	
-	if not split1 or not split2:
+	try:
+		try:
+			split1 = cpv1.cpv_split
+		except AttributeError:
+			cpv1 = _pkg_str(cpv1)
+			split1 = cpv1.cpv_split
+
+		try:
+			split2 = cpv2.cpv_split
+		except AttributeError:
+			cpv2 = _pkg_str(cpv2)
+			split2 = cpv2.cpv_split
+
+	except InvalidData:
 		raise portage.exception.PortageException(_("Invalid data '%s, %s', parameter was not a CPV") % (cpv1, cpv2))
-	
-	if split1[0] != split2[0]:
+
+	if split1[0] != split2[0] or \
+		split1[1] != split2[1]:
 		return False
-	
-	return (pkgcmp(split1[1:], split2[1:]) == 0)
+
+	return vercmp(cpv1.version, cpv2.version) == 0
 
 def strip_empty(myarr):
 	"""

diff --git a/pym/portage/tests/dep/testStandalone.py b/pym/portage/tests/dep/testStandalone.py
index e9f01df..f03f2d5 100644
--- a/pym/portage/tests/dep/testStandalone.py
+++ b/pym/portage/tests/dep/testStandalone.py
@@ -1,4 +1,4 @@
-# Copyright 2010 Gentoo Foundation
+# Copyright 2010-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from portage.tests import TestCase
@@ -29,7 +29,8 @@ class TestStandalone(TestCase):
 		)
 
 		for cpv1, cpv2, expected_result in test_cases:
-			self.assertEqual(cpvequal(cpv1, cpv2), expected_result)
+			self.assertEqual(cpvequal(cpv1, cpv2), expected_result,
+				"cpvequal('%s', '%s') != %s" % (cpv1, cpv2, expected_result))
 
 		for cpv1, cpv2 in test_cases_xfail:
 			self.assertRaisesMsg("cpvequal("+cpv1+", "+cpv2+")", \



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/portage/tests/dep/
@ 2012-07-18 21:07 Zac Medico
  0 siblings, 0 replies; 15+ messages in thread
From: Zac Medico @ 2012-07-18 21:07 UTC (permalink / raw
  To: gentoo-commits

commit:     2472be18586f41c6e74a6d1f6a88c17a415eca9b
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 18 21:07:09 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Jul 18 21:07:09 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=2472be18

match_from_list: match slot for extended atoms

---
 pym/portage/dep/__init__.py                   |    2 +-
 pym/portage/tests/dep/test_match_from_list.py |    2 ++
 2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 8286e8d..e547deb 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -2237,7 +2237,7 @@ def match_from_list(mydep, candidate_list):
 	else:
 		raise KeyError(_("Unknown operator: %s") % mydep)
 
-	if mydep.slot is not None and not mydep.extended_syntax:
+	if mydep.slot is not None:
 		candidate_list = mylist
 		mylist = []
 		for x in candidate_list:

diff --git a/pym/portage/tests/dep/test_match_from_list.py b/pym/portage/tests/dep/test_match_from_list.py
index e80345d..d5d718f 100644
--- a/pym/portage/tests/dep/test_match_from_list.py
+++ b/pym/portage/tests/dep/test_match_from_list.py
@@ -74,6 +74,8 @@ class Test_match_from_list(TestCase):
 			("=sys-fs/udev-1*", ["sys-fs/udev-123"], ["sys-fs/udev-123"]),
 			("=sys-fs/udev-4*", ["sys-fs/udev-456"], ["sys-fs/udev-456"] ),
 			("*/*", ["sys-fs/udev-456"], ["sys-fs/udev-456"] ),
+			("*/*:0", ["sys-fs/udev-456:0"], ["sys-fs/udev-456:0"] ),
+			("*/*:1", ["sys-fs/udev-456:0"], [] ),
 			("sys-fs/*", ["sys-fs/udev-456"], ["sys-fs/udev-456"] ),
 			("*/udev", ["sys-fs/udev-456"], ["sys-fs/udev-456"] ),
 			("=sys-apps/portage-2*", ["sys-apps/portage-2.1"], ["sys-apps/portage-2.1"] ),



^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/portage/tests/dep/
@ 2012-09-18 20:17 Zac Medico
  0 siblings, 0 replies; 15+ messages in thread
From: Zac Medico @ 2012-09-18 20:17 UTC (permalink / raw
  To: gentoo-commits

commit:     61406033e6ae182d9f4a7fceea81871e74f9b0b6
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 18 20:17:34 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Sep 18 20:17:34 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=61406033

Atom: don't allow :slot* syntax

This syntax is useless, and PMS doesn't discuss it.

---
 pym/portage/dep/__init__.py                   |    2 ++
 pym/portage/tests/dep/testAtom.py             |    1 -
 pym/portage/tests/dep/test_isvalidatom.py     |    2 +-
 pym/portage/tests/dep/test_match_from_list.py |    2 --
 4 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 4d85f94..b4b240d 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -1333,6 +1333,8 @@ class Atom(_unicode):
 						sub_slot = sub_slot[:-1]
 					self.__dict__['sub_slot'] = sub_slot
 					self.__dict__['slot_operator'] = slot_operator
+				if self.slot is not None and self.slot_operator == "*":
+					raise InvalidAtom(self)
 			else:
 				self.__dict__['slot'] = slot
 				self.__dict__['sub_slot'] = None

diff --git a/pym/portage/tests/dep/testAtom.py b/pym/portage/tests/dep/testAtom.py
index 0c72fd0..094538d 100644
--- a/pym/portage/tests/dep/testAtom.py
+++ b/pym/portage/tests/dep/testAtom.py
@@ -155,7 +155,6 @@ class TestAtom(TestCase):
 			("virtual/ffmpeg:=", "4-slot-abi", {"slot": None, "sub_slot": None, "slot_operator": "="}),
 			("virtual/ffmpeg:0=", "4-slot-abi", {"slot": "0", "sub_slot": None, "slot_operator": "="}),
 			("virtual/ffmpeg:*", "4-slot-abi", {"slot": None, "sub_slot": None, "slot_operator": "*"}),
-			("virtual/ffmpeg:0*", "4-slot-abi", {"slot": "0", "sub_slot": None, "slot_operator": "*"}),
 			("virtual/ffmpeg:0", "4-slot-abi", {"slot": "0", "sub_slot": None, "slot_operator": None}),
 			("virtual/ffmpeg", "4-slot-abi", {"slot": None, "sub_slot": None, "slot_operator": None}),
 		)

diff --git a/pym/portage/tests/dep/test_isvalidatom.py b/pym/portage/tests/dep/test_isvalidatom.py
index abcec75..625bde5 100644
--- a/pym/portage/tests/dep/test_isvalidatom.py
+++ b/pym/portage/tests/dep/test_isvalidatom.py
@@ -141,7 +141,7 @@ class IsValidAtom(TestCase):
 			IsValidAtomTestCase("virtual/ffmpeg:=", True),
 			IsValidAtomTestCase("virtual/ffmpeg:0=", True),
 			IsValidAtomTestCase("virtual/ffmpeg:*", True),
-			IsValidAtomTestCase("virtual/ffmpeg:0*", True),
+			IsValidAtomTestCase("virtual/ffmpeg:0*", False),
 			IsValidAtomTestCase("virtual/ffmpeg:0", True),
 		)
 

diff --git a/pym/portage/tests/dep/test_match_from_list.py b/pym/portage/tests/dep/test_match_from_list.py
index 2a1945b..4a6ab3b 100644
--- a/pym/portage/tests/dep/test_match_from_list.py
+++ b/pym/portage/tests/dep/test_match_from_list.py
@@ -108,13 +108,11 @@ class Test_match_from_list(TestCase):
 			("virtual/ffmpeg:=", [Package("=virtual/ffmpeg-0.10.3:0/53")], ["virtual/ffmpeg-0.10.3"] ),
 			("virtual/ffmpeg:0=", [Package("=virtual/ffmpeg-0.10.3:0/53")], ["virtual/ffmpeg-0.10.3"] ),
 			("virtual/ffmpeg:*", [Package("=virtual/ffmpeg-0.10.3:0/53")], ["virtual/ffmpeg-0.10.3"] ),
-			("virtual/ffmpeg:0*", [Package("=virtual/ffmpeg-0.10.3:0/53")], ["virtual/ffmpeg-0.10.3"] ),
 			("virtual/ffmpeg:0", [Package("=virtual/ffmpeg-0.10.3:0/53")], ["virtual/ffmpeg-0.10.3"] ),
 
 			("sys-libs/db:4.8/4.8", [Package("=sys-libs/db-4.8.30:4.8")], ["sys-libs/db-4.8.30"] ),
 			("sys-libs/db:4.8/4.8=", [Package("=sys-libs/db-4.8.30:4.8")], ["sys-libs/db-4.8.30"] ),
 			("sys-libs/db:4.8=", [Package("=sys-libs/db-4.8.30:4.8")], ["sys-libs/db-4.8.30"] ),
-			("sys-libs/db:4.8*", [Package("=sys-libs/db-4.8.30:4.8")], ["sys-libs/db-4.8.30"] ),
 			("sys-libs/db:*", [Package("=sys-libs/db-4.8.30:4.8")], ["sys-libs/db-4.8.30"] ),
 			("sys-libs/db:4.8/0", [Package("=sys-libs/db-4.8.30:4.8")], [] ),
 			("sys-libs/db:4.8/0=", [Package("=sys-libs/db-4.8.30:4.8")], [] ),


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/portage/tests/dep/
@ 2013-01-04  4:35 Zac Medico
  0 siblings, 0 replies; 15+ messages in thread
From: Zac Medico @ 2013-01-04  4:35 UTC (permalink / raw
  To: gentoo-commits

commit:     fe1194b25031f40e51d1a82352bb7d79bcafe912
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Jan  4 04:35:40 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Jan  4 04:35:40 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=fe1194b2

test_paren_reduce: disable deprecation warning

---
 pym/portage/dep/__init__.py                |    4 ++--
 pym/portage/tests/dep/test_paren_reduce.py |   11 +++++++----
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 916d5ea..67383e8 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -255,7 +255,7 @@ def strip_empty(myarr):
 		('portage.dep.strip_empty',), DeprecationWarning, stacklevel=2)
 	return [x for x in myarr if x]
 
-def paren_reduce(mystr):
+def paren_reduce(mystr, _deprecation_warn=True):
 	"""
 	Take a string and convert all paren enclosed entities into sublists and
 	split the list elements by spaces. All redundant brackets are removed.
@@ -269,7 +269,7 @@ def paren_reduce(mystr):
 	@rtype: Array
 	@return: The reduced string in an array
 	"""
-	if portage._internal_caller:
+	if portage._internal_caller and _deprecation_warn:
 		warnings.warn(_("%s is deprecated and will be removed without replacement.") % \
 			('portage.dep.paren_reduce',), DeprecationWarning, stacklevel=2)
 	mysplit = mystr.split()

diff --git a/pym/portage/tests/dep/test_paren_reduce.py b/pym/portage/tests/dep/test_paren_reduce.py
index 9a147a0..1dfa648 100644
--- a/pym/portage/tests/dep/test_paren_reduce.py
+++ b/pym/portage/tests/dep/test_paren_reduce.py
@@ -1,4 +1,4 @@
-# Copyright 2010-2011 Gentoo Foundation
+# Copyright 2010-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from portage.tests import TestCase
@@ -57,10 +57,13 @@ class TestParenReduce(TestCase):
 		)
 
 		for dep_str, expected_result in test_cases:
-			self.assertEqual(paren_reduce(dep_str), expected_result,
+			self.assertEqual(paren_reduce(dep_str, _deprecation_warn=False),
+				expected_result,
 				"input: '%s' result: %s != %s" % (dep_str,
-				paren_reduce(dep_str), expected_result))
+				paren_reduce(dep_str, _deprecation_warn=False),
+				expected_result))
 
 		for dep_str in test_cases_xfail:
 			self.assertRaisesMsg(dep_str,
-				InvalidDependString, paren_reduce, dep_str)
+				InvalidDependString, paren_reduce, dep_str,
+					_deprecation_warn=False)


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/portage/tests/dep/
@ 2013-05-24 18:02 Zac Medico
  0 siblings, 0 replies; 15+ messages in thread
From: Zac Medico @ 2013-05-24 18:02 UTC (permalink / raw
  To: gentoo-commits

commit:     4839cd921b91e33b0e183d877fd9bd856250eb2a
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri May 24 18:02:22 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri May 24 18:02:22 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=4839cd92

Atom: handle invalid */foo-version wildcard

Before, a wildcard atom could be treated as valid even though it
specified a version without an operator, as reported at here:

https://forums.gentoo.org/viewtopic-p-7314746.html#7314746

---
 pym/portage/dep/__init__.py               |    6 ++++--
 pym/portage/tests/dep/test_isvalidatom.py |    5 ++++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 6f3b357..7776f89 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -29,7 +29,7 @@ from portage.eapi import _get_eapi_attrs
 from portage.exception import InvalidAtom, InvalidData, InvalidDependString
 from portage.localization import _
 from portage.versions import catpkgsplit, catsplit, \
-	vercmp, ververify, _cp, _cpv, _pkg_str, _slot, _unknown_repo
+	vercmp, ververify, _cp, _cpv, _pkg_str, _slot, _unknown_repo, _vr
 import portage.cache.mappings
 
 if sys.hexversion >= 0x3000000:
@@ -121,7 +121,7 @@ def _get_atom_wildcard_re(eapi_attrs):
 		pkg_re = r'[\w+*][\w+*-]*?'
 
 	atom_re = re.compile(r'((?P<simple>(' +
-		_extended_cat + r')/(' + pkg_re + r'))' + \
+		_extended_cat + r')/(' + pkg_re + r'(-' + _vr + ')?))' + \
 		'|(?P<star>=((' + _extended_cat + r')/(' + pkg_re + r'))-(?P<version>\*\w+\*)))' + \
 		'(:(?P<slot>' + _slot_loose + r'))?(' +
 		_repo_separator + r'(?P<repo>' + _repo_name + r'))?$', re.UNICODE)
@@ -1243,6 +1243,8 @@ class Atom(_unicode):
 				else:
 					op = None
 					cpv = cp = m.group('simple')
+					if m.group(atom_re.groupindex['simple'] + 3) is not None:
+						raise InvalidAtom(self)
 				if cpv.find("**") != -1:
 					raise InvalidAtom(self)
 				slot = m.group('slot')

diff --git a/pym/portage/tests/dep/test_isvalidatom.py b/pym/portage/tests/dep/test_isvalidatom.py
index 6b0566d..67ba603 100644
--- a/pym/portage/tests/dep/test_isvalidatom.py
+++ b/pym/portage/tests/dep/test_isvalidatom.py
@@ -1,4 +1,4 @@
-# Copyright 2006-2010 Gentoo Foundation
+# Copyright 2006-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from portage.tests import TestCase
@@ -143,6 +143,9 @@ class IsValidAtom(TestCase):
 			IsValidAtomTestCase("virtual/ffmpeg:*", True),
 			IsValidAtomTestCase("virtual/ffmpeg:0*", False),
 			IsValidAtomTestCase("virtual/ffmpeg:0", True),
+
+			# Wildcard atoms
+			IsValidAtomTestCase("*/portage-2.1", False, allow_wildcard=True),
 		)
 
 		for test_case in test_cases:


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/portage/tests/dep/
@ 2013-06-09  0:23 Zac Medico
  0 siblings, 0 replies; 15+ messages in thread
From: Zac Medico @ 2013-06-09  0:23 UTC (permalink / raw
  To: gentoo-commits

commit:     889e19d27ac978dbbc9699bac152657675569ebd
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 00:22:50 2013 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 00:22:50 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=889e19d2

match_from_list: =* op with revision, bug #467826

---
 pym/portage/dep/__init__.py                   | 32 ++++++++++++++++++++++-----
 pym/portage/tests/dep/test_match_from_list.py |  7 +++++-
 2 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 7776f89..798903f 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -2164,15 +2164,37 @@ def match_from_list(mydep, candidate_list):
 		myver = mycpv_cps[2].lstrip("0")
 		if not myver or not myver[0].isdigit():
 			myver = "0"+myver
-		mycpv_cmp = mycpv_cps[0] + "/" + mycpv_cps[1] + "-" + myver
+		if myver == mycpv_cps[2]:
+			mycpv_cmp = mycpv
+		else:
+			# Use replace to preserve the revision part if it exists
+			# (mycpv_cps[3] can't be trusted because in contains r0
+			# even when the input has no revision part).
+			mycpv_cmp = mycpv.replace(
+				mydep.cp + "-" + mycpv_cps[2],
+				mydep.cp + "-" + myver, 1)
 		for x in candidate_list:
-			xs = getattr(x, "cpv_split", None)
-			if xs is None:
-				xs = catpkgsplit(remove_slot(x))
+			try:
+				x.cp
+			except AttributeError:
+				try:
+					pkg = _pkg_str(remove_slot(x))
+				except InvalidData:
+					continue
+			else:
+				pkg = x
+
+			xs = pkg.cpv_split
 			myver = xs[2].lstrip("0")
 			if not myver or not myver[0].isdigit():
 				myver = "0"+myver
-			xcpv = xs[0]+"/"+xs[1]+"-"+myver
+			if myver == xs[2]:
+				xcpv = pkg.cpv
+			else:
+				# Use replace to preserve the revision part if it exists.
+				xcpv = pkg.cpv.replace(
+					pkg.cp + "-" + xs[2],
+					pkg.cp + "-" + myver, 1)
 			if xcpv.startswith(mycpv_cmp):
 				mylist.append(x)
 

diff --git a/pym/portage/tests/dep/test_match_from_list.py b/pym/portage/tests/dep/test_match_from_list.py
index b648624..8a1c9e2 100644
--- a/pym/portage/tests/dep/test_match_from_list.py
+++ b/pym/portage/tests/dep/test_match_from_list.py
@@ -1,4 +1,4 @@
-# Copyright 2006-2012 Gentoo Foundation
+# Copyright 2006-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import sys
@@ -71,6 +71,11 @@ class Test_match_from_list(TestCase):
 			(">sys-apps/portage-047", ["sys-apps/portage-046-r1"], []),
 			("sys-apps/portage:0", [Package("=sys-apps/portage-045:0")], ["sys-apps/portage-045"]),
 			("sys-apps/portage:0", [Package("=sys-apps/portage-045:1")], []),
+			("=cat/pkg-1-r1*", ["cat/pkg-1_alpha1"], []),
+			("=cat/pkg-1-r1*", ["cat/pkg-1-r11"], ["cat/pkg-1-r11"]),
+			("=cat/pkg-1-r1*", ["cat/pkg-01-r11"], ["cat/pkg-01-r11"]),
+			("=cat/pkg-01-r1*", ["cat/pkg-1-r11"], ["cat/pkg-1-r11"]),
+			("=cat/pkg-01-r1*", ["cat/pkg-001-r11"], ["cat/pkg-001-r11"]),
 			("=sys-fs/udev-1*", ["sys-fs/udev-123"], ["sys-fs/udev-123"]),
 			("=sys-fs/udev-4*", ["sys-fs/udev-456"], ["sys-fs/udev-456"]),
 			("*/*", ["sys-fs/udev-456"], ["sys-fs/udev-456"]),


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/portage/tests/dep/
@ 2015-09-21 20:15 Zac Medico
  0 siblings, 0 replies; 15+ messages in thread
From: Zac Medico @ 2015-09-21 20:15 UTC (permalink / raw
  To: gentoo-commits

commit:     d4966a381ee4577818bd972946647338046715b1
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Sep 21 01:52:19 2015 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Sep 21 20:13:36 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=d4966a38

match_from_list: restrict =* to match only on version part boundaries (bug 560466)

Make the =* glob match only on boundaries between version parts, in order
to eliminate ambiguity (so that 1* does not match version 10). Only break
compatibility in cases where dependencies have been specified ambiguously.

X-Gentoo-Bug: 560466
X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=560466
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>

 pym/portage/dep/__init__.py                   |  7 ++++++-
 pym/portage/tests/dep/test_match_from_list.py | 21 +++++++++++++++------
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 0a13d9f..5dd1638 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -2250,7 +2250,12 @@ def match_from_list(mydep, candidate_list):
 					pkg.cp + "-" + xs[2],
 					pkg.cp + "-" + myver, 1)
 			if xcpv.startswith(mycpv_cmp):
-				mylist.append(x)
+				# =* glob matches only on boundaries between version parts,
+				# so 1* does not match 10 (bug 560466).
+				next_char = xcpv[len(mycpv_cmp):len(mycpv_cmp)+1]
+				if (not next_char or next_char in '._-' or
+					mycpv_cmp[-1].isdigit() != next_char.isdigit()):
+					mylist.append(x)
 
 	elif operator == "~": # version, any revision, match
 		for x in candidate_list:

diff --git a/pym/portage/tests/dep/test_match_from_list.py b/pym/portage/tests/dep/test_match_from_list.py
index 75ac8fd..3080479 100644
--- a/pym/portage/tests/dep/test_match_from_list.py
+++ b/pym/portage/tests/dep/test_match_from_list.py
@@ -73,12 +73,21 @@ class Test_match_from_list(TestCase):
 			("sys-apps/portage:0", [Package("=sys-apps/portage-045:0")], ["sys-apps/portage-045"]),
 			("sys-apps/portage:0", [Package("=sys-apps/portage-045:1")], []),
 			("=cat/pkg-1-r1*", ["cat/pkg-1_alpha1"], []),
-			("=cat/pkg-1-r1*", ["cat/pkg-1-r11"], ["cat/pkg-1-r11"]),
-			("=cat/pkg-1-r1*", ["cat/pkg-01-r11"], ["cat/pkg-01-r11"]),
-			("=cat/pkg-01-r1*", ["cat/pkg-1-r11"], ["cat/pkg-1-r11"]),
-			("=cat/pkg-01-r1*", ["cat/pkg-001-r11"], ["cat/pkg-001-r11"]),
-			("=sys-fs/udev-1*", ["sys-fs/udev-123"], ["sys-fs/udev-123"]),
-			("=sys-fs/udev-4*", ["sys-fs/udev-456"], ["sys-fs/udev-456"]),
+			# =* glob matches only on boundaries between version parts,
+			# so 1* does not match 10 (bug 560466).
+			("=cat/pkg-1.1*", ["cat/pkg-1.1-r1", "cat/pkg-1.10-r1"], ["cat/pkg-1.1-r1"]),
+			("=cat/pkg-1-r1*", ["cat/pkg-1-r11"], []),
+			("=cat/pkg-1_pre*", ["cat/pkg-1_pre1"], ["cat/pkg-1_pre1"]),
+			("=cat/pkg-1-r1*", ["cat/pkg-1-r1"], ["cat/pkg-1-r1"]),
+			("=cat/pkg-1-r11*", ["cat/pkg-1-r11"], ["cat/pkg-1-r11"]),
+			("=cat/pkg-1-r11*", ["cat/pkg-01-r11"], ["cat/pkg-01-r11"]),
+			("=cat/pkg-01-r11*", ["cat/pkg-1-r11"], ["cat/pkg-1-r11"]),
+			("=cat/pkg-01-r11*", ["cat/pkg-001-r11"], ["cat/pkg-001-r11"]),
+			("=sys-fs/udev-1*", ["sys-fs/udev-123", "sys-fs/udev-123-r1"], []),
+			("=sys-fs/udev-123*", ["sys-fs/udev-123"], ["sys-fs/udev-123"]),
+			("=sys-fs/udev-123*", ["sys-fs/udev-123-r1"], ["sys-fs/udev-123-r1"]),
+			("=sys-fs/udev-4*", ["sys-fs/udev-456", "sys-fs/udev-456-r1"], []),
+			("=sys-fs/udev-456*", ["sys-fs/udev-456"], ["sys-fs/udev-456"]),
 			("*/*", ["sys-fs/udev-456"], ["sys-fs/udev-456"]),
 			("*/*:0", ["sys-fs/udev-456:0"], ["sys-fs/udev-456:0"]),
 			("*/*:1", ["sys-fs/udev-456:0"], []),


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-09-21 20:15 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-04 21:07 [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/portage/tests/dep/ zmedico
  -- strict thread matches above, loose matches on Subject: below --
2015-09-21 20:15 Zac Medico
2013-06-09  0:23 Zac Medico
2013-05-24 18:02 Zac Medico
2013-01-04  4:35 Zac Medico
2012-09-18 20:17 Zac Medico
2012-07-18 21:07 Zac Medico
2012-05-13 20:11 Zac Medico
2011-10-04  4:45 Zac Medico
2011-06-09 18:48 Zac Medico
2011-06-09 14:24 Zac Medico
2011-02-07 22:00 Zac Medico
2011-02-05  0:16 Zac Medico
2011-02-04 22:32 Zac Medico
2011-02-04  5:42 zmedico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox