public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-1842] mklog: Handle correctly long lines.
@ 2021-06-28 11:44 Martin Liska
0 siblings, 0 replies; only message in thread
From: Martin Liska @ 2021-06-28 11:44 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:b838641bb0d4de5b25128b54012155ab46f452d0
commit r12-1842-gb838641bb0d4de5b25128b54012155ab46f452d0
Author: Martin Liska <mliska@suse.cz>
Date: Mon Jun 28 13:08:10 2021 +0200
mklog: Handle correctly long lines.
contrib/ChangeLog:
* mklog.py: Handle correctly long lines.
* test_mklog.py: Test it.
Diff:
---
contrib/mklog.py | 22 ++++++++++++++++++----
contrib/test_mklog.py | 25 +++++++++++++++++++++++++
2 files changed, 43 insertions(+), 4 deletions(-)
diff --git a/contrib/mklog.py b/contrib/mklog.py
index 674c1dcd78b..ba70af0eef2 100755
--- a/contrib/mklog.py
+++ b/contrib/mklog.py
@@ -38,6 +38,9 @@ import requests
from unidiff import PatchSet
+LINE_LIMIT = 100
+TAB_WIDTH = 8
+
pr_regex = re.compile(r'(\/(\/|\*)|[Cc*!])\s+(?P<pr>PR [a-z+-]+\/[0-9]+)')
prnum_regex = re.compile(r'PR (?P<comp>[a-z+-]+)/(?P<num>[0-9]+)')
dr_regex = re.compile(r'(\/(\/|\*)|[Cc*!])\s+(?P<dr>DR [0-9]+)')
@@ -134,6 +137,16 @@ def get_pr_titles(prs):
return '\n'.join(output)
+def append_changelog_line(out, relative_path, text):
+ line = f'\t* {relative_path}:'
+ if len(line.replace('\t', ' ' * TAB_WIDTH) + ' ' + text) <= LINE_LIMIT:
+ out += f'{line} {text}\n'
+ else:
+ out += f'{line}\n'
+ out += f'\t{text}\n'
+ return out
+
+
def generate_changelog(data, no_functions=False, fill_pr_titles=False,
additional_prs=None):
changelogs = {}
@@ -213,12 +226,12 @@ def generate_changelog(data, no_functions=False, fill_pr_titles=False,
relative_path = file.path[len(changelog):].lstrip('/')
functions = []
if file.is_added_file:
- msg = 'New test' if in_tests else 'New file'
- out += '\t* %s: %s.\n' % (relative_path, msg)
+ msg = 'New test.' if in_tests else 'New file.'
+ out = append_changelog_line(out, relative_path, msg)
elif file.is_removed_file:
- out += '\t* %s: Removed.\n' % (relative_path)
+ out = append_changelog_line(out, relative_path, 'Removed.')
elif hasattr(file, 'is_rename') and file.is_rename:
- out += '\t* %s: Moved to...\n' % (relative_path)
+ out = append_changelog_line(out, relative_path, 'Moved to...')
new_path = file.target_file[2:]
# A file can be theoretically moved to a location that
# belongs to a different ChangeLog. Let user fix it.
@@ -227,6 +240,7 @@ def generate_changelog(data, no_functions=False, fill_pr_titles=False,
out += '\t* %s: ...here.\n' % (new_path)
elif os.path.basename(file.path) in generated_files:
out += '\t* %s: Regenerate.\n' % (relative_path)
+ append_changelog_line(out, relative_path, 'Regenerate.')
else:
if not no_functions:
for hunk in file:
diff --git a/contrib/test_mklog.py b/contrib/test_mklog.py
index f5e9ecd577c..bf2f280b46e 100755
--- a/contrib/test_mklog.py
+++ b/contrib/test_mklog.py
@@ -443,6 +443,27 @@ gcc/ChangeLog:
'''
+PATCH10 = '''\
+diff --git a/libgomp/doc/the-libgomp-abi/implementing-firstprivate-lastprivate-copyin-and-copyprivate-clauses.rst b/libgomp/doc/the-libgomp-abi/implementing-firstprivate-lastprivate-copyin-and-copyprivate-clauses.rst
+new file mode 100644
+index 00000000000..ad3c6d856fc
+--- /dev/null
++++ b/libgomp/doc/the-libgomp-abi/implementing-firstprivate-lastprivate-copyin-and-copyprivate-clauses.rst
+@@ -0,0 +1,3 @@
++
++
++
+
+'''
+
+EXPECTED10 = '''\
+libgomp/ChangeLog:
+
+ * doc/the-libgomp-abi/implementing-firstprivate-lastprivate-copyin-and-copyprivate-clauses.rst:
+ New file.
+
+'''
+
class TestMklog(unittest.TestCase):
def test_macro_definition(self):
changelog = generate_changelog(PATCH1)
@@ -485,3 +506,7 @@ class TestMklog(unittest.TestCase):
def test_define_macro_parsing(self):
changelog = generate_changelog(PATCH9)
assert changelog == EXPECTED9
+
+ def test_long_filenames(self):
+ changelog = generate_changelog(PATCH10)
+ assert changelog == EXPECTED10
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-06-28 11:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-28 11:44 [gcc r12-1842] mklog: Handle correctly long lines Martin Liska
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).