From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id BC1A01396D0 for ; Mon, 11 Sep 2017 20:20:29 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 06BB51FC03E; Mon, 11 Sep 2017 20:20:29 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id CCDD81FC03E for ; Mon, 11 Sep 2017 20:20:28 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 042803417DD for ; Mon, 11 Sep 2017 20:20:28 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 9D08A8E5B for ; Mon, 11 Sep 2017 20:20:26 +0000 (UTC) From: "Sebastian Pipping" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sebastian Pipping" Message-ID: <1504962267.0bbf21d7c25743e030879ab65af5e432aba2eaa3.sping@gentoo> Subject: [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/ekeyword/ X-VCS-Repository: proj/gentoolkit X-VCS-Files: pym/gentoolkit/ekeyword/ekeyword.py X-VCS-Directories: pym/gentoolkit/ekeyword/ X-VCS-Committer: sping X-VCS-Committer-Name: Sebastian Pipping X-VCS-Revision: 0bbf21d7c25743e030879ab65af5e432aba2eaa3 X-VCS-Branch: master Date: Mon, 11 Sep 2017 20:20:26 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 9aa16c93-467a-4f0b-bd61-55deaaa3cda5 X-Archives-Hash: 52cd087d3f587dd81738210b6522fe7c commit: 0bbf21d7c25743e030879ab65af5e432aba2eaa3 Author: Sebastian Pipping pipping org> AuthorDate: Sat Sep 9 13:04:27 2017 +0000 Commit: Sebastian Pipping gentoo org> CommitDate: Sat Sep 9 13:04:27 2017 +0000 URL: https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=0bbf21d7 ekeyword: Support sorting keywords without additional changes pym/gentoolkit/ekeyword/ekeyword.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/pym/gentoolkit/ekeyword/ekeyword.py b/pym/gentoolkit/ekeyword/ekeyword.py index 170c25b..af37a9a 100755 --- a/pym/gentoolkit/ekeyword/ekeyword.py +++ b/pym/gentoolkit/ekeyword/ekeyword.py @@ -261,15 +261,29 @@ def process_content(ebuild, data, ops, arch_status=None, verbose=0, continue # Ok, we've got it, now let's process things. - old_keywords = set(m.group(3).split()) + old_keywords_original = m.group(3).split() # preserve original order + old_keywords = set(old_keywords_original) new_keywords = process_keywords( old_keywords, ops, arch_status=arch_status) + were_sorted_already = ( + old_keywords_original == sort_keywords(old_keywords_original)) + # Finally let's present the results to the user. - if (new_keywords != old_keywords) or verbose: + if (new_keywords != old_keywords) or \ + (not ops and not were_sorted_already) or verbose: # Only do the diff work if something actually changed. updated = True - old_keywords = sort_keywords(old_keywords) + + if not ops: + # We're sorting only so we want to compare with the + # unsorted original (or changes in order will not show) + old_keywords = old_keywords_original + else: + # We changed keywords so let's diff sorted versions + # so that keywords changes are easy to spot + old_keywords = sort_keywords(old_keywords) + new_keywords = sort_keywords(new_keywords) line = '%s"%s"%s\n' % (m.group(1), ' '.join(new_keywords), m.group(5)) @@ -435,14 +449,12 @@ def args_to_work(args, arch_status=None, _repo='gentoo', quiet=0): """Process |args| into a list of work itmes (ebuild/arches to update)""" work = [] todo_arches = [] - last_todo_arches = None + last_todo_arches = [] for arg in args: if arg.endswith('.ebuild'): if not todo_arches: todo_arches = last_todo_arches - if not todo_arches: - raise ValueError('missing arches to process for %s' % arg) work.append([arg, todo_arches]) last_todo_arches = todo_arches todo_arches = [] @@ -510,7 +522,7 @@ def main(argv): parser = get_parser() opts = parser.parse_args(parse_args) if not work_args: - parser.error('need arches/ebuilds to process') + parser.error('need ebuilds to process') if opts.style == 'auto': if not portage_settings().get('NOCOLOR', 'false').lower() in ('no', 'false'):