Add backport apply command - #3414
Open
tianyiy-tim wants to merge 1 commit into
Open
Conversation
tianyiy-tim
force-pushed
the
add-backport-apply
branch
from
August 10, 2026 18:08
bc25f3e to
e262484
Compare
tianyiy-tim
force-pushed
the
backport-stack/analyze
branch
from
August 10, 2026 18:09
6d91d1c to
2186b59
Compare
tianyiy-tim
force-pushed
the
add-backport-apply
branch
from
August 10, 2026 21:43
e262484 to
17cfd10
Compare
tianyiy-tim
force-pushed
the
backport-stack/analyze
branch
from
August 10, 2026 21:43
2186b59 to
86a29a2
Compare
tianyiy-tim
force-pushed
the
add-backport-apply
branch
from
August 10, 2026 22:20
17cfd10 to
a9cf352
Compare
tianyiy-tim
force-pushed
the
backport-stack/analyze
branch
from
August 10, 2026 22:20
86a29a2 to
bb4edf2
Compare
tianyiy-tim
force-pushed
the
add-backport-apply
branch
from
August 11, 2026 17:53
a9cf352 to
75e8a17
Compare
tianyiy-tim
force-pushed
the
backport-stack/analyze
branch
from
August 11, 2026 17:53
bb4edf2 to
49f8504
Compare
tianyiy-tim
force-pushed
the
add-backport-apply
branch
from
August 12, 2026 16:46
75e8a17 to
d661ef3
Compare
tianyiy-tim
force-pushed
the
backport-stack/analyze
branch
from
August 12, 2026 16:46
49f8504 to
8618685
Compare
tianyiy-tim
force-pushed
the
add-backport-apply
branch
2 times, most recently
from
August 13, 2026 18:39
93dad97 to
e57e9ed
Compare
tianyiy-tim
marked this pull request as ready for review
August 13, 2026 19:19
nhatnghiho
approved these changes
Aug 15, 2026
nhatnghiho
left a comment
Contributor
There was a problem hiding this comment.
Good job with this PR! Few minor comments below
Comment on lines
+48
to
+52
| p.add_argument( | ||
| "--yes", | ||
| action="store_true", | ||
| help="Skips the confirm. Useful for test scripts", | ||
| ) |
Contributor
There was a problem hiding this comment.
It isn't very clear to me why we need --yes? Can you elaborate more in the help message why test scripts need it?
| │ ├── replay_fixes.py # replays real fixes and grades them | ||
| │ ├── fixes.txt # 39 real fixes to replay | ||
| │ └── answer_key.txt # which branches each one should flag | ||
| └── .backport-runs/ # the last analyze result, not checked in |
Contributor
There was a problem hiding this comment.
nit: add a section in your README explaining the structure of the runstate files in .backport-runs/
tianyiy-tim
force-pushed
the
add-backport-apply
branch
from
August 17, 2026 22:02
e57e9ed to
d492f02
Compare
tianyiy-tim
force-pushed
the
backport-stack/analyze
branch
from
August 17, 2026 22:02
8618685 to
de6efbc
Compare
tianyiy-tim
force-pushed
the
add-backport-apply
branch
from
August 17, 2026 22:17
d492f02 to
4ae7856
Compare
tianyiy-tim
force-pushed
the
backport-stack/analyze
branch
from
August 17, 2026 22:17
de6efbc to
6cb377c
Compare
tianyiy-tim
force-pushed
the
add-backport-apply
branch
from
August 17, 2026 22:28
4ae7856 to
3bcd6bf
Compare
tianyiy-tim
force-pushed
the
backport-stack/analyze
branch
from
August 17, 2026 22:28
6cb377c to
a629026
Compare
tianyiy-tim
force-pushed
the
add-backport-apply
branch
from
August 17, 2026 22:52
3bcd6bf to
140f0c4
Compare
tianyiy-tim
force-pushed
the
backport-stack/analyze
branch
from
August 17, 2026 22:52
a629026 to
4de2668
Compare
Reads the run analyze saved and cherry-picks the fix onto one local branch per affected branch, named backport-<release branch>-<fix>. Branches analyze could not settle are left out, since picking onto one of those would be a guess Each pick runs in its own worktree, so the branch you have checked out never moves and a half finished cherry-pick cannot strand your own working tree mid merge. A clean pick leaves the branch and removes its worktree, a conflict keeps the worktree so it can be resolved in place Each branch is cut from the same remote-tracking release branch analyze judged, not from wherever origin happens to point. A fork is usually behind on the release branches, and a backport built on a base the analysis never saw is not the backport that was asked for Nothing is pushed and no pull request is opened
tianyiy-tim
force-pushed
the
add-backport-apply
branch
from
August 18, 2026 03:37
140f0c4 to
dcf3f49
Compare
tianyiy-tim
force-pushed
the
backport-stack/analyze
branch
from
August 18, 2026 03:37
4de2668 to
6c5fd30
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issues:
Addresses
P425131803Description of changes:
analyzeonly reports which branches are affected. Acting on that still means cherry-picking the fix onto each branch by hand, which for a fix that hits seven branches is seven rounds of the same work.This pull request adds
apply, which cherry-picks the fix onto one local branch per affected branch, namedbackport-<release branch>-<fix>.Stacked on #3389. The base here is
backport-stack/analyze, a scaffolding branch holding that PR's commits, so this diff is only the 7 files this change touches. I will retarget it tomainonce #3389 merges. Please don't merge it into the scaffolding branch.Call-outs:
Each pick runs in its own worktree, so the branch you have checked out never moves and a half-finished cherry-pick can't strand your working tree mid-merge.
A clean pick leaves the branch and removes its worktree. A conflict keeps the worktree, stopped mid-cherry-pick, so you can fix it in place.
Branches that
analyzecould not settle are left out. Cherry-picking onto one of those would be a guess.Cherry-picks pass
-xso the commit carries the "cherry picked from commit" line. That's one of the three signalsanalyzeuses to spot a branch that already has the fix, so without it the tool couldn't recognise its own backports on a later run.Each branch is cut from the same remote-tracking release branch
analyzejudged, not fromorigin. Locallyoriginis usually a fork that is behind on the release branches, and a backport built on a base the analysis never saw can cherry-pick cleanly and still be the wrong change.Nothing is pushed and no pull request is opened. That's the next one.
Testing:
Unit tests - 19 new, 141 total:
They cover the branch naming, which branches get picked, the run file it reads, that the worktree starts from the ref
analyzejudged rather thanorigin, and that a clean pick removes its worktree while a conflict keeps it.Real fix - ran
applyforac3aee310across all 7 release branches: 2 applied cleanly and 5 conflicted. Confirmed the conflicted worktrees were left mid-cherry-pick withUUmarkers, the clean picks produced commits on top of the release branch with the original subject kept, and the-xtrailer is written and found bybranch_mentions_cherry_pick.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.