Bug 1331899 - Update wpt sync for manifest changes, r=Ms2ger
authorJames Graham <james@hoppipolla.co.uk>
Tue, 03 Jan 2017 19:06:22 +0000
changeset 377407 496a7780461a7bcf3ebdd7675d9ba9198b25c531
parent 377406 6e93fdded1289192335788d768fd19381521a86f
child 377408 78932f311341b35b265c21dbf7c8c37066fc0fc1
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMs2ger
bugs1331899
milestone53.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 1331899 - Update wpt sync for manifest changes, r=Ms2ger The source revision is no longer stored in the manifest so instead store it in our metadata file. MozReview-Commit-ID: DjGmRi2Khws
testing/web-platform/update/upstream.py
--- a/testing/web-platform/update/upstream.py
+++ b/testing/web-platform/update/upstream.py
@@ -1,16 +1,15 @@
 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
 from .github import GitHub
 
 
@@ -78,51 +77,55 @@ class SyncToUpstream(Step):
 
         kwargs = state.kwargs
         with state.push(["local_tree", "sync_tree", "tests_path", "metadata_path",
                          "sync"]):
             state.token = kwargs["token"]
             runner = SyncToUpstreamRunner(self.logger, state)
             runner.run()
 
+class GetLastSyncData(Step):
+    """Find the gecko commit at which we last performed a sync with upstream and the upstream
+    commit that was synced."""
+
+    provides = ["sync_data_path", "last_sync_commit", "old_upstream_rev"]
+
+    def create(self, state):
+        self.logger.info("Looking for last sync commit")
+        state.sync_data_path = os.path.join(state.metadata_path, "mozilla-sync")
+        items = {}
+        with open(state.sync_data_path) as f:
+            for line in f.readlines():
+                key, value = [item.strip() for item in line.split(":", 1)]
+                items[key] = value
+
+        state.last_sync_commit = Commit(state.local_tree, items["local"])
+        state.old_upstream_rev = items["upstream"]
+
+        if not state.local_tree.contains_commit(state.last_sync_commit):
+            self.logger.error("Could not find last sync commit %s" % last_sync_sha1)
+            return exit_clean
+
+        self.logger.info("Last sync to web-platform-tests happened in %s" % state.last_sync_commit.sha1)
+
 
 class CheckoutBranch(Step):
     """Create a branch in the sync tree pointing at the last upstream sync commit
     and check it out"""
 
     provides = ["branch"]
 
     def create(self, state):
         self.logger.info("Updating sync tree from %s" % state.sync["remote_url"])
         state.branch = state.sync_tree.unique_branch_name(
-            "outbound_update_%s" % state.old_manifest.rev)
+            "outbound_update_%s" % state.old_upstream_rev)
         state.sync_tree.update(state.sync["remote_url"],
                                state.sync["branch"],
                                state.branch)
-        state.sync_tree.checkout(state.old_manifest.rev, state.branch, force=True)
-
-
-class GetLastSyncCommit(Step):
-    """Find the gecko commit at which we last performed a sync with upstream."""
-
-    provides = ["last_sync_path", "last_sync_commit"]
-
-    def create(self, state):
-        self.logger.info("Looking for last sync commit")
-        state.last_sync_path = os.path.join(state.metadata_path, "mozilla-sync")
-        with open(state.last_sync_path) as f:
-            last_sync_sha1 = f.read().strip()
-
-        state.last_sync_commit = Commit(state.local_tree, last_sync_sha1)
-
-        if not state.local_tree.contains_commit(state.last_sync_commit):
-            self.logger.error("Could not find last sync commit %s" % last_sync_sha1)
-            return exit_clean
-
-        self.logger.info("Last sync to web-platform-tests happened in %s" % state.last_sync_commit.sha1)
+        state.sync_tree.checkout(state.old_upstream_rev, state.branch, force=True)
 
 
 class GetBaseCommit(Step):
     """Find the latest upstream commit on the branch that we are syncing with"""
 
     provides = ["base_commit"]
 
     def create(self, state):
@@ -295,25 +298,28 @@ class MergeUpstream(Step):
             with state.push(["gh_repo", "sync_tree"]):
                 state.commit = commit
                 pr_merger = PRMergeRunner(self.logger, state)
                 rv = pr_merger.run()
                 if rv is not None:
                     return rv
             state.merge_index += 1
 
-class UpdateLastSyncCommit(Step):
+class UpdateLastSyncData(Step):
     """Update the gecko commit at which we last performed a sync with upstream."""
 
     provides = []
 
     def create(self, state):
         self.logger.info("Updating last sync commit")
-        with open(state.last_sync_path, "w") as f:
-            f.write(state.local_tree.rev)
+        data = {"local": state.local_tree.rev,
+                "upstream": state.sync_tree.rev}
+        with open(state.sync_data_path, "w") as f:
+            for key, value in data.iteritems():
+                f.write("%s: %s\n" % (key, value))
         # This gets added to the patch later on
 
 class MergeLocalBranch(Step):
     """Create a local branch pointing at the commit to upstream"""
 
     provides = ["local_branch"]
 
     def create(self, state):
@@ -376,27 +382,26 @@ class PRDeleteBranch(Step):
 
     def create(self, state):
         self.logger.info("Deleting remote branch")
         state.sync_tree.push(state.gh_repo.url, "", state.remote_branch)
 
 
 class SyncToUpstreamRunner(StepRunner):
     """Runner for syncing local changes to upstream"""
-    steps = [LoadManifest,
+    steps = [GetLastSyncData,
              CheckoutBranch,
-             GetLastSyncCommit,
              GetBaseCommit,
              LoadCommits,
              SelectCommits,
              MovePatches,
              RebaseCommits,
              CheckRebase,
              MergeUpstream,
-             UpdateLastSyncCommit]
+             UpdateLastSyncData]
 
 
 class PRMergeRunner(StepRunner):
     """(Sub)Runner for creating and merging a PR"""
     steps = [
         MergeLocalBranch,
         MergeRemoteBranch,
         PushUpstream,