Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions recipe/patches/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Use the existing series from the target feedstock branch and the CPython tags
for its old and new releases. The example below assumes sibling `cpython` and
`python-feedstock` checkouts; adjust the paths and tags as needed.

Run the commands in stages. If the rebase reports conflicts, resolve them before
continuing: preserve the intended patch changes and file line endings, do not
let an editor add a final newline to a file that lacks one, stage each resolution,
and run `git rebase --continue`.

```bash
old=v3.14.7
new=v3.14.8
Expand All @@ -12,43 +17,38 @@ cd cpython
git switch -c feedstock-patches "$old"
git am -3 ../python-feedstock/recipe/patches/*.patch
git rebase --onto "$new" "$old"

# Continue here once the rebase has completed successfully.
rm *.patch
git format-patch --no-signature "$new"
for f in *.patch; do
python ../python-feedstock/recipe/patches/make-mixed-crlf-patch.py "$f"
done

# Verify the exported series on a clean checkout of the new tag.
patched_head=$(git rev-parse HEAD)
git switch --detach "$new"
git am *.patch
git diff "$patched_head" HEAD --exit-code
Comment on lines +28 to +32

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This part makes no sense to me. If we've just generated the patches on top of $new with git format-patch, what possible failure mode are we expecting that would justify this almost-certain-to-be-redundant validation?


# Copy the verified patches back to the feedstock.
cp *.patch ../python-feedstock/recipe/patches/
```

The glob selects only patch files in numbered order. Apply all patches, including
those selected only on other platforms in the recipe. `git am -3` can fall back
to a three-way merge when the required Git blobs are available.

Resolve any rebase conflicts, preserving the intended patch changes and file
line endings. Do not let an editor add a final newline to a file that lacks one.
Stage each resolution and run `git rebase --continue`.

Export to a separate directory so generated patches are not mixed with the old
series, then restore the mixed line endings required by Windows patches:

```bash
mkdir ../refreshed-patches
git format-patch --no-signature -o ../refreshed-patches "$new"
for f in ../refreshed-patches/*.patch; do
python ../python-feedstock/recipe/patches/make-mixed-crlf-patch.py "$f"
done
```
Exporting to a separate directory keeps generated patches apart from the old
series. The helper restores the mixed line endings required by Windows patches.
The rebased series remains on `feedstock-patches` while the exported patches are
verified in a detached checkout. The diff check must succeed before copying the
patches back; it confirms that applying them reproduces the rebased source tree.
Preserve patch authorship, metadata, ordering, and recipe references.

For Windows Command Prompt, the application step has this equivalent (use `%%f`
instead of `%f` in a batch file):

```bat
for /f "delims=" %f in ('dir /b /s /on ..\python-feedstock\recipe\patches\*.patch') do git am -3 "%f"
```

Before replacing the feedstock's patches, verify the exported series with
`git am` on a clean checkout of the new tag:

```bash
git worktree add --detach ../cpython-patch-check "$new"
git -C ../cpython-patch-check am ../refreshed-patches/*.patch
git diff HEAD "$(git -C ../cpython-patch-check rev-parse HEAD)" --exit-code
```

The final check confirms that applying the exported patches reproduces the
rebased source tree. Preserve patch authorship, metadata, ordering, and recipe
references when copying the regenerated series back to the feedstock.
Loading