aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/wpt/update/tree.py4
-rw-r--r--tests/wpt/update/upstream.py28
2 files changed, 8 insertions, 24 deletions
diff --git a/tests/wpt/update/tree.py b/tests/wpt/update/tree.py
index 5d2a98c2927..e0552da380f 100644
--- a/tests/wpt/update/tree.py
+++ b/tests/wpt/update/tree.py
@@ -69,7 +69,7 @@ class GitTree(wptupdate.tree.GitTree):
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 @@ class GitTree(wptupdate.tree.GitTree):
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):
diff --git a/tests/wpt/update/upstream.py b/tests/wpt/update/upstream.py
index e3266eccafc..b3451278f15 100644
--- a/tests/wpt/update/upstream.py
+++ b/tests/wpt/update/upstream.py
@@ -14,32 +14,13 @@ from .github import GitHub
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 @@ class MovePatches(Step):
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