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
This commit is contained in:
James Graham 2017-01-03 19:06:22 +00:00
Родитель 20f892ddce
Коммит ac7ea37652
1 изменённых файлов: 34 добавлений и 29 удалений

Просмотреть файл

@ -5,7 +5,6 @@ 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
@ -83,6 +82,30 @@ class SyncToUpstream(Step):
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
@ -93,31 +116,11 @@ class CheckoutBranch(Step):
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):
@ -300,15 +303,18 @@ class MergeUpstream(Step):
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):
@ -381,9 +387,8 @@ class PRDeleteBranch(Step):
class SyncToUpstreamRunner(StepRunner):
"""Runner for syncing local changes to upstream"""
steps = [LoadManifest,
steps = [GetLastSyncData,
CheckoutBranch,
GetLastSyncCommit,
GetBaseCommit,
LoadCommits,
SelectCommits,
@ -391,7 +396,7 @@ class SyncToUpstreamRunner(StepRunner):
RebaseCommits,
CheckRebase,
MergeUpstream,
UpdateLastSyncCommit]
UpdateLastSyncData]
class PRMergeRunner(StepRunner):