Skip to content

backport: squash and use cherry-pick, not rebase#2291

Merged
bors-ferrocene[bot] merged 10 commits intomainfrom
jyn/backport-automation
Apr 24, 2026
Merged

backport: squash and use cherry-pick, not rebase#2291
bors-ferrocene[bot] merged 10 commits intomainfrom
jyn/backport-automation

Conversation

@jyn514
Copy link
Copy Markdown
Contributor

@jyn514 jyn514 commented Apr 10, 2026

This hits many fewer conflicts when backporting. Now, instead of requiring every commit to backport cleanly, we only require the diff between main and the PR to backport cleanly. This decreases the fraction of PRs that need to be submitted manually, and also reduces the manual work needed to backport PRs when a manual backport is needed.

There are also various other changes to make the backporting scripts more maintainable and testable; see each individual commit for details. Unlike before, this does not mess with the current git state; running git cherry-pick --abort puts you back in exactly the same state you were in before you ran one.py.

See #2301 for an example PR opened by this automation, and https://github.com/ferrocene/ferrocene/actions/runs/24351997960/job/71108663815 for a sample job output.


Testing

Here is a sample session using one.py to do a manual backport for the upcoming release:

$ git checkout origin/release/1.95
HEAD is now at a31dd5ca4b4d Merge #2258
$ git checkout jyn/backport-automation ferrocene/tools/backport ferrocene/tools/automations-common
$ ferrocene/tools/backport/one.py 2245
ERROR: this script cannot be run when you have staged changes; try running `git reset`
$ git reset
Unstaged changes after reset:
M	ferrocene/tools/automations-common/src/automations_common/automated_prs.py
M	ferrocene/tools/backport/all.py
M	ferrocene/tools/backport/one.py
$ ferrocene/tools/backport/one.py 2245                                                                                                                                                                                                         17:45
warning: if no API token is set in the GITHUB_TOKEN env var, requests may be rate-limited
INFO: backporting ferrocene/ferrocene#2245 to a31dd5ca4b4dfee431d6c5be7b58a8ce56e54b00 (please do not CTRL-C)

Auto-merging .circleci/workflows.yml
Auto-merging ferrocene/ci/scripts/setup-uv.sh
CONFLICT (content): Merge conflict in ferrocene/ci/scripts/setup-uv.sh
error: could not apply d3faae633305... Backport ferrocene/ferrocene#2245

ERROR: Encountered a merge conflict backporting ferrocene/ferrocene#2245

INFO: attempting to auto-solve conflicts with mergiraf
WARN Mergiraf: Could not find a supported language for ferrocene/ci/scripts/setup-uv.sh
HELP: Fix the conflicts, run 'git add/rm <filepath>', then run 'git cherry-pick --continue'.
NOTE: Running 'git cherry-pick --abort' will put you back in your original git state.

NOTE: conflicts exist in the following locations:
ferrocene/ci/scripts/setup-uv.sh:7-17
NOTE: 'HEAD' in the conflicted files refers to your current branch, a31dd5ca4b4dfee431d6c5be7b58a8ce56e54b00

$ git diff --name-status --cached
M       .circleci/workflows.yml
U       ferrocene/ci/scripts/setup-uv.sh
$ git status | head -n5
HEAD detached at origin/release/1.95
You are currently cherry-picking commit d3faae633305.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

(After this lands on beta, the git checkout ferrocene/tools && git reset lines will no longer be needed.)

@jyn514

This comment was marked as resolved.

@jyn514

This comment was marked as resolved.

@jyn514 jyn514 force-pushed the jyn/backport-automation branch from 91a51f1 to 35d8924 Compare April 13, 2026 15:17
@jyn514 jyn514 force-pushed the jyn/backport-automation branch from 35d8924 to a400cd8 Compare April 13, 2026 15:23
@jyn514 jyn514 mentioned this pull request Apr 13, 2026
@jyn514 jyn514 changed the title backport: use git apply && commit, not rebase backport: squash and use cherry-pick, not rebase Apr 13, 2026
Copy link
Copy Markdown
Member

@Urhengulas Urhengulas left a comment

Choose a reason for hiding this comment

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

The last commit says it wants to be removed as well

Comment thread ferrocene/tools/backport/all.py
Comment thread ferrocene/tools/backport/one.py Outdated
@jyn514 jyn514 force-pushed the jyn/backport-automation branch from a400cd8 to 77f4a2f Compare April 16, 2026 13:21
jyn514 added 4 commits April 16, 2026 15:30
A rebase workflow has several problems:
- Firstly, it's just a lot more complicated. It uses a temporary branch,
  an "interactive" non-interactive editor, and several levels of nesting
  across processes.
- Secondly, it requires *every* commit in a PR to rebase successfully,
  not just the PR's diff. This increases the number of PRs that have to
  be rebased manually, and increases the workload while manually
  rebasing.

