1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
#!/bin/bash
set -e
finish() {
set +x
echo $2
exit $1
}
if [[ ! -d "fissix" ]]; then
finish 1 "ERROR: Must be run from root of fissix repository"
fi
# debug mode
set -x
# make sure no local changes
git update-index -q --refresh
if ! git diff-index --quiet HEAD --; then
finish 1 "ERROR: local changes present; stash or commit then retry"
fi
# switch to base branch, and discard local commits
git checkout -f base
git reset --hard origin/base
# update cpython to latest master
git submodule update --init
git -C cpython checkout -f master
git -C cpython clean -xfd
# copy from cpython
rsync -av cpython/Lib/lib2to3/ fissix/
# reformat lib2to3, ignore any failures
.venv/bin/python -m black --fast fissix/ || true
# Stop early if no changes
git update-index -q --refresh
if git diff-index --quiet HEAD --; then
git checkout -f master
finish 0 "DONE: No upstream changes to lib2to3"
fi
# checkpoint on base branch
REV=$(git -C cpython describe)
git commit -am "Import upstream lib2to3 from $REV"
# cherry-pick this to master branch
git checkout -f master
if ! git cherry-pick base --no-commit; then
while ! git update-index --refresh; do
read -p "Merge conflicts present; resolve then press Enter to continue" choice
echo "checking ..."
done
fi
# reformat to catch merge conflicts
.venv/bin/python -m black --fast fissix/ || true
# Update version markers
scripts/version.sh
# Amend formatting and version markers to cherry-pick commit
git commit -am "Merge upstream lib2to3 from $REV"
finish 0 "Update completed; be sure to push both master and base branches"
|