in sync/landing.py [0:0]
def unlanded_gecko_commits(self):
"""Get a list of gecko commits that correspond to commits which have
landed on the gecko integration branch, but are not yet merged into the
upstream commit we are updating to.
There are two possible sources of such commits:
* Unlanded PRs. These correspond to upstream syncs with status of "open"
* Gecko PRs that landed between the wpt commit that we are syncing to
and latest upstream master.
:return: List of commits in the order in which they originally landed in gecko"""
if self._unlanded_gecko_commits is None:
commits = []
def on_integration_branch(commit):
# Calling this continually is O(N*M) where N is the number of unlanded commits
# and M is the average depth of the commit in the gecko tree
# If we need a faster implementation one approach would be to store all the
# commits not on the integration branch and check if this commit is in that set
return self.git_gecko.is_ancestor(commit,
self.git_gecko.rev_parse(
self.gecko_integration_branch()))
# All the commits from unlanded upstream syncs that are reachable from the
# integration branch
unlanded_syncs = set()
for status in ["open", "wpt-merged"]:
unlanded_syncs |= set(upstream.UpstreamSync.load_by_status(self.git_gecko,
self.git_wpt,
status))
for sync in unlanded_syncs:
branch_commits = [commit.sha1 for commit in sync.gecko_commits if
on_integration_branch(commit)]
if branch_commits:
logger.info("Commits from unlanded sync for bug %s (PR %s) will be reapplied" %
(sync.bug, sync.pr))
commits.extend(branch_commits)
# All the gecko commits that landed between the base sync point and master
# We take the base here and then remove upstreamed commits that we are landing
# as we reach them so that we can get the right diffs for the other PRs
unlanded_commits = self.git_wpt.iter_commits("%s..origin/master" %
self.wpt_commits.base.sha1)
seen_bugs = set()
for commit in unlanded_commits:
wpt_commit = sync_commit.WptCommit(self.git_wpt, commit)
gecko_commit = wpt_commit.metadata.get("gecko-commit")
if gecko_commit:
git_sha = cinnabar(self.git_gecko).hg2git(gecko_commit)
commit = sync_commit.GeckoCommit(self.git_gecko, git_sha)
bug_number = bug.bug_number_from_url(commit.metadata.get("bugzilla-url"))
if on_integration_branch(commit):
if bug_number and bug_number not in seen_bugs:
logger.info("Commits from landed sync for bug %s will be reapplied" %
bug_number)
seen_bugs.add(bug_number)
commits.append(commit.sha1)
commits = set(commits)
# Order the commits according to the order in which they landed in gecko
ordered_commits = []
for commit in self.git_gecko.iter_commits(self.gecko_integration_branch(),
paths=env.config["gecko"]["path"]["wpt"]):
if commit.hexsha in commits:
ordered_commits.append(commit.hexsha)
commits.remove(commit.hexsha)
if not commits:
break
self._unlanded_gecko_commits = list(reversed(
[sync_commit.GeckoCommit(self.git_gecko, item) for item in ordered_commits]))
return self._unlanded_gecko_commits