public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/autopar_devel] mklog: support renaming of files
@ 2020-08-22 21:39 Giuliano Belinassi
  0 siblings, 0 replies; only message in thread
From: Giuliano Belinassi @ 2020-08-22 21:39 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:48d989fdddd32acbb32b1cda25bc112edfc427ac

commit 48d989fdddd32acbb32b1cda25bc112edfc427ac
Author: Martin Liska <mliska@suse.cz>
Date:   Wed May 27 20:03:50 2020 +0200

    mklog: support renaming of files
    
    contrib/ChangeLog:
    
            * mklog.py: Support renaming of files.
            One needs unidiff 0.6.0+.
            * test_mklog.py: Test it.

Diff:
---
 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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-22 21:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-22 21:39 [gcc/devel/autopar_devel] mklog: support renaming of files Giuliano Belinassi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).