Implement backouts handling for commits with git reverts.#2707
Implement backouts handling for commits with git reverts.#2707lutien merged 3 commits intomozilla:masterfrom
Conversation
Since the migration of gecko repo the backout commit look like git revert commits, so we have to parse them differently. They also contain only the original git hash, which we have to convert to identify backout commits.
sync/commit.py
Outdated
|
|
||
| return landing.LandingSync.has_metadata(self.msg) | ||
|
|
||
| def parse_backouts(self) -> tuple[list[bytes], list[int]] | None: |
There was a problem hiding this comment.
Could we normalize the output here to always return either hg revisions or GeckoCommit objects, rather than depending on the caller to do so?
Also I think this is broken if it's neither a hg not git backout, since nodes_bugs is undefined?
There was a problem hiding this comment.
Ok, I've tried to do that, but I think then it requires moving almost all code from the commits_backed_out, so instead I've just moved the parser choosing to commits_backed_out. Also added node_bugs initialization before.
test/test_upstream.py
Outdated
| backout_rev = upstream_gecko_backout( | ||
| rev, | ||
| bug, | ||
| f"""Revert \"{message}\"\nThis reverts commit bd771e8b679de5312fbb0e8bfa24edc1ca87b1e5.""".encode(), |
There was a problem hiding this comment.
Surely we don't statically know the backed out SHA1? Also could we update the fixture to create the right commit message for the git backout case automatically?
There was a problem hiding this comment.
The thing is, for pure git we just need some git hash that looks like it. So it would work for the parser, because for conversion we're going to mock the API call anyway. I've now added the fixture and added there a random hash (and also added a comment explaining it all).
483f045 to
1385145
Compare
| for node in nodes: | ||
| git_sha = cinnabar(self.repo).hg2git(node.decode("ascii")) | ||
| hg_revision = node.decode("ascii") | ||
| if self.is_git_revert: |
There was a problem hiding this comment.
Computing this over and over seems a bit wasteful, but isn't critical.
Since the migration of gecko repo the backout commit look like git revert commits, so we have to parse them differently. They also contain only the original git hash, which we have to convert to identify backout commits.
Example of such a commit: https://hg-edge.mozilla.org/integration/autoland/rev/92d065a544ee.