commit:     1b33e0ae109e11b1ee696ea6c6919bb86ecbc66f
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 27 23:32:57 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Wed Jan 27 23:32:57 2016 +0000
URL:        https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=1b33e0ae

ekeyword: fix "all" keyword handling w/-keywords

When an ebuild has a keyword like '-sparc', we don't want the magic
"all" or "~all" keywords to change it to 'sparc' or '~sparc'.

 src/ekeyword/ekeyword.py          | 8 ++++++++
 src/ekeyword/ekeyword_unittest.py | 8 ++++++++
 2 files changed, 16 insertions(+)

diff --git a/src/ekeyword/ekeyword.py b/src/ekeyword/ekeyword.py
index 64f4eb0..e4a8197 100755
--- a/src/ekeyword/ekeyword.py
+++ b/src/ekeyword/ekeyword.py
@@ -180,9 +180,17 @@ def process_keywords(keywords, ops, arch_status=None):
                                # master list.  If it lacks some keywords, then 
we might miss
                                # somethings here, but not much we can do.
                                arches = old_arches
+
                        # We ignore the glob arch as we never want to tweak it.
                        if '*' in arches:
                                arches.remove('*')
+
+                       # For keywords that are explicitly disabled, do not 
update.  When
+                       # people use `ekeyword ~all ...` or `ekeyword all ...`, 
they rarely
+                       # (if ever) want to change a '-sparc' to 'sparc' or 
'-sparc' to
+                       # '~sparc'.  We force people to explicitly do `ekeyword 
sparc ...`
+                       # in these cases.
+                       arches = [x for x in arches if '-' + x not in 
new_keywords]
                else:
                        arches = (oarch,)
 

diff --git a/src/ekeyword/ekeyword_unittest.py 
b/src/ekeyword/ekeyword_unittest.py
index 134dd80..473113b 100755
--- a/src/ekeyword/ekeyword_unittest.py
+++ b/src/ekeyword/ekeyword_unittest.py
@@ -196,6 +196,14 @@ class TestProcessKeywords(unittest.TestCase):
                self._test('-* ~* * alpha arm arm64 m68k', ops,
                           '-* ~* * ~alpha arm ~arm64 ~m68k', arch_status)
 
+       def testAllDisabled(self):
+               """Make sure ~all does not change -arch to ~arch"""
+               ops = (
+                       ekeyword.Op('~', 'all', None),
+               )
+               self._test('alpha -sparc ~x86', ops,
+                          '~alpha -sparc ~x86', {})
+
 
 class TestProcessContent(unittest.TestCase):
        """Tests for process_content"""

Reply via email to