From patchwork Wed May 27 18:15:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 1299153 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49XJsD3QWgz9sSF for ; Thu, 28 May 2020 04:15:10 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 21E86383F868; Wed, 27 May 2020 18:15:08 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id ECC553851C12 for ; Wed, 27 May 2020 18:15:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org ECC553851C12 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mliska@suse.cz X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 92340AEB1; Wed, 27 May 2020 18:15:07 +0000 (UTC) Subject: [PATCH] mklog: support renaming of files From: =?utf-8?q?Martin_Li=C5=A1ka?= To: Pierre-Marie de Rodat , gcc-patches@gcc.gnu.org References: <20200527142911.9527-1-derodat@adacore.com> Message-ID: <5ac665ab-5d18-ca05-04fc-8add9f6ced32@suse.cz> Date: Wed, 27 May 2020 20:15:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Spam-Status: No, score=-15.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi. There's a patch that utilizes newly added functionality in unidiff 0.6.0. It newly generates: $ ./contrib/mklog.py 0001-test.patch gcc/ChangeLog: * ipa-icf.c: Moved to... * ipa-icf2.c: ...here. The support is optional and detected during run-time. Thoughts? Martin From 8d970b9a57ee373cacbbd2aa29cdbe1c29df4081 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Wed, 27 May 2020 20:03:50 +0200 Subject: [PATCH] mklog: support renaming of files contrib/ChangeLog: * mklog.py: Support renaming of files. One needs unidiff 0.6.0+. * test_mklog.py: Test it. --- contrib/mklog.py | 8 ++++++++ contrib/test_mklog.py | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/contrib/mklog.py b/contrib/mklog.py index fb58661b5eb..243edbb15c5 100755 --- a/contrib/mklog.py +++ b/contrib/mklog.py @@ -173,6 +173,14 @@ def generate_changelog(data, no_functions=False, fill_pr_titles=False): out += '\t* %s: %s.\n' % (relative_path, msg) elif file.is_removed_file: out += '\t* %s: Removed.\n' % (relative_path) + elif hasattr(file, 'is_rename') and file.is_rename: + out += '\t* %s: Moved to...\n' % (relative_path) + new_path = file.target_file[2:] + # A file can be theoretically moved to a location that + # belongs to a different ChangeLog. Let user fix it. + if new_path.startswith(changelog): + new_path = new_path[len(changelog):].lstrip('/') + out += '\t* %s: ...here.\n' % (new_path) else: if not no_functions: for hunk in file: diff --git a/contrib/test_mklog.py b/contrib/test_mklog.py index ef7f2b1a594..344b7a2c771 100755 --- a/contrib/test_mklog.py +++ b/contrib/test_mklog.py @@ -30,6 +30,11 @@ import unittest from mklog import generate_changelog +import unidiff + +unidiff_supports_renaming = hasattr(unidiff.PatchedFile(), 'is_rename') + + PATCH1 = '''\ diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h index 567c23380fe..e6209ede9d6 100644 @@ -379,6 +384,21 @@ gcc/testsuite/ChangeLog: ''' +PATCH8 = '''\ +diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf2.c +similarity index 100% +rename from gcc/ipa-icf.c +rename to gcc/ipa-icf2.c +''' + +EXPECTED8 = '''\ +gcc/ChangeLog: + + * ipa-icf.c: Moved to... + * ipa-icf2.c: ...here. + +''' + class TestMklog(unittest.TestCase): def test_macro_definition(self): changelog = generate_changelog(PATCH1) @@ -411,3 +431,9 @@ class TestMklog(unittest.TestCase): def test_dr_detection_in_test_case(self): changelog = generate_changelog(PATCH7) assert changelog == EXPECTED7 + + @unittest.skipIf(not unidiff_supports_renaming, + 'Newer version of unidiff is needed (0.6.0+)') + def test_renaming(self): + changelog = generate_changelog(PATCH8) + assert changelog == EXPECTED8 -- 2.26.2