public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-3157] mklog: fix renaming with version 0.7.0.
@ 2021-08-26  8:22 Martin Liska
  0 siblings, 0 replies; only message in thread
From: Martin Liska @ 2021-08-26  8:22 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:e370a2482d41fd382055695b9a0a638ce75e1038

commit r12-3157-ge370a2482d41fd382055695b9a0a638ce75e1038
Author: Martin Liska <mliska@suse.cz>
Date:   Thu Aug 26 10:20:20 2021 +0200

    mklog: fix renaming with version 0.7.0.
    
    contrib/ChangeLog:
    
            * mklog.py: Use file.{source,target}_file for proper rename
            handling.

Diff:
---
 contrib/mklog.py | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/contrib/mklog.py b/contrib/mklog.py
index d362be5ab10..cd5ef0bcc74 100755
--- a/contrib/mklog.py
+++ b/contrib/mklog.py
@@ -148,6 +148,13 @@ def append_changelog_line(out, relative_path, text):
     return out
 
 
+def get_rel_path_if_prefixed(path, folder):
+    if path.startswith(folder):
+        return path[len(folder):].lstrip('/')
+    else:
+        return path
+
+
 def generate_changelog(data, no_functions=False, fill_pr_titles=False,
                        additional_prs=None):
     changelogs = {}
@@ -228,7 +235,7 @@ def generate_changelog(data, no_functions=False, fill_pr_titles=False,
         for file in sorted(files, key=sort_changelog_files):
             assert file.path.startswith(changelog)
             in_tests = 'testsuite' in changelog or 'testsuite' in file.path
-            relative_path = file.path[len(changelog):].lstrip('/')
+            relative_path = get_rel_path_if_prefixed(file.path, changelog)
             functions = []
             if file.is_added_file:
                 msg = 'New test.' if in_tests else 'New file.'
@@ -236,13 +243,17 @@ def generate_changelog(data, no_functions=False, fill_pr_titles=False,
             elif file.is_removed_file:
                 out = append_changelog_line(out, relative_path, 'Removed.')
             elif hasattr(file, 'is_rename') and file.is_rename:
-                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.
-                if new_path.startswith(changelog):
-                    new_path = new_path[len(changelog):].lstrip('/')
-                out += '\t* %s: ...here.\n' % (new_path)
+                #
+                # Since unidiff 0.7.0, path.file == path.target_file[2:],
+                # it used to be path.source_file[2:]
+                relative_path = get_rel_path_if_prefixed(file.source_file[2:],
+                                                         changelog)
+                out = append_changelog_line(out, relative_path, 'Moved to...')
+                new_path = get_rel_path_if_prefixed(file.target_file[2:],
+                                                    changelog)
+                out += f'\t* {new_path}: ...here.\n'
             elif os.path.basename(file.path) in generated_files:
                 out += '\t* %s: Regenerate.\n' % (relative_path)
                 append_changelog_line(out, relative_path, 'Regenerate.')


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-26  8:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-26  8:22 [gcc r12-3157] mklog: fix renaming with version 0.7.0 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).