gcc-changelog: enhance handling of renamings

Message ID 20200527142911.9527-1-derodat@adacore.com
State New
Headers show
Series
  • gcc-changelog: enhance handling of renamings
Related show

Commit Message

Pierre-Marie de Rodat May 27, 2020, 2:29 p.m.
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.
---
 contrib/gcc-changelog/git_email.py      |   5 +
 contrib/gcc-changelog/git_repository.py |   5 +
 contrib/gcc-changelog/test_email.py     |   5 +
 contrib/gcc-changelog/test_patches.txt  | 153 ++++++++++++++++++++++++
 4 files changed, 168 insertions(+)

-- 
2.20.1

Comments

Martin Liška May 27, 2020, 5:50 p.m. | #1
On 5/27/20 4:29 PM, Pierre-Marie de Rodat wrote:
> 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:


Hello.

Thank you very much for working on this! It's a good idea that's currently
not supported.

> 

>     * 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.

> ---

>   contrib/gcc-changelog/git_email.py      |   5 +

>   contrib/gcc-changelog/git_repository.py |   5 +

>   contrib/gcc-changelog/test_email.py     |   5 +

>   contrib/gcc-changelog/test_patches.txt  | 153 ++++++++++++++++++++++++

>   4 files changed, 168 insertions(+)

> 

> diff --git a/contrib/gcc-changelog/git_email.py b/contrib/gcc-changelog/git_email.py

> index 8c9df293a66..6e42629cf07 100755

> --- a/contrib/gcc-changelog/git_email.py

> +++ b/contrib/gcc-changelog/git_email.py

> @@ -54,6 +54,11 @@ class GitEmail(GitCommit):

>                   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((f.target_file[2:], 'A'))

> +                t = 'D'


However, this is available for unidiff package starting from version 0.6.0. With a bit older
release I see:

                 t = 'D'
>           elif f.is_rename:

E           AttributeError: 'PatchedFile' object has no attribute 'is_rename'

Which is a minor limitation is git_email.py is supposed to be used only for tests.

>               else:

>                   t = 'M'

>               modified_files.append((f.path, t))

> 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'


Can you please align both previous hunks, I mean doing in both:

modified_files.append(..., 'A')
t = 'D'

>               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..c188fe9b276 100755

> --- a/contrib/gcc-changelog/test_email.py

> +++ b/contrib/gcc-changelog/test_email.py

> @@ -295,3 +295,8 @@ 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'])


We'll need here a skip based on version of unidiff. So something like:
@pytest.mark.skipif
?

I'm going to prepare a counter-part for mklog that can also handle file renaming.

Martin

> +

> +    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

> +

>
Martin Liška May 27, 2020, 5:57 p.m. | #2
On 5/27/20 7:50 PM, Martin Liška wrote:
> We'll need here a skip based on version of unidiff. So something like:

> @pytest.mark.skipif

> ?


I believe something like:

diff --git a/contrib/gcc-changelog/git_email.py b/contrib/gcc-changelog/git_email.py
index 6e42629cf07..afa6771c7fe 100755
--- a/contrib/gcc-changelog/git_email.py
+++ b/contrib/gcc-changelog/git_email.py
@@ -54,7 +54,7 @@ class GitEmail(GitCommit):
                  t = 'A'
              elif f.is_removed_file:
                  t = 'D'
-            elif f.is_rename:
+            elif hasattr(f, 'is_rename') and 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((f.target_file[2:], 'A'))
diff --git a/contrib/gcc-changelog/test_email.py b/contrib/gcc-changelog/test_email.py
index c188fe9b276..f174f08d15b 100755
--- a/contrib/gcc-changelog/test_email.py
+++ b/contrib/gcc-changelog/test_email.py
@@ -22,10 +22,15 @@ import unittest
  
  from git_email import GitEmail
  
+import unidiff
+
  
  script_path = os.path.dirname(os.path.realpath(__file__))
  
  
+unidiff_supports_renaming = hasattr(unidiff.PatchedFile, 'is_rename')
+
+
  class TestGccChangelog(unittest.TestCase):
      def setUp(self):
          self.patches = {}
@@ -296,6 +301,8 @@ class TestGccChangelog(unittest.TestCase):
                      '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')
Pierre-Marie de Rodat May 28, 2020, 9:05 a.m. | #3
On 27/05/2020 19:50, Martin Liška wrote:
> Thank you very much for working on this! It's a good idea that's currently

> not supported.


You are welcome, I’m glad to contribute. :-)

> However, this is available for unidiff package starting from version 

> 0.6.0. With a bit older

> release I see:

> 

>                  t = 'D'

>>           elif f.is_rename:

> E           AttributeError: 'PatchedFile' object has no attribute 

> 'is_rename'

> 

> Which is a minor limitation is git_email.py is supposed to be used only 

> for tests.


Agreed.

> Can you please align both previous hunks, I mean doing in both:

> 

> modified_files.append(..., 'A')

> t = 'D'


I initially thought it was not possible (f.path in git_email.py 
corresponds to the source file, whereas file.b_path in git_repository.py 
corresponds to the target file), but a simple refactoring did it.

> We'll need here a skip based on version of unidiff. So something like:

> @pytest.mark.skipif

> ?

> 

> I'm going to prepare a counter-part for mklog that can also handle file 

> renaming.


Thanks! The updated patch is attached.

-- 
Pierre-Marie de Rodat
From 42b48c97cb30bcc1b05679ced3cb946551bfcae0 Mon Sep 17 00:00:00 2001
From: Pierre-Marie de Rodat <derodat@adacore.com>

Date: Wed, 27 May 2020 15:25:18 +0200
Subject: [PATCH] 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.
---
 contrib/gcc-changelog/git_email.py      |  11 +-
 contrib/gcc-changelog/git_repository.py |   5 +
 contrib/gcc-changelog/test_email.py     |  10 ++
 contrib/gcc-changelog/test_patches.txt  | 153 ++++++++++++++++++++++++
 4 files changed, 178 insertions(+), 1 deletion(-)

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
+
-- 
2.20.1
Martin Liška May 28, 2020, 9:09 a.m. | #4
On 5/28/20 11:05 AM, Pierre-Marie de Rodat wrote:
> Thanks! The updated patch is attached.


The patch is fine, please install it.

Thanks,
Martin
Pierre-Marie de Rodat May 28, 2020, 9:15 a.m. | #5
On 28/05/2020 11:09, Martin Liška wrote:
> On 5/28/20 11:05 AM, Pierre-Marie de Rodat wrote:

>> Thanks! The updated patch is attached.

> 

> The patch is fine, please install it.


Now pushed. Thank you again.

-- 
Pierre-Marie de Rodat
Kewen.Lin via Gcc-patches May 28, 2020, 11:20 a.m. | #6
On Thu, May 28, 2020 at 11:09:41AM +0200, Martin Liška wrote:
> On 5/28/20 11:05 AM, Pierre-Marie de Rodat wrote:

> > Thanks! The updated patch is attached.

> 

> The patch is fine, please install it.


I'd like to mention that for file renames, perhaps it is acceptable not to
have a ChangeLog entry for pure file rename (do we require it after
Pierre-Marie's patch), but if it is rename + some changes, the committer
should still describe the changes in there, which is something the script
can't do for him.

	Jakub
Martin Liška May 28, 2020, 11:54 a.m. | #7
On 5/28/20 1:20 PM, Jakub Jelinek wrote:
> On Thu, May 28, 2020 at 11:09:41AM +0200, Martin Liška wrote:

>> On 5/28/20 11:05 AM, Pierre-Marie de Rodat wrote:

>>> Thanks! The updated patch is attached.

>>

>> The patch is fine, please install it.

> 

> I'd like to mention that for file renames, perhaps it is acceptable not to

> have a ChangeLog entry for pure file rename (do we require it after

> Pierre-Marie's patch), but if it is rename + some changes, the committer

> should still describe the changes in there, which is something the script

> can't do for him.


That will likely depend on the similarity level (100%). But I'm not sure GitPython
can provide such an information. It seems to me a nit, file renaming is quite rare
operation.

Martin

> 

> 	Jakub

>

Patch

diff --git a/contrib/gcc-changelog/git_email.py b/contrib/gcc-changelog/git_email.py
index 8c9df293a66..6e42629cf07 100755
--- a/contrib/gcc-changelog/git_email.py
+++ b/contrib/gcc-changelog/git_email.py
@@ -54,6 +54,11 @@  class GitEmail(GitCommit):
                 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((f.target_file[2:], 'A'))
+                t = 'D'
             else:
                 t = 'M'
             modified_files.append((f.path, t))
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..c188fe9b276 100755
--- a/contrib/gcc-changelog/test_email.py
+++ b/contrib/gcc-changelog/test_email.py
@@ -295,3 +295,8 @@  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'])
+
+    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
+