|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -Exeuo pipefail |
| 4 | + |
| 5 | +# |
| 6 | +# Usage |
| 7 | +# |
| 8 | +# if code is based on 3.14.0 and want to change to 3.14.1: |
| 9 | +# $0 v3.14.0 v3.14.1 |
| 10 | +# if you just want to compute the diffs with an upstream version: |
| 11 | +# $0 v3.14.0 v3.14.0 |
| 12 | +# note that both args are any valid git revision, but tags work fine |
| 13 | +# |
| 14 | + |
| 15 | +cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/.." |
| 16 | + |
| 17 | +# load CPYTHON_CLONE_PATH |
| 18 | +set -a |
| 19 | +source sync/.env |
| 20 | +set +a |
| 21 | + |
| 22 | +# make sure local git repo is clean |
| 23 | +test -z "$(git status --porcelain | tee /dev/stderr)" |
| 24 | + |
| 25 | +# fetch CPython tags |
| 26 | +src_rev="$1" |
| 27 | +dst_rev="$2" |
| 28 | +git -C "$CPYTHON_CLONE_PATH" fetch |
| 29 | +git -C "$CPYTHON_CLONE_PATH" show --no-patch "$src_rev" |
| 30 | +git -C "$CPYTHON_CLONE_PATH" show --no-patch "$dst_rev" |
| 31 | + |
| 32 | +# cleanup |
| 33 | +patch_dir="sync/cpython" |
| 34 | +rm -rf "$patch_dir" |
| 35 | +find . -name '*.orig' -delete |
| 36 | +find . -name '*.rej' -delete |
| 37 | + |
| 38 | +# perform the diff & patch |
| 39 | +set +x |
| 40 | +while read -r src_path dst_path; do |
| 41 | + echo ">>>> $src_path" |
| 42 | + mkdir -p "$patch_dir/$(dirname "$dst_path")" |
| 43 | + patch_file="$patch_dir/$dst_path.patch" |
| 44 | + git -C "$CPYTHON_CLONE_PATH" show "$src_rev:$src_path" >"$dst_path" |
| 45 | + git diff -R --output="$patch_file" "$dst_path" |
| 46 | + git -C "$CPYTHON_CLONE_PATH" show "$dst_rev:$src_path" >"$dst_path" |
| 47 | + if [ -s "$patch_file" ]; then |
| 48 | + patch -i "$patch_file" -p 1 || true |
| 49 | + else |
| 50 | + rm "$patch_file" |
| 51 | + fi |
| 52 | +done <<EOF |
| 53 | +Include/internal/pycore_blocks_output_buffer.h src/c/compat/pycore_blocks_output_buffer.h |
| 54 | +Modules/_zstd/zstddict.h src/c/compression_zstd/zstddict.h |
| 55 | +Modules/_zstd/_zstdmodule.c src/c/compression_zstd/_zstdmodule.c |
| 56 | +Modules/_zstd/zstddict.c src/c/compression_zstd/zstddict.c |
| 57 | +Modules/_zstd/decompressor.c src/c/compression_zstd/decompressor.c |
| 58 | +Modules/_zstd/buffer.h src/c/compression_zstd/buffer.h |
| 59 | +Modules/_zstd/_zstdmodule.h src/c/compression_zstd/_zstdmodule.h |
| 60 | +Modules/_zstd/compressor.c src/c/compression_zstd/compressor.c |
| 61 | +Modules/_zstd/clinic/compressor.c.h src/c/compression_zstd/clinic/compressor.c.h |
| 62 | +Modules/_zstd/clinic/zstddict.c.h src/c/compression_zstd/clinic/zstddict.c.h |
| 63 | +Modules/_zstd/clinic/_zstdmodule.c.h src/c/compression_zstd/clinic/_zstdmodule.c.h |
| 64 | +Modules/_zstd/clinic/decompressor.c.h src/c/compression_zstd/clinic/decompressor.c.h |
| 65 | +Lib/compression/_common/_streams.py src/python/backports/zstd/_streams.py |
| 66 | +Lib/compression/zstd/__init__.py src/python/backports/zstd/__init__.py |
| 67 | +Lib/compression/zstd/_zstdfile.py src/python/backports/zstd/_zstdfile.py |
| 68 | +Lib/tarfile.py src/python/backports/zstd/tarfile.py |
| 69 | +Lib/zipfile/__init__.py src/python/backports/zstd/zipfile/__init__.py |
| 70 | +Lib/zipfile/__main__.py src/python/backports/zstd/zipfile/__main__.py |
| 71 | +Lib/zipfile/_path/__init__.py src/python/backports/zstd/zipfile/_path/__init__.py |
| 72 | +Lib/zipfile/_path/glob.py src/python/backports/zstd/zipfile/_path/glob.py |
| 73 | +Lib/test/__init__.py tests/test/__init__.py |
| 74 | +Lib/test/tokenizedata/__init__.py tests/test/tokenizedata/__init__.py |
| 75 | +Lib/test/tokenizedata/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt tests/test/tokenizedata/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt |
| 76 | +Lib/test/tokenizedata/tokenize_tests.txt tests/test/tokenizedata/tokenize_tests.txt |
| 77 | +Lib/test/tokenizedata/badsyntax_3131.py tests/test/tokenizedata/badsyntax_3131.py |
| 78 | +Lib/test/support/__init__.py tests/test/support/__init__.py |
| 79 | +Lib/test/support/script_helper.py tests/test/support/script_helper.py |
| 80 | +Lib/test/support/warnings_helper.py tests/test/support/warnings_helper.py |
| 81 | +Lib/test/support/threading_helper.py tests/test/support/threading_helper.py |
| 82 | +Lib/test/support/import_helper.py tests/test/support/import_helper.py |
| 83 | +Lib/test/support/os_helper.py tests/test/support/os_helper.py |
| 84 | +Lib/test/test_zipfile/__init__.py tests/test/test_zipfile/__init__.py |
| 85 | +Lib/test/test_zipfile/__main__.py tests/test/test_zipfile/__main__.py |
| 86 | +Lib/test/test_zipfile/test_core.py tests/test/test_zipfile/test_core.py |
| 87 | +Lib/test/test_zipfile/_path/__init__.py tests/test/test_zipfile/_path/__init__.py |
| 88 | +Lib/test/test_zipfile/_path/write-alpharep.py tests/test/test_zipfile/_path/write-alpharep.py |
| 89 | +Lib/test/test_zipfile/_path/_test_params.py tests/test/test_zipfile/_path/_test_params.py |
| 90 | +Lib/test/test_zipfile/_path/test_complexity.py tests/test/test_zipfile/_path/test_complexity.py |
| 91 | +Lib/test/test_zipfile/_path/_itertools.py tests/test/test_zipfile/_path/_itertools.py |
| 92 | +Lib/test/test_zipfile/_path/_functools.py tests/test/test_zipfile/_path/_functools.py |
| 93 | +Lib/test/test_zipfile/_path/_support.py tests/test/test_zipfile/_path/_support.py |
| 94 | +Lib/test/test_zipfile/_path/test_path.py tests/test/test_zipfile/_path/test_path.py |
| 95 | +Lib/test/archivetestdata/testtar.tar.xz tests/test/archivetestdata/testtar.tar.xz |
| 96 | +Lib/test/archivetestdata/testtar.tar tests/test/archivetestdata/testtar.tar |
| 97 | +Lib/test/archivetestdata/exe_with_zip tests/test/archivetestdata/exe_with_zip |
| 98 | +Lib/test/archivetestdata/recursion.tar tests/test/archivetestdata/recursion.tar |
| 99 | +Lib/test/archivetestdata/zip_cp437_header.zip tests/test/archivetestdata/zip_cp437_header.zip |
| 100 | +Lib/test/archivetestdata/zipdir_backslash.zip tests/test/archivetestdata/zipdir_backslash.zip |
| 101 | +Lib/test/archivetestdata/zipdir.zip tests/test/archivetestdata/zipdir.zip |
| 102 | +Lib/test/archivetestdata/exe_with_z64 tests/test/archivetestdata/exe_with_z64 |
| 103 | +Lib/test/test_zstd.py tests/test/test_zstd.py |
| 104 | +Lib/test/archiver_tests.py tests/test/archiver_tests.py |
| 105 | +Lib/test/test_tarfile.py tests/test/test_tarfile.py |
| 106 | +EOF |
| 107 | +find "$patch_dir" -type d -empty -delete |
| 108 | + |
| 109 | +echo ">>> Rejected patches" |
| 110 | +find . -name '*.rej' |
| 111 | + |
| 112 | +echo ">>> Also check shutil diffs manually" |
| 113 | +git -C "$CPYTHON_CLONE_PATH" diff "$src_rev...$dst_rev" "Lib/shutil.py" |
| 114 | + |
| 115 | +echo ">>> Script finished, but diffs needs to be reviewed manually" |
0 commit comments