Title: [294183] trunk/Tools
Revision
294183
Author
[email protected]
Date
2022-05-13 16:37:58 -0700 (Fri, 13 May 2022)

Log Message

[webkit-patch] Include commit messages in patches
https://bugs.webkit.org/show_bug.cgi?id=240256
<rdar://92982358>

Rubber-stamped by Aakash Jain.

* Scripts/webkitpy/common/checkout/checkout.py:
(Checkout.commit_message_for_this_commit): If no changelogs are modified, prefer
the commit message.
* Scripts/webkitpy/common/checkout/diff_parser.py:
(DiffParser._parse_into_diff_files): Ignore commit message headers.
* Scripts/webkitpy/common/checkout/scm/git.py:
(Git.create_patch): Prefer `git format-patch` when local commits are available.
(Git.rev_parse): Determine hash for ref.
(Git.format_patch): Deleted.
(Git.request_pull): Deleted.
* Scripts/webkitpy/tool/steps/abstractstep.py:
(AbstractStep): Keep record of local commit.
* Scripts/webkitpy/tool/steps/editchangelog.py:
(EditChangeLog.run): Do not edit changelog if no changelog is present.
* Scripts/webkitpy/tool/steps/preparechangelog.py:
(PrepareChangeLog.run): Do not prepare changelog if local commit is present.

Canonical link: https://commits.webkit.org/250550@main

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (294182 => 294183)


--- trunk/Tools/ChangeLog	2022-05-13 23:12:14 UTC (rev 294182)
+++ trunk/Tools/ChangeLog	2022-05-13 23:37:58 UTC (rev 294183)
@@ -1,3 +1,28 @@
+2022-05-13  Jonathan Bedard  <[email protected]>
+
+        [webkit-patch] Include commit messages in patches
+        https://bugs.webkit.org/show_bug.cgi?id=240256
+        <rdar://92982358>
+
+        Rubber-stamped by Aakash Jain.
+
+        * Scripts/webkitpy/common/checkout/checkout.py:
+        (Checkout.commit_message_for_this_commit): If no changelogs are modified, prefer
+        the commit message.
+        * Scripts/webkitpy/common/checkout/diff_parser.py:
+        (DiffParser._parse_into_diff_files): Ignore commit message headers.
+        * Scripts/webkitpy/common/checkout/scm/git.py:
+        (Git.create_patch): Prefer `git format-patch` when local commits are available.
+        (Git.rev_parse): Determine hash for ref.
+        (Git.format_patch): Deleted.
+        (Git.request_pull): Deleted.
+        * Scripts/webkitpy/tool/steps/abstractstep.py:
+        (AbstractStep): Keep record of local commit.
+        * Scripts/webkitpy/tool/steps/editchangelog.py:
+        (EditChangeLog.run): Do not edit changelog if no changelog is present.
+        * Scripts/webkitpy/tool/steps/preparechangelog.py:
+        (PrepareChangeLog.run): Do not prepare changelog if local commit is present.
+
 2022-05-13  Wenson Hsieh  <[email protected]>
 
         ImageAnalysisQueue should reanalyze image elements whose image sources have changed

Modified: trunk/Tools/Scripts/webkitpy/common/checkout/checkout.py (294182 => 294183)


--- trunk/Tools/Scripts/webkitpy/common/checkout/checkout.py	2022-05-13 23:12:14 UTC (rev 294182)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/checkout.py	2022-05-13 23:37:58 UTC (rev 294183)
@@ -1,4 +1,5 @@
 # Copyright (c) 2010 Google Inc. All rights reserved.
+# Copyright (c) 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 are
@@ -36,6 +37,7 @@
 from webkitpy.common.checkout.scm import CommitMessage
 from webkitpy.common.memoized import memoized
 from webkitpy.common.system.executive import ScriptError
+from webkitpy.common.checkout.scm import Git
 
 if sys.version_info > (3, 0):
     from functools import reduce
@@ -133,6 +135,9 @@
 
     def commit_message_for_this_commit(self, git_commit, changed_files=None, return_stderr=False):
         changelog_paths = self.modified_changelogs(git_commit, changed_files)
+        if not len(changelog_paths) and isinstance(self._scm, Git):
+            if self._scm.merge_base(None) != self._scm.rev_parse('HEAD'):
+                return self._scm.commit_message_for_local_commit(git_commit or 'HEAD')
         if not len(changelog_paths):
             raise ScriptError(message="Found no modified ChangeLogs, cannot create a commit message.\n"
                               "All changes require a ChangeLog.  See:\n %s" % urls.contribution_guidelines)

Modified: trunk/Tools/Scripts/webkitpy/common/checkout/diff_parser.py (294182 => 294183)


--- trunk/Tools/Scripts/webkitpy/common/checkout/diff_parser.py	2022-05-13 23:12:14 UTC (rev 294182)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/diff_parser.py	2022-05-13 23:37:58 UTC (rev 294183)
@@ -1,4 +1,5 @@
 # Copyright (C) 2009 Google Inc. All rights reserved.
+# Copyright (c) 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 are
@@ -139,6 +140,8 @@
     a DiffFile object.
     """
 
+    VERSION_RE = re.compile(r'^\d+.\d+.\d+ \(\S+ Git-\d+\)$')
+
     def __init__(self, diff_input):
         """Parses a diff.
 
@@ -188,7 +191,7 @@
                     current_file.add_unchanged_line(old_diff_line, new_diff_line, line[1:])
                     old_diff_line += 1
                     new_diff_line += 1
-                elif line == '\\ No newline at end of file':
+                elif line == '\\ No newline at end of file' or not line or self.VERSION_RE.match(line):
                     # Nothing to do.  We may still have some added lines.
                     pass
                 else:

