public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Martin Liška" <mliska@suse.cz>
To: gcc-patches@gcc.gnu.org
Cc: Tobias Burnus <tobias@codesourcery.com>
Subject: [PATCH (pushed)] gcc-changelog: do not use PatchSet.from_filename
Date: Fri, 16 Dec 2022 12:23:32 +0100	[thread overview]
Message-ID: <8535eafd-58cc-5454-a92c-6aaf242b686b@suse.cz> (raw)
In-Reply-To: <39aa0988-2d5c-183d-4c5a-4cfd3b061836@suse.cz>

Use rather PatchSet constructor where we can pass
properly opened file with newline='\n'.

contrib/ChangeLog:

	* gcc-changelog/git_email.py: Use PatchSet constructor
	as newline argument is not supported with older unidiff
	library.
---
 contrib/gcc-changelog/git_email.py | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/contrib/gcc-changelog/git_email.py b/contrib/gcc-changelog/git_email.py
index 093c887ba4c..f3773f178ea 100755
--- a/contrib/gcc-changelog/git_email.py
+++ b/contrib/gcc-changelog/git_email.py
@@ -39,18 +39,15 @@ unidiff_supports_renaming = hasattr(PatchedFile(), 'is_rename')
 class GitEmail(GitCommit):
     def __init__(self, filename):
         self.filename = filename
-        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 = ''
 
         subject_last = False
-        with open(self.filename, 'r') as f:
-            lines = f.read().splitlines()
+        with open(self.filename, newline='\n') as f:
+            data = f.read()
+            diff = PatchSet(data)
+            lines = data.splitlines()
         lines = list(takewhile(lambda line: line != '---', lines))
         for line in lines:
             if line.startswith(DATE_PREFIX):
-- 
2.39.0


      reply	other threads:[~2022-12-16 11:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-16  9:18 [Patch] gcc-changelog/git_email.py: Support older unidiff.PatchSet Tobias Burnus
2022-12-16  9:27 ` Martin Liška
2022-12-16 11:23   ` Martin Liška [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8535eafd-58cc-5454-a92c-6aaf242b686b@suse.cz \
    --to=mliska@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=tobias@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).