Bug 1217418 - Make wpt update script more robust in the face of patches that won't apply, r=Ms2ger
authorJames Graham <james@hoppipolla.co.uk>
Wed, 21 Oct 2015 13:50:16 +0100
changeset 304375 f65121860ffe934518e7a886243e648db4289629
parent 304374 c050501bde8269be0183a5d394afe413565bdee5
child 304376 af7f101376375a3d763bad927596b104cb638e95
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMs2ger
bugs1217418
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1217418 - Make wpt update script more robust in the face of patches that won't apply, r=Ms2ger This can happen if landing the update took a long time such that there is a local patch against a file that was changed upstream in the period between starting the update and landing it.
testing/web-platform/update/upstream.py
--- a/testing/web-platform/update/upstream.py
+++ b/testing/web-platform/update/upstream.py
@@ -1,12 +1,13 @@
 import os
 import re
 import subprocess
 import sys
+import tempfile
 import urlparse
 
 from wptrunner.update.sync import LoadManifest
 from wptrunner.update.tree import get_unique_name
 from wptrunner.update.base import Step, StepRunner, exit_clean, exit_unclean
 
 from .tree import Commit, GitTree, Patch
 import github
@@ -198,28 +199,42 @@ class MovePatches(Step):
 
     def create(self, state):
         state.commits_loaded = 0
 
         strip_path = os.path.relpath(state.tests_path,
                                      state.local_tree.root)
         self.logger.debug("Stripping patch %s" % strip_path)
 
+        if not hasattr(state, "patch"):
+            state.patch = None
+
         for commit in state.source_commits[state.commits_loaded:]:
             i = state.commits_loaded + 1
             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)
+            if not state.patch:
+                patch = commit.export_patch(state.tests_path)
+                stripped_patch = rewrite_patch(patch, strip_path)
+            else:
+                filename, stripped_patch = state.patch
+                with open(filename) as f:
+                    stripped_patch.diff = f.read()
+                state.patch = None
             try:
                 state.sync_tree.import_patch(stripped_patch)
             except:
-                print patch.diff
+                with tempfile.NamedTemporaryFile(delete=False, suffix=".diff") as f:
+                    f.write(stripped_patch.diff)
+                    print """Patch failed to apply. Diff saved in %s.
+Fix this file so it applies and run with --continue""" % f.name
+                    state.patch = (f.name, stripped_patch)
                 raise
             state.commits_loaded = i
 
+
 class RebaseCommits(Step):
     """Rebase commits from the current branch on top of the upstream destination branch.
 
     This step is particularly likely to fail if the rebase generates merge conflicts.
     In that case the conflicts can be fixed up locally and the sync process restarted
     with --continue.
     """
     def create(self, state):