public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch] gcc-changelog/git_email.py: Support older unidiff.PatchSet
@ 2022-12-16  9:18 Tobias Burnus
  2022-12-16  9:27 ` Martin Liška
  0 siblings, 1 reply; 3+ messages in thread
From: Tobias Burnus @ 2022-12-16  9:18 UTC (permalink / raw)
  To: gcc-patches, Martin Liška

[-- Attachment #1: Type: text/plain, Size: 399 bytes --]

Another backward compatibility issue - failed here on Ubuntu 20.04 which
is old but not ancient.

OK for mainline?

Tobias
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

[-- Attachment #2: git-email.diff --]
[-- Type: text/x-patch, Size: 1281 bytes --]

gcc-changelog/git_email.py: Support older unidiff.PatchSet

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.

diff --git a/contrib/gcc-changelog/git_email.py b/contrib/gcc-changelog/git_email.py
index ef50ebfb7fd..093c887ba4c 100755
--- a/contrib/gcc-changelog/git_email.py
+++ b/contrib/gcc-changelog/git_email.py
@@ -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 = ''

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch] gcc-changelog/git_email.py: Support older unidiff.PatchSet
  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   ` [PATCH (pushed)] gcc-changelog: do not use PatchSet.from_filename Martin Liška
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Liška @ 2022-12-16  9:27 UTC (permalink / raw)
  To: Tobias Burnus, gcc-patches

On 12/16/22 10:18, Tobias Burnus wrote:
> Another backward compatibility issue - failed here on Ubuntu 20.04 which
> is old but not ancient.
> 
> OK for mainline?

It's fine, thanks for the workaround!

Martin

> 
> Tobias
> -----------------
> Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH (pushed)] gcc-changelog: do not use PatchSet.from_filename
  2022-12-16  9:27 ` Martin Liška
@ 2022-12-16 11:23   ` Martin Liška
  0 siblings, 0 replies; 3+ messages in thread
From: Martin Liška @ 2022-12-16 11:23 UTC (permalink / raw)
  To: gcc-patches; +Cc: Tobias Burnus

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-16 11:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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   ` [PATCH (pushed)] gcc-changelog: do not use PatchSet.from_filename Martin Liška

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