summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorPierre-Marie de Rodat <derodat@adacore.com>2020-05-27 15:25:18 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2020-05-28 11:14:44 +0200
commita634157de1e83536123412b02aae184a9d590751 (patch)
tree83dacc81f1e29dd65201200026944480c3917813 /contrib
parent48e872db11b27604f4993f9be8f67f40b1a40468 (diff)
gcc-changelog: enhance handling of renamings
So far, we expect from a commit that renames a file to contain a changelog entry only for the new name. For example, after the following commit: $ git move foo bar $ git commit We expect the following changelog: * bar: Renamed from foo. Git does not keep track of renamings, only file deletions and additions. The display of patches then uses heuristics (with config-dependent parameters) to try to match deleted and added files in the same commit. It is thus brittle to rely on this information. This commit modifies changelog processing so that renames are considered as a deletion of a file plus an addition of another file. The following changelog is now expected for the above example: * foo: Move... * bar: Here. contrib/ * gcc-changelog/git_email.py (GitEmail.__init__): Interpret file renamings as a file deletion plus a file addition. * gcc-changelog/git_repository.py (parse_git_revisions): Likewise. * gcc-changelog/test_email.py: New testcase. * gcc-changelog/test_patches.txt: New testcase.
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/gcc-changelog/git_email.py11
-rwxr-xr-xcontrib/gcc-changelog/git_repository.py5
-rwxr-xr-xcontrib/gcc-changelog/test_email.py10
-rw-r--r--contrib/gcc-changelog/test_patches.txt153
4 files changed, 178 insertions, 1 deletions
diff --git a/contrib/gcc-changelog/git_email.py b/contrib/gcc-changelog/git_email.py
index 8c9df293a66..367cf76d8ee 100755
--- a/contrib/gcc-changelog/git_email.py
+++ b/contrib/gcc-changelog/git_email.py
@@ -50,13 +50,22 @@ class GitEmail(GitCommit):
modified_files = []
for f in diff:
+ # Strip "a/" and "b/" prefixes
+ source = f.source_file[2:]
+ target = f.target_file[2:]
+
if f.is_added_file:
t = 'A'
elif f.is_removed_file:
t = 'D'
+ elif f.is_rename:
+ # Consider that renamed files are two operations: the deletion
+ # of the original name and the addition of the new one.
+ modified_files.append((source, 'D'))
+ t = 'A'
else:
t = 'M'
- modified_files.append((f.path, t))
+ modified_files.append((target, t))
super().__init__(None, date, author, body, modified_files,
strict=strict)
diff --git a/contrib/gcc-changelog/git_repository.py b/contrib/gcc-changelog/git_repository.py
index 0473fe73fba..e3b6c4d7a38 100755
--- a/contrib/gcc-changelog/git_repository.py
+++ b/contrib/gcc-changelog/git_repository.py
@@ -47,6 +47,11 @@ def parse_git_revisions(repo_path, revisions, strict=False):
t = 'A'
elif file.deleted_file:
t = 'D'
+ elif file.renamed_file:
+ # Consider that renamed files are two operations: the deletion
+ # of the original name and the addition of the new one.
+ modified_files.append((file.a_path, 'D'))
+ t = 'A'
else:
t = 'M'
modified_files.append((file.b_path, t))
diff --git a/contrib/gcc-changelog/test_email.py b/contrib/gcc-changelog/test_email.py
index 3d2c8ff2412..23372f082a0 100755
--- a/contrib/gcc-changelog/test_email.py
+++ b/contrib/gcc-changelog/test_email.py
@@ -18,6 +18,7 @@
import os
import tempfile
+import unidiff
import unittest
from git_email import GitEmail
@@ -25,6 +26,8 @@ from git_email import GitEmail
script_path = os.path.dirname(os.path.realpath(__file__))
+unidiff_supports_renaming = hasattr(unidiff.PatchedFile(), 'is_rename')
+
class TestGccChangelog(unittest.TestCase):
def setUp(self):
@@ -295,3 +298,10 @@ class TestGccChangelog(unittest.TestCase):
'sem_ch12.adb', 'sem_ch4.adb', 'sem_ch7.adb',
'sem_ch8.adb', 'sem_elab.adb', 'sem_type.adb',
'sem_util.adb'])
+
+ @unittest.skipIf(not unidiff_supports_renaming,
+ 'Newer version of unidiff is needed (0.6.0+)')
+ def test_renamed_file(self):
+ email = self.from_patch_glob(
+ '0001-Ada-Add-support-for-XDR-streaming-in-the-default-run.patch')
+ assert not email.errors
diff --git a/contrib/gcc-changelog/test_patches.txt b/contrib/gcc-changelog/test_patches.txt
index 06869bff504..cc81fcd32b8 100644
--- a/contrib/gcc-changelog/test_patches.txt
+++ b/contrib/gcc-changelog/test_patches.txt
@@ -2741,3 +2741,156 @@ index b980b4c..c1b1d9e 100644
--
2.1.4
+=== 0001-Ada-Add-support-for-XDR-streaming-in-the-default-run.patch ===
+From ed248d9bc3b72b6888a1b9cd84a8ef26809249f0 Mon Sep 17 00:00:00 2001
+From: Arnaud Charlet <charlet@adacore.com>
+Date: Thu, 23 Apr 2020 05:46:29 -0400
+Subject: [PATCH] [Ada] Add support for XDR streaming in the default runtime
+
+--!# FROM: /homes/derodat/tron/gnat2fsf/gnat
+--!# COMMIT: 5ad4cabb9f70114eb61c025e91406d4fba253f95
+--!# Change-Id: I21f92cad27933747495cdfa544a048f62f944cbd
+--!# TN: T423-014
+
+Currently we provide a separate implementation of Stream_Attributes via
+s-stratt__xdr.adb which needs to be recompiled manually.
+
+This change introduces instead a new binder switch to choose at bind
+time which stream implementation to use and replaces s-stratt__xdr.adb
+by a new unit System.Stream_Attributes.XDR.
+
+2020-05-04 Arnaud Charlet <charlet@adacore.com>
+
+gcc/ada/
+
+ * Makefile.rtl: Add s-statxd.o.
+ * bindgen.adb (Gen_Adainit): Add support for XDR_Stream.
+ * bindusg.adb (Display): Add mention of -xdr.
+ * gnatbind.adb: Process -xdr switch.
+ * init.c (__gl_xdr_stream): New.
+ * opt.ads (XDR_Stream): New.
+ * libgnat/s-stratt__xdr.adb: Rename to...
+ * libgnat/s-statxd.adb: this and adjust.
+ * libgnat/s-statxd.ads: New.
+ * libgnat/s-stratt.ads, libgnat/s-stratt.adb: Choose between
+ default and XDR implementation at runtime.
+ * libgnat/s-ststop.ads: Update comments.
+ * doc/gnat_rm/implementation_advice.rst: Update doc on XDR
+ streaming.
+ * gnat_rm.texi: Regenerate.
+---
+ gcc/ada/Makefile.rtl | 1 +
+ gcc/ada/bindgen.adb | 29 +-
+ gcc/ada/bindusg.adb | 5 +
+ gcc/ada/doc/gnat_rm/implementation_advice.rst | 35 +--
+ gcc/ada/gnat_rm.texi | 36 +--
+ gcc/ada/gnatbind.adb | 5 +
+ gcc/ada/init.c | 1 +
+ .../{s-stratt__xdr.adb => s-statxd.adb} | 63 ++--
+ gcc/ada/libgnat/s-statxd.ads | 117 +++++++
+ gcc/ada/libgnat/s-stratt.adb | 286 +++++++++++++++---
+ gcc/ada/libgnat/s-stratt.ads | 7 +-
+ gcc/ada/libgnat/s-ststop.ads | 4 +-
+ gcc/ada/opt.ads | 6 +-
+ 13 files changed, 428 insertions(+), 167 deletions(-)
+ rename gcc/ada/libgnat/{s-stratt__xdr.adb => s-statxd.adb} (96%)
+ create mode 100644 gcc/ada/libgnat/s-statxd.ads
+
+diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl
+index b340a9ef919..15e4f68ccdb 100644
+--- a/gcc/ada/Makefile.rtl
++++ b/gcc/ada/Makefile.rtl
+@@ -1 +1,2 @@
+
++
+diff --git a/gcc/ada/bindgen.adb b/gcc/ada/bindgen.adb
+index 99ad3009d13..91b4cb38486 100644
+--- a/gcc/ada/bindgen.adb
++++ b/gcc/ada/bindgen.adb
+@@ -1 +1,2 @@
+
++
+diff --git a/gcc/ada/bindusg.adb b/gcc/ada/bindusg.adb
+index 45215d2ebea..6fd55ee8721 100644
+--- a/gcc/ada/bindusg.adb
++++ b/gcc/ada/bindusg.adb
+@@ -1 +1,2 @@
+
++
+diff --git a/gcc/ada/doc/gnat_rm/implementation_advice.rst b/gcc/ada/doc/gnat_rm/implementation_advice.rst
+index 31376d92461..998d0c597df 100644
+--- a/gcc/ada/doc/gnat_rm/implementation_advice.rst
++++ b/gcc/ada/doc/gnat_rm/implementation_advice.rst
+@@ -1 +1,2 @@
+
++
+diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi
+index c174073d508..d72f905a2df 100644
+--- a/gcc/ada/gnat_rm.texi
++++ b/gcc/ada/gnat_rm.texi
+@@ -1 +1,2 @@
+
++
+diff --git a/gcc/ada/gnatbind.adb b/gcc/ada/gnatbind.adb
+index 4907082a42c..4372152b439 100644
+--- a/gcc/ada/gnatbind.adb
++++ b/gcc/ada/gnatbind.adb
+@@ -1 +1,2 @@
+
++
+diff --git a/gcc/ada/init.c b/gcc/ada/init.c
+index f9f627ebcff..e76aa79c5a8 100644
+--- a/gcc/ada/init.c
++++ b/gcc/ada/init.c
+@@ -1 +1,2 @@
+
++
+diff --git a/gcc/ada/libgnat/s-stratt__xdr.adb b/gcc/ada/libgnat/s-statxd.adb
+similarity index 96%
+rename from gcc/ada/libgnat/s-stratt__xdr.adb
+rename to gcc/ada/libgnat/s-statxd.adb
+index 7e32fcf9b91..fcefae7e6f2 100644
+--- a/gcc/ada/libgnat/s-stratt__xdr.adb
++++ b/gcc/ada/libgnat/s-statxd.adb
+@@ -1 +1,2 @@
+
++
+diff --git a/gcc/ada/libgnat/s-statxd.ads b/gcc/ada/libgnat/s-statxd.ads
+new file mode 100644
+index 00000000000..cca5e5471bd
+--- /dev/null
++++ b/gcc/ada/libgnat/s-statxd.ads
+@@ -1 +1,2 @@
+
++
+diff --git a/gcc/ada/libgnat/s-stratt.adb b/gcc/ada/libgnat/s-stratt.adb
+index 64f3f040081..366dabdc7b6 100644
+--- a/gcc/ada/libgnat/s-stratt.adb
++++ b/gcc/ada/libgnat/s-stratt.adb
+@@ -1 +1,2 @@
+
++
+diff --git a/gcc/ada/libgnat/s-stratt.ads b/gcc/ada/libgnat/s-stratt.ads
+index 73369490146..c8c453aad2a 100644
+--- a/gcc/ada/libgnat/s-stratt.ads
++++ b/gcc/ada/libgnat/s-stratt.ads
+@@ -1 +1,2 @@
+
++
+diff --git a/gcc/ada/libgnat/s-ststop.ads b/gcc/ada/libgnat/s-ststop.ads
+index d0da0609d9d..321460b89d8 100644
+--- a/gcc/ada/libgnat/s-ststop.ads
++++ b/gcc/ada/libgnat/s-ststop.ads
+@@ -1 +1,2 @@
+
++
+diff --git a/gcc/ada/opt.ads b/gcc/ada/opt.ads
+index 9e0263b431d..37f3d030e3f 100644
+--- a/gcc/ada/opt.ads
++++ b/gcc/ada/opt.ads
+@@ -1 +1,2 @@
+
++
+--
+2.20.1
+