Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update web-platform-tests #18756

Merged
merged 9 commits into from Oct 5, 2017

Use git's path stripping when upstreaming patches.

  • Loading branch information
jdm authored and Ms2ger committed Oct 4, 2017
commit d9baadd3dfd573ed3cab53dbc8c58d97c0377e15
@@ -69,7 +69,7 @@ def log(self, base_commit=None, path=None):
data = self.git("log", *args)
return [self.commit_cls(self, sha1) for sha1 in data.split("\0") if sha1]

def import_patch(self, patch):
def import_patch(self, patch, strip_count):
"""Import a patch file into the tree and commit it
:param patch: a Patch object containing the patch to import
@@ -79,7 +79,7 @@ def import_patch(self, patch):
f.write(patch.diff)
f.flush()
f.seek(0)
self.git("apply", "--index", f.name)
self.git("apply", "--index", f.name, "-p", str(strip_count))
self.git("commit", "-m", patch.message.text, "--author=%s" % patch.full_author)

def rebase(self, ref, continue_rebase=False):
@@ -14,32 +14,13 @@


def rewrite_patch(patch, strip_dir):
"""Take a Patch and convert to a different repository by stripping a prefix from the
file paths. Also rewrite the message to remove the bug number and reviewer, but add
"""Take a Patch and rewrite the message to remove the bug number and reviewer, but add
a bugzilla link in the summary.
:param patch: the Patch to convert
:param strip_dir: the path prefix to remove
"""

if not strip_dir.startswith("/"):
strip_dir = "/%s"% strip_dir

new_diff = []
line_starts = ["diff ", "+++ ", "--- "]
for line in patch.diff.split("\n"):
for start in line_starts:
if line.startswith(start):
new_diff.append(line.replace(strip_dir, "").encode("utf8"))
break
else:
new_diff.append(line)

new_diff = "\n".join(new_diff)

assert new_diff != patch

return Patch(patch.author, patch.email, rewrite_message(patch), None, new_diff)
return Patch(patch.author, patch.email, rewrite_message(patch), None, patch.diff)

def rewrite_message(patch):
if patch.merge_message and patch.merge_message.bug:
@@ -223,8 +204,11 @@ def create(self, state):
self.logger.info("Moving commit %i: %s" % (i, commit.message.full_summary))
patch = commit.export_patch(state.tests_path)
stripped_patch = rewrite_patch(patch, strip_path)
strip_count = strip_path.count('/')
if strip_path[-1] != '/':
strip_count += 1
try:
state.sync_tree.import_patch(stripped_patch)
state.sync_tree.import_patch(stripped_patch, 1 + strip_count)
except:
print patch.diff
raise
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.