Modified: trunk/Tools/Scripts/webkitpy/common/checkout/scm/git.py (294182 => 294183)


--- trunk/Tools/Scripts/webkitpy/common/checkout/scm/git.py	2022-05-13 23:12:14 UTC (rev 294182)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/scm/git.py	2022-05-13 23:37:58 UTC (rev 294183)
@@ -1,5 +1,5 @@
 # Copyright (c) 2009, 2010, 2011 Google Inc. All rights reserved.
-# Copyright (c) 2009, 2016 Apple Inc. All rights reserved.
+# Copyright (c) 2009, 2016, 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 are
@@ -356,24 +356,27 @@
         If git_index is True, git_commit is ignored because only indexed files are handled.
         """
 
+        head = self.rev_parse('HEAD')
+        merge_base = self.merge_base(git_commit)
+        if merge_base == head:
+            command = [self.executable_name, 'diff', '--binary', '--no-color', '--no-ext-diff', '--full-index', '--no-renames']
+        else:
+            command = [self.executable_name, 'format-patch', '--stdout', '--binary']
+
         # Put code changes at the top of the patch and layout tests
         # at the bottom, this makes for easier reviewing.
         config_path = self._filesystem.dirname(self._filesystem.path_to_module('webkitpy.common.config'))
         order_file = self._filesystem.join(config_path, 'orderfile')
-        order = ''
         if self._filesystem.exists(order_file):
-            order = '-O' + order_file
+            command += ['-O', order_file]
 
-        command = [self.executable_name, 'diff', '--binary', '--no-color', '--no-ext-diff', '--full-index', '--no-renames', order]
         if git_index:
             command += ['--cached']
-        else:
-            command += [self.merge_base(git_commit)]
-        command += ['--']
-        if changed_files:
-            command += changed_files
-        return self.prepend_svn_revision(self.run(command, decode_output=False, cwd=self.checkout_root))
+        elif merge_base != head:
+            command += ['HEAD...{}'.format(merge_base)]
 
+        return 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'.
         command = ['svn', 'find-rev', revision_or_treeish]
@@ -621,12 +624,6 @@
     def commit(self, options):
         return self._run_git(['commit'] + options)
 
-    def format_patch(self, options):
-        return self._run_git(['format-patch'] + options)
-
-    def request_pull(self, options):
-        return self._run_git(['request-pull'] + options)
-
     def remote(self, options):
         return self._run_git(['remote'] + options)
 
@@ -647,3 +644,6 @@
         if quiet:
             command += ['-q']
         return self._run_git(command)
+
+    def rev_parse(self, rev):
+        return self._run_git(['rev-parse', rev]).rstrip()

Modified: trunk/Tools/Scripts/webkitpy/tool/steps/abstractstep.py (294182 => 294183)


--- trunk/Tools/Scripts/webkitpy/tool/steps/abstractstep.py	2022-05-13 23:12:14 UTC (rev 294182)
+++ trunk/Tools/Scripts/webkitpy/tool/steps/abstractstep.py	2022-05-13 23:37:58 UTC (rev 294183)
@@ -28,6 +28,7 @@
 
 import sys
 
+from webkitpy.common.checkout.scm import Git
 from webkitpy.tool.steps.options import Options
 
 
@@ -51,6 +52,7 @@
         "diff": lambda self, state: self._tool.scm().create_patch(self._options.git_commit, changed_files=self._changed_files(state)),
         # Absolute path to ChangeLog files.
         "changelogs": lambda self, state: self._tool.checkout().modified_changelogs(self._options.git_commit, changed_files=self._changed_files(state)),
+        "has_local_commit": lambda self, state: self._tool.scm().merge_base(None) != self._tool.scm().rev_parse('HEAD') if isinstance(self._tool.scm(), Git) else False
     }
 
     def cached_lookup(self, state, key, promise=None):

Modified: trunk/Tools/Scripts/webkitpy/tool/steps/editchangelog.py (294182 => 294183)


--- trunk/Tools/Scripts/webkitpy/tool/steps/editchangelog.py	2022-05-13 23:12:14 UTC (rev 294182)
+++ trunk/Tools/Scripts/webkitpy/tool/steps/editchangelog.py	2022-05-13 23:37:58 UTC (rev 294183)
@@ -1,4 +1,5 @@
 # Copyright (C) 2010 Google Inc. All rights reserved.
+# Copyright (C) 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 are
@@ -32,5 +33,6 @@
 class EditChangeLog(AbstractStep):
     def run(self, state):
         absolute_paths = list(map(self._tool.scm().absolute_path, self.cached_lookup(state, "changelogs")))
-        self._tool.user.edit_changelog(absolute_paths)
-        self.did_modify_checkout(state)
+        if absolute_paths:
+            self._tool.user.edit_changelog(absolute_paths)
+            self.did_modify_checkout(state)

Modified: trunk/Tools/Scripts/webkitpy/tool/steps/preparechangelog.py (294182 => 294183)


--- trunk/Tools/Scripts/webkitpy/tool/steps/preparechangelog.py	2022-05-13 23:12:14 UTC (rev 294182)
+++ trunk/Tools/Scripts/webkitpy/tool/steps/preparechangelog.py	2022-05-13 23:37:58 UTC (rev 294183)
@@ -1,4 +1,4 @@
-# Copyright (C) 2020 Apple Inc. All rights reserved.
+# Copyright (C) 2020-2022 Apple Inc. All rights reserved.
 # Copyright (C) 2010 Google Inc. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -106,6 +106,8 @@
         return final_entry + "\n"
 
     def run(self, state):
+        if not self._options.update_changelogs and self.cached_lookup(state, "has_local_commit"):
+            return
         if self.cached_lookup(state, "changelogs"):
             self._ensure_bug_url(state)
             if not self._options.update_changelogs:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to