Skip to content
Permalink
Browse files
[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
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294183 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
JonWBedard committed May 13, 2022
1 parent ad5aeb9 commit 9fb799e7c5567af8bba18ec5c8be92e028d8d3ff
@@ -1,3 +1,28 @@
2022-05-13 Jonathan Bedard <jbedard@apple.com>

[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 <wenson_hsieh@apple.com>

ImageAnalysisQueue should reanalyze image elements whose image sources have changed
@@ -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 modified_non_changelogs(self, git_commit, changed_files=None):

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)
@@ -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 @@ class DiffParser(object):
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 @@ def _parse_into_diff_files(self, diff_input):
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:
@@ -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,23 +356,26 @@ def create_patch(self, git_commit=None, changed_files=None, git_index=False):
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'.
@@ -621,12 +624,6 @@ def apply_mail_patch(self, options):
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 @@ def checkout(self, revision, quiet=None):
if quiet:
command += ['-q']
return self._run_git(command)

def rev_parse(self, rev):
return self._run_git(['rev-parse', rev]).rstrip()
@@ -28,6 +28,7 @@

import sys

from webkitpy.common.checkout.scm import Git
from webkitpy.tool.steps.options import Options


@@ -51,6 +52,7 @@ def _changed_files(self, state):
"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):
@@ -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)
@@ -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 @@ def _merge_entries(self, old_entry, new_entry):
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:

0 comments on commit 9fb799e

Please sign in to comment.