Using `git apply` allows us to avoid both issues.
- Put mergiraf changes in a separate commit
@jyn514 jyn514 force-pushed the jyn/backport-automation branch from 77f4a2f to dd5e098 Compare April 16, 2026 13:33
Copy link
Copy Markdown
Member

@Urhengulas Urhengulas left a comment

Choose a reason for hiding this comment

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

bors merge

bors-ferrocene Bot added a commit that referenced this pull request Apr 24, 2026
2291: backport: squash and use `cherry-pick`, not rebase r=Urhengulas a=jyn514

This hits many fewer conflicts when backporting. Now, instead of requiring every commit to backport cleanly, we only require the diff between `main` and the PR to backport cleanly. This decreases the fraction of PRs that need to be submitted manually, and also reduces the manual work needed to backport PRs when a manual backport is needed.

There are also various other changes to make the backporting scripts more maintainable and testable; see each individual commit for details. Unlike before, this does not mess with the current git state; running `git cherry-pick --abort` puts you back in exactly the same state you were in before you ran `one.py`.

See #2301 for an example PR opened by this automation, and https://github.com/ferrocene/ferrocene/actions/runs/24351997960/job/71108663815 for a sample job output.

---

## Testing

Here is a sample session using `one.py` to do a manual backport for the upcoming release:
```console
$ git checkout origin/release/1.95
HEAD is now at a31dd5c Merge #2258
$ git checkout jyn/backport-automation ferrocene/tools/backport ferrocene/tools/automations-common
$ ferrocene/tools/backport/one.py 2245
ERROR: this script cannot be run when you have staged changes; try running `git reset`
$ git reset
Unstaged changes after reset:
M	ferrocene/tools/automations-common/src/automations_common/automated_prs.py
M	ferrocene/tools/backport/all.py
M	ferrocene/tools/backport/one.py
$ ferrocene/tools/backport/one.py 2245                                                                                                                                                                                                         17:45
warning: if no API token is set in the GITHUB_TOKEN env var, requests may be rate-limited
INFO: backporting #2245 to a31dd5c (please do not CTRL-C)

Auto-merging .circleci/workflows.yml
Auto-merging ferrocene/ci/scripts/setup-uv.sh
CONFLICT (content): Merge conflict in ferrocene/ci/scripts/setup-uv.sh
error: could not apply d3faae633305... Backport #2245

ERROR: Encountered a merge conflict backporting #2245

INFO: attempting to auto-solve conflicts with mergiraf
WARN Mergiraf: Could not find a supported language for ferrocene/ci/scripts/setup-uv.sh
HELP: Fix the conflicts, run 'git add/rm <filepath>', then run 'git cherry-pick --continue'.
NOTE: Running 'git cherry-pick --abort' will put you back in your original git state.

NOTE: conflicts exist in the following locations:
ferrocene/ci/scripts/setup-uv.sh:7-17
NOTE: 'HEAD' in the conflicted files refers to your current branch, a31dd5c

$ git diff --name-status --cached
M       .circleci/workflows.yml
U       ferrocene/ci/scripts/setup-uv.sh
$ git status | head -n5
HEAD detached at origin/release/1.95
You are currently cherry-picking commit d3faae633305.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)
```

(After this lands on beta, the `git checkout ferrocene/tools && git reset` lines will no longer be needed.)

2336: Fix several bugs in `ferrocene::prevalidated` r=Urhengulas a=jyn514

Thanks to `@Urhengulas` for catching these.

1. The THIR pass didn't check associated items at all. This is fixed in the first commit and tested in `tests/ui/ferrocene/lint-prevalidated/thir-impl-item.rs`. The second commit adds the missing items to libcore.
2. The post-mono pass didn't check dynamic casts. I had correctly "failed closed" here -- the THIR pass would ICE if it wasn't able to check a cast — but because of 1. there were several casts in libcore that weren't caught, including in libcore. The ICE is fixed in the third commit and the post-mono pass is extended in the fourth. This is tested in `tests/ui/ferrocene/lint-prevalidated/dyn-cast-post-mono.rs`.
3. The post-mono pass can't handle MIR inlining. I tried to get this working (see https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/SourceScopeData.20-.3E.20SourceScope/with/590200295), but wasn't able to figure out how to do it reliably. Instead I just disable mir inlining in the 5th commit. This is tested in `tests/ui/ferrocene/lint-prevalidated/mir-inlining.rs`.

Co-authored-by: Jynn Nelson <[email protected]>
Co-authored-by: Urhengulas <[email protected]>
@bors-ferrocene
Copy link
Copy Markdown
Contributor

Build failed (retrying...):

@bors-ferrocene
Copy link
Copy Markdown
Contributor

Build succeeded:

@bors-ferrocene bors-ferrocene Bot merged commit cffb7b8 into main Apr 24, 2026
4 checks passed
@github-actions github-actions Bot added backport:maybe PR candidate for backport merged-in:1.97 labels Apr 24, 2026
@tshepang tshepang deleted the jyn/backport-automation branch April 27, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants