gcc-changelog/git_email.py: Support older unidiff modules
authorTobias Burnus <tobias@codesourcery.com>
Tue, 3 Nov 2020 16:46:36 +0000 (17:46 +0100)
committerTobias Burnus <tobias@codesourcery.com>
Tue, 3 Nov 2020 16:46:36 +0000 (17:46 +0100)
contrib/ChangeLog:

* gcc-changelog/git_email.py: Add unidiff_supports_renaming check.

contrib/gcc-changelog/git_email.py

index 014fdd1004b4b04ba67fb87a72a9feb59debcc31..5b53ca4a6a9c89923b37e0a167ad3139a580da37 100755 (executable)
@@ -24,10 +24,11 @@ from dateutil.parser import parse
 
 from git_commit import GitCommit, GitInfo
 
-from unidiff import PatchSet
+from unidiff import PatchSet, PatchedFile
 
 DATE_PREFIX = 'Date: '
 FROM_PREFIX = 'From: '
+unidiff_supports_renaming = hasattr(PatchedFile(), 'is_rename')
 
 
 class GitEmail(GitCommit):
@@ -58,7 +59,7 @@ class GitEmail(GitCommit):
                 t = 'A'
             elif f.is_removed_file:
                 t = 'D'
-            elif f.is_rename:
+            elif unidiff_supports_renaming 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((source, 'D'))