Fix use_reduce + opconvert of "A || ( B C )".
authorZac Medico <zmedico@gentoo.org>
Fri, 15 Oct 2010 09:28:54 +0000 (02:28 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 15 Oct 2010 09:28:54 +0000 (02:28 -0700)
pym/portage/dep/__init__.py
pym/portage/tests/dep/test_use_reduce.py

index d9f6a2155bd9b938b06fc8b253235d357c633f00..010d88351611577da41a148b900f1f40d0a74c8b 100644 (file)
@@ -453,7 +453,10 @@ def use_reduce(depstr, uselist=[], masklist=[], matchall=False, excludeall=[], i
                                                else:
                                                        stack[level].extend(l)
                                        else:
-                                               stack[level].append(l)
+                                               if opconvert and stack[level] and stack[level][-1] == '||':
+                                                       stack[level][-1] = ['||'] + l
+                                               else:
+                                                       stack[level].append(l)
 
                                if l and not ignore:
                                        #The current list is not empty and we don't want to ignore it because
index 162d7cdf27159ece5c39b41519a7609febb55c69..32a9e50d5ea5692a0ea29f835f1768663fa13bc0 100644 (file)
@@ -304,12 +304,10 @@ class UseReduce(TestCase):
                                "|| ( A B ) C",
                                opconvert = True,
                                expected_result = [['||', 'A', 'B'], 'C']),
-
-                       # ['A', '||', ['B', 'C']] != ['A', ['||', 'B', 'C']]
-                       #UseReduceTestCase(
-                       #       "A || ( B C )",
-                       #       opconvert = True,
-                       #       expected_result = ['A', ['||', 'B', 'C']]),
+                       UseReduceTestCase(
+                               "A || ( B C )",
+                               opconvert = True,
+                               expected_result = ['A', ['||', 'B', 'C']]),
 
                        UseReduceTestCase(
                                "|| ( A )",