]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gcc-changelog/git_email.py: Support older unidiff.PatchSet
authorTobias Burnus <tobias@codesourcery.com>
Fri, 16 Dec 2022 10:01:22 +0000 (11:01 +0100)
committerTobias Burnus <tobias@codesourcery.com>
Fri, 16 Dec 2022 10:02:24 +0000 (11:02 +0100)
Commit "unidiff: use newline='\n' argument",
r13-4603-gb045179973161115c7ea029b2788f5156fc55cda, added support CR
on a line, but that broke support for older unidiff.PatchSet.

This patch uses a fallback for git_email.py (drop argument) if not
available (TypeError exception) but keeps using it in test_email.py
unconditionally.

contrib/ChangeLog:

* gcc-changelog/git_email.py (GitEmail:__init__): Support older
unidiff.PatchSet that do not have a newline= argument
of from_filename.

contrib/gcc-changelog/git_email.py

index ef50ebfb7fdcc89000b36836156e96b3d9ae30cc..093c887ba4cbb25c604d494dc44ce5294f644e5f 100755 (executable)
@@ -39,7 +39,11 @@ unidiff_supports_renaming = hasattr(PatchedFile(), 'is_rename')
 class GitEmail(GitCommit):
     def __init__(self, filename):
         self.filename = filename
-        diff = PatchSet.from_filename(filename, newline='\n')
+        try:
+          diff = PatchSet.from_filename(filename, newline='\n')
+        except TypeError:
+          # Older versions don't have the newline argument
+          diff = PatchSet.from_filename(filename)
         date = None
         author = None
         subject = ''