Skip to content

Implement backouts handling for commits with git reverts.#2707

Merged
lutien merged 3 commits intomozilla:masterfrom
lutien:fix-backouts-for-git
Feb 26, 2026
Merged

Implement backouts handling for commits with git reverts.#2707
lutien merged 3 commits intomozilla:masterfrom
lutien:fix-backouts-for-git

Conversation

@lutien
Copy link
Member

@lutien lutien commented Feb 23, 2026

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.

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.
@lutien lutien requested a review from jgraham February 23, 2026 17:03
sync/commit.py Outdated

return landing.LandingSync.has_metadata(self.msg)

def parse_backouts(self) -> tuple[list[bytes], list[int]] | None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

backout_rev = upstream_gecko_backout(
rev,
bug,
f"""Revert \"{message}\"\nThis reverts commit bd771e8b679de5312fbb0e8bfa24edc1ca87b1e5.""".encode(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@lutien lutien force-pushed the fix-backouts-for-git branch from 483f045 to 1385145 Compare February 24, 2026 10:43
@lutien lutien requested a review from jgraham February 24, 2026 10:45
for node in nodes:
git_sha = cinnabar(self.repo).hg2git(node.decode("ascii"))
hg_revision = node.decode("ascii")
if self.is_git_revert:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Computing this over and over seems a bit wasteful, but isn't critical.

@lutien lutien merged commit eee0771 into mozilla:master Feb 26, 2026
4 checks passed
@lutien lutien deleted the fix-backouts-for-git branch February 26, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants