From f83fd7dfaf8c0cf74a76a6fa3f51ffe2d34ee9e8 Mon Sep 17 00:00:00 2001 From: James Graham Date: Tue, 3 Jan 2017 19:06:50 +0000 Subject: [PATCH] Bug 1331899 - Fix rename handling in wpt sync process, r=Ms2ger MozReview-Commit-ID: JbBaYGnYKKY --- testing/web-platform/update/upstream.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/testing/web-platform/update/upstream.py b/testing/web-platform/update/upstream.py index 1d0037d538c5..f483142492f8 100644 --- a/testing/web-platform/update/upstream.py +++ b/testing/web-platform/update/upstream.py @@ -26,11 +26,12 @@ def rewrite_patch(patch, strip_dir): strip_dir = "/%s"% strip_dir new_diff = [] - line_starts = ["diff ", "+++ ", "--- ", "rename from ", "rename to "] + line_starts = [("diff ", True), ("+++ ", True), ("--- ", True), ("rename from ", False), ("rename to ", False)] for line in patch.diff.split("\n"): - for start in line_starts: + for start, leading_slash in line_starts: + strip = strip_dir if leading_slash else strip_dir[1:] if line.startswith(start): - new_diff.append(line.replace(strip_dir, "").encode("utf8")) + new_diff.append(line.replace(strip, "").encode("utf8")) break else: new_diff.append(line)