From patchwork Mon Jul 25 10:15:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 72706 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1064432qga; Mon, 25 Jul 2016 03:15:07 -0700 (PDT) X-Received: by 10.28.152.5 with SMTP id a5mr19611588wme.76.1469441707584; Mon, 25 Jul 2016 03:15:07 -0700 (PDT) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id v83si23333479wmv.78.2016.07.25.03.15.07; Mon, 25 Jul 2016 03:15:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) client-ip=85.214.87.163; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 041FAA7783; Mon, 25 Jul 2016 12:14:53 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id m-wLUQNYvSHY; Mon, 25 Jul 2016 12:14:52 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B8A86A77B0; Mon, 25 Jul 2016 12:14:44 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5A10CA778E for ; Mon, 25 Jul 2016 12:14:23 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PlmtfrIaKr0f for ; Mon, 25 Jul 2016 12:14:23 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from conuserg-11.nifty.com (conuserg-11.nifty.com [210.131.2.78]) by theia.denx.de (Postfix) with ESMTPS id 60F8CA7790 for ; Mon, 25 Jul 2016 12:14:17 +0200 (CEST) Received: from beagle.diag.org (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-11.nifty.com with ESMTP id u6PADhxG021296; Mon, 25 Jul 2016 19:13:46 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com u6PADhxG021296 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1469441626; bh=WxdxyVEPCEM9vz7Fg6RTJGs6hTJJrnz1hNQiBD23jTI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0ydmUpyfBXv0YCCAvK3RtcMfMWrFmMuTU3r9kRBVpLNUpWwpGNQa9fQ+OKVKTpOs6 U2RMcmhCxeYZdnvbyu330Y9OoIE3idZ2T7r5Ik1FV7LmWN+uVORehfq8duq8STDvvv +JxxzBZscF+Q6Nf7wd0OV8W4PBQD9myjSPrVBZ5wcBhlozao2Rlig7lDY3l06LDV9/ Zt6TsCH6zgrlajdWUKnRARydnHMZVIOtMbFpbtjZzR4P02VfhpGZ3ttAw8k08qks6I iQRNTirvz9AdkqGELmD6OKA3oyKQ7XVXdThI20+rQHLc53TbdDjOVPYvzNG44J6h9W yihaKjym2kf5A== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Mon, 25 Jul 2016 19:15:25 +0900 Message-Id: <1469441729-5817-5-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1469441729-5817-1-git-send-email-yamada.masahiro@socionext.com> References: <1469441729-5817-1-git-send-email-yamada.masahiro@socionext.com> Cc: Tom Rini , Joe Hershberger Subject: [U-Boot] [PATCH v2 4/8] tools: moveconfig: show result of header cleaning in unified diff X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The header cleanup feature of this tool now removes empty ifdef's, successive blank lines as well as moved option defines. So, we want to see a little more context to check which lines were deleted. It is true that we can see it by "git diff", but it would not work in the --dry-run mode. So, here, this commit. Signed-off-by: Masahiro Yamada --- Changes in v2: - Make diffing into a helper function tools/moveconfig.py | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) -- 1.9.1 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot diff --git a/tools/moveconfig.py b/tools/moveconfig.py index 03e4953..4f07782 100755 --- a/tools/moveconfig.py +++ b/tools/moveconfig.py @@ -161,6 +161,7 @@ To see the complete list of supported options, run """ import copy +import difflib import filecmp import fnmatch import multiprocessing @@ -275,6 +276,22 @@ def color_text(color_enabled, color, string): else: return string +def show_diff(a, b, file_path): + """Show unidified diff. + + Arguments: + a: A list of lines (before) + b: A list of lines (after) + file_path: Path to the file + """ + + diff = difflib.unified_diff(a, b, + fromfile=os.path.join('a', file_path), + tofile=os.path.join('b', file_path)) + + for line in diff: + print line, + def update_cross_compile(color_enabled): """Update per-arch CROSS_COMPILE via environment variables @@ -414,16 +431,19 @@ def cleanup_one_header(header_path, patterns, dry_run): if matched == old_matched: break - for i in matched: - print '%s: %s: %s' % (header_path, i + 1, lines[i]), + tolines = copy.copy(lines) + + for i in reversed(matched): + tolines.pop(i) + + show_diff(lines, tolines, header_path) if dry_run: return with open(header_path, 'w') as f: - for i, line in enumerate(lines): - if not i in matched: - f.write(line) + for line in tolines: + f.write(line) def cleanup_headers(configs, dry_run): """Delete config defines from board headers.