Skip to content

merge queue: embarking main (d8eaac9) and #1325 together#1335

Closed
mergify[bot] wants to merge 2 commits intomainfrom
mergify/merge-queue/0871a3b990
Closed

merge queue: embarking main (d8eaac9) and #1325 together#1335
mergify[bot] wants to merge 2 commits intomainfrom
mergify/merge-queue/0871a3b990

Conversation

@mergify
Copy link
Copy Markdown
Contributor

@mergify mergify Bot commented May 4, 2026

🎉 This pull request has been checked successfully and will be merged soon. 🎉

Branch main (d8eaac9) and #1325 are embarked together for merge.

This pull request has been created by Mergify to speculatively check the mergeability of #1325.
You don't need to do anything. Mergify will close this pull request automatically when it is complete.

Required conditions of queue rule default for merge:

Required conditions to stay in the queue:

---
checking_base_sha: d8eaac93a2cbbe006d7d1debaf466c3a4cc08456
previous_failed_batches: []
pull_requests:
  - number: 1325
    scopes: []
scopes: []
...

jd and others added 2 commits April 30, 2026 16:32
After a stack push that includes both a rebase onto a moved trunk and
content edits, the standard `compare/old_sha...new_sha` URL anchored at
`merge-base(old, new)` shows the user's actual changes mixed with every
upstream commit pulled in by the rebase. Reviewers see noise instead of
intent.

This change synthesises a "replay" commit per content-change push:
cherry-pick the previous PR head onto the new PR head's parent (via
`git merge-tree --write-tree` — no working-tree side effects), upload
it as an unreferenced commit through the GitHub Git Data API, and use
its SHA as the URL anchor for a clean rebase-aware diff. The visible
SHA-shorthand label still shows the actual old/new SHAs so users see
what they expect, and a small `(raw)` fallback link points at the
original three-dot URL — useful when GitHub eventually GCs the
unreferenced replay commit. Pure-rebase pushes (patch-IDs match) skip
the synthesis entirely and render a `_(rebase only)_` badge with no
link, since the meaningful diff is empty.

Failure modes (cherry-pick conflict, missing parents, GitHub API
errors, git < 2.38) all return None silently and the renderer falls
back to the existing three-dot URL — no behaviour regression.

New module `mergify_cli/stack/replay.py`:
- compute_merged_tree → runs `git merge-tree --write-tree` with
  parallel parent rev-parses, returns merged tree SHA + parent_new SHA
- compute_tree_delta → parses `git diff-tree -r --raw --no-renames`
  into Git Data API tree entries, with mode/type preservation for
  executables, symlinks, and submodules
- upload_replay_commit → POSTs the tree delta with `base_tree` then a
  parentless-of-new commit; returns the new commit SHA or None on
  any HTTP error
- replay_for_revision → top-level orchestration with all-failure-mode
  fallback to None

Wired into `stack_push`: `replay_for_revision` runs concurrently per
"content"-classified PR (bounded by the existing
MAX_CONCURRENT_API_CALLS semaphore) before the force-push to GitHub.
The resulting replay SHA flows through the revision-history comment
data path as a new `_RevisionEntry.replay_sha` field, persisted in the
JSON marker for round-trip and re-render across subsequent pushes.

Tests: 12 new in `test_replay.py` (covering merge-tree clean/conflict,
tree-delta parsing for M/A/D/T statuses including submodule mode
preservation, two-stage API upload happy and partial-failure paths,
end-to-end orchestration including conflict / no-diff / rev-parse-tree
short-circuits) plus 5 new in `test_push.py` covering the data-model
round-trip, the rebase-only badge, the dual-link rendering with and
without replay_sha, and end-to-end propagation through `stack_push`.

Change-Id: I4b16130414084031dc79dc3de22fc1ae32334409
@mergify mergify Bot deployed to Mergify Merge Protections May 4, 2026 08:33 Active
@mergify mergify Bot closed this May 4, 2026
@mergify mergify Bot deleted the mergify/merge-queue/0871a3b990 branch May 4, 2026 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant