out += '\t* %s: %s.\n' % (relative_path, msg)
elif file.is_removed_file:
out += '\t* %s: Removed.\n' % (relative_path)
+ elif hasattr(file, 'is_rename') and file.is_rename:
+ out += '\t* %s: Moved to...\n' % (relative_path)
+ 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)
else:
if not no_functions:
for hunk in file:
from mklog import generate_changelog
+import unidiff
+
+unidiff_supports_renaming = hasattr(unidiff.PatchedFile(), 'is_rename')
+
+
PATCH1 = '''\
diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h
index 567c23380fe..e6209ede9d6 100644
'''
+PATCH8 = '''\
+diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf2.c
+similarity index 100%
+rename from gcc/ipa-icf.c
+rename to gcc/ipa-icf2.c
+'''
+
+EXPECTED8 = '''\
+gcc/ChangeLog:
+
+ * ipa-icf.c: Moved to...
+ * ipa-icf2.c: ...here.
+
+'''
+
class TestMklog(unittest.TestCase):
def test_macro_definition(self):
changelog = generate_changelog(PATCH1)
def test_dr_detection_in_test_case(self):
changelog = generate_changelog(PATCH7)
assert changelog == EXPECTED7
+
+ @unittest.skipIf(not unidiff_supports_renaming,
+ 'Newer version of unidiff is needed (0.6.0+)')
+ def test_renaming(self):
+ changelog = generate_changelog(PATCH8)
+ assert changelog == EXPECTED8