Modified: trunk/Tools/ChangeLog (292303 => 292304)
--- trunk/Tools/ChangeLog 2022-04-04 17:52:57 UTC (rev 292303)
+++ trunk/Tools/ChangeLog 2022-04-04 17:56:24 UTC (rev 292304)
@@ -1,3 +1,17 @@
+2022-04-04 Jonathan Bedard <[email protected]>
+
+ [git-webkit canonicalize] Support multiple empty lines
+ https://bugs.webkit.org/show_bug.cgi?id=238744
+ <rdar://problem/91246947>
+
+ Reviewed by Stephanie Lewis and Dewei Zhu.
+
+ * Scripts/libraries/webkitscmpy/webkitscmpy/program/canonicalize/message.py:
+ (main): When committing a change with 'Patch by' in it, SVN adds an
+ extra empty line in the commit message.
+ * Scripts/libraries/webkitscmpy/webkitscmpy/test/canonicalize_unittest.py:
+ (TestCanonicalize.test_git_svn_existing_merge_queue): Added.
+
2022-04-04 Chris Dumez <[email protected]>
Drop mostly unused String(const LChar*) constructor
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/canonicalize/message.py (292303 => 292304)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/canonicalize/message.py 2022-04-04 17:52:57 UTC (rev 292303)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/canonicalize/message.py 2022-04-04 17:56:24 UTC (rev 292304)
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
-# Copyright (C) 2020, 2021 Apple Inc. All rights reserved.
+# Copyright (C) 2020-2022 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -69,16 +69,28 @@
if identifier_index and lines[identifier_index - 1].startswith(identifier_template.format('').split(':')[0]):
lines[identifier_index - 1] = identifier_template.format(commit)
identifier_index = identifier_index - 2
- elif identifier_index and lines[identifier_index - 2].startswith(identifier_template.format('').split(':')[0]):
- del lines[identifier_index - 2]
- lines.insert(identifier_index - 1, identifier_template.format(commit))
- identifier_index = identifier_index - 2
else:
- lines.insert(identifier_index, identifier_template.format(commit))
+ for index in [2, 3]:
+ if identifier_index - index > 0 and lines[identifier_index - index].startswith(identifier_template.format('').split(':')[0]):
+ del lines[identifier_index - index]
+ lines.insert(identifier_index - 1, identifier_template.format(commit))
+ identifier_index = identifier_index - 2
+ break
+ else:
+ lines.insert(identifier_index, identifier_template.format(commit))
if lines[identifier_index]:
lines.insert(identifier_index, '')
+ # Turn multiple empty lines at the end of a commit into a single one
+ index = len(lines) - 1
+ while index and lines[index]:
+ index -= 1
+ index -= 1
+ while index and not lines[index]:
+ del lines[index]
+ index -= 1
+
for line in lines:
print(line)
Modified: trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/canonicalize_unittest.py (292303 => 292304)
--- trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/canonicalize_unittest.py 2022-04-04 17:52:57 UTC (rev 292303)
+++ trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/canonicalize_unittest.py 2022-04-04 17:56:24 UTC (rev 292304)
@@ -210,6 +210,48 @@
'1 commit successfully canonicalized!\n',
)
+ def test_git_svn_existing_merge_queue(self):
+ with OutputCapture() as captured, mocks.local.Git(self.path, git_svn=True) as mock, mocks.local.Svn(), MockTime:
+ contirbutors = Contributor.Mapping()
+ contirbutors.create('Jonathan Bedard', '[email protected]')
+
+ mock.commits[mock.default_branch].append(Commit(
+ hash='766609276fe201e7ce2c69994e113d979d2148ac',
+ branch=mock.default_branch,
+ author=Contributor('[email protected]', emails=['[email protected]']),
+ identifier=mock.commits[mock.default_branch][-1].identifier + 1,
+ timestamp=1601668000,
+ revision=9,
+ message='New commit\nIdentifier: 6@main\n\n\ngit-svn-id: https://svn.example.org/repository/repository/trunk@9 268f45cc-cd09-0410-ab3c-d52691b4dbfc',
+ ))
+
+ self.assertEqual(0, program.main(
+ args=('canonicalize', '-vv'),
+ path=self.path,
+ contributors=contirbutors,
+ ))
+
+ commit = local.Git(self.path).commit(branch=mock.default_branch)
+ self.assertEqual(commit.author, contirbutors['[email protected]'])
+
+ self.assertEqual(
+ commit.message,
+ 'New commit\n\n'
+ 'Identifier: 6@main\n'
+ 'git-svn-id: https://svn.example.org/repository/repository/trunk@9 268f45cc-cd09-0410-ab3c-d52691b4dbfc',
+ )
+
+ self.assertEqual(
+ captured.stdout.getvalue(),
+ 'Rewrite 766609276fe201e7ce2c69994e113d979d2148ac (1/1) (--- seconds passed, remaining --- predicted)\n'
+ 'Overwriting 766609276fe201e7ce2c69994e113d979d2148ac\n'
+ ' GIT_AUTHOR_NAME=Jonathan Bedard\n'
+ ' [email protected]\n'
+ ' GIT_COMMITTER_NAME=Jonathan Bedard\n'
+ ' [email protected]\n'
+ '1 commit successfully canonicalized!\n',
+ )
+
def test_branch_commits(self):
with OutputCapture() as captured, mocks.local.Git(self.path) as mock, mocks.local.Svn(), MockTime:
contirbutors = Contributor.Mapping()