Call fixChangeLogPatch when generating patches from webkit-patch
authorbasile_clement@apple.com <basile_clement@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Jul 2015 20:22:58 +0000 (20:22 +0000)
committerbasile_clement@apple.com <basile_clement@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Jul 2015 20:22:58 +0000 (20:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=147248

Reviewed by Geoffrey Garen.

When two consecutive patches are from the same author, diff tools
create wrong-looking diffs for ChangeLog files where the apparent added
author is actually the previous patch's author line, making it awkward
to read - and things only get worse when committing a patch and a
followup fix for the same bug shortly after.

We have a perl function in VCSUtils.pm, fixChangeLogPatch, to corrects
this, which we use in perl scripts (svn-create-patch et al). But it is
not used by webkit-patch, which is a python script, and thus creates
"bad" diffs.

In the long term, we should probably port fixChangeLogPatch to python -
but in the short term, let's make webkit-patch call perl to run
fixChangeLogPatch. We are already making various external calls there
anyway.

* Scripts/webkitpy/common/checkout/scm/git.py:
(Git.create_patch):
* Scripts/webkitpy/common/checkout/scm/scm.py:
(SCM.fix_changelog_patch):
* Scripts/webkitpy/common/checkout/scm/svn.py:
(SVN.create_patch):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@187357 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/common/checkout/scm/git.py
Tools/Scripts/webkitpy/common/checkout/scm/scm.py
Tools/Scripts/webkitpy/common/checkout/scm/svn.py

index 4f3b9e1..ff71e49 100644 (file)
@@ -1,3 +1,33 @@
+2015-07-24  Basile Clement  <basile_clement@apple.com>
+
+        Call fixChangeLogPatch when generating patches from webkit-patch
+        https://bugs.webkit.org/show_bug.cgi?id=147248
+
+        Reviewed by Geoffrey Garen.
+
+        When two consecutive patches are from the same author, diff tools
+        create wrong-looking diffs for ChangeLog files where the apparent added
+        author is actually the previous patch's author line, making it awkward
+        to read - and things only get worse when committing a patch and a
+        followup fix for the same bug shortly after.
+
+        We have a perl function in VCSUtils.pm, fixChangeLogPatch, to corrects
+        this, which we use in perl scripts (svn-create-patch et al). But it is
+        not used by webkit-patch, which is a python script, and thus creates
+        "bad" diffs.
+
+        In the long term, we should probably port fixChangeLogPatch to python -
+        but in the short term, let's make webkit-patch call perl to run
+        fixChangeLogPatch. We are already making various external calls there
+        anyway.
+
+        * Scripts/webkitpy/common/checkout/scm/git.py:
+        (Git.create_patch):
+        * Scripts/webkitpy/common/checkout/scm/scm.py:
+        (SCM.fix_changelog_patch):
+        * Scripts/webkitpy/common/checkout/scm/svn.py:
+        (SVN.create_patch):
+
 2015-07-24  Dean Johnson  <dean_johnson@apple.com>
 
         commit-queue flags in webkit-patch are confusing
index 7abb9aa..c8e1e3c 100644 (file)
@@ -321,7 +321,9 @@ class Git(SCM, SVNRepository):
         command += ["--"]
         if changed_files:
             command += changed_files
-        return self.prepend_svn_revision(self.run(command, decode_output=False, cwd=self.checkout_root))
+        return self.fix_changelog_patch(
+                self.prepend_svn_revision(
+                    self.run(command, decode_output=False, cwd=self.checkout_root)))
 
     def _run_git_svn_find_rev(self, revision_or_treeish, branch=None):
         # git svn find-rev requires SVN revisions to begin with the character 'r'.
index ebb6c09..b3dcf70 100644 (file)
@@ -77,6 +77,12 @@ class SCM:
                            return_stderr=return_stderr,
                            decode_output=decode_output)
 
+    def fix_changelog_patch(self, diff):
+        return self.run(
+                ['perl', '-e', 'use VCSUtils; print(fixChangeLogPatch(join("", <STDIN>))->{"patch"});'],
+                cwd=self._filesystem.join(self.checkout_root, 'Tools', 'Scripts'),
+                input=diff, decode_output=False)
+
     # SCM always returns repository relative path, but sometimes we need
     # absolute paths to pass to rm, etc.
     def absolute_path(self, repository_relative_path):
index b2a5c95..664be3e 100644 (file)
@@ -273,9 +273,10 @@ class SVN(SCM, SVNRepository):
         elif changed_files == None:
             changed_files = []
         script_path = self._filesystem.join(self.checkout_root, "Tools", "Scripts", "svn-create-patch")
-        return self.run([script_path, "--no-style"] + changed_files,
-            cwd=self.checkout_root, return_stderr=False,
-            decode_output=False)
+        return self.fix_changelog_patch(
+                self.run([script_path, "--no-style"] + changed_files,
+                    cwd=self.checkout_root, return_stderr=False,
+                    decode_output=False))
 
     def committer_email_for_revision(self, revision):
         return self._run_svn(["propget", "svn:author", "--revprop", "-r", revision]).rstrip()