diff options
author | Martin Liska <mliska@suse.cz> | 2021-08-26 10:20:20 +0200 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2021-08-26 10:20:20 +0200 |
commit | e370a2482d41fd382055695b9a0a638ce75e1038 (patch) | |
tree | a97e7b8b71c657b3b908cc5906ad394518baa675 /contrib | |
parent | bfc9250e0de5d5de8a93785ec20e04466ad720f6 (diff) | |
download | gcc-e370a2482d41fd382055695b9a0a638ce75e1038.zip gcc-e370a2482d41fd382055695b9a0a638ce75e1038.tar.gz gcc-e370a2482d41fd382055695b9a0a638ce75e1038.tar.bz2 |
mklog: fix renaming with version 0.7.0.
contrib/ChangeLog:
* mklog.py: Use file.{source,target}_file for proper rename
handling.
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/mklog.py | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/contrib/mklog.py b/contrib/mklog.py index d362be5..cd5ef0b 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.') |