push-to-trunk.sh/merge-to-branch.sh: use "git apply" instead of "patch" to apply patches

Review URL: https://codereview.chromium.org/11031065

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12663 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 6e1bafc8
...@@ -36,9 +36,7 @@ TEMP_BRANCH=$BRANCHNAME-temporary-branch-created-by-script ...@@ -36,9 +36,7 @@ TEMP_BRANCH=$BRANCHNAME-temporary-branch-created-by-script
VERSION_FILE="src/version.cc" VERSION_FILE="src/version.cc"
CHANGELOG_ENTRY_FILE="$PERSISTFILE_BASENAME-changelog-entry" CHANGELOG_ENTRY_FILE="$PERSISTFILE_BASENAME-changelog-entry"
PATCH_FILE="$PERSISTFILE_BASENAME-patch" PATCH_FILE="$PERSISTFILE_BASENAME-patch"
PATCH_OUTPUT_FILE="$PERSISTFILE_BASENAME-patch-output"
COMMITMSG_FILE="$PERSISTFILE_BASENAME-commitmsg" COMMITMSG_FILE="$PERSISTFILE_BASENAME-commitmsg"
TOUCHED_FILES_FILE="$PERSISTFILE_BASENAME-touched-files"
TRUNK_REVISION_FILE="$PERSISTFILE_BASENAME-trunkrevision" TRUNK_REVISION_FILE="$PERSISTFILE_BASENAME-trunkrevision"
START_STEP=0 START_STEP=0
CURRENT_STEP=0 CURRENT_STEP=0
...@@ -181,8 +179,8 @@ the uploaded CL." ...@@ -181,8 +179,8 @@ the uploaded CL."
} }
wait_for_resolving_conflicts() { wait_for_resolving_conflicts() {
echo "Applying the patch failed. Either type \"ABORT<Return>\", or \ echo "Applying the patch \"$1\" failed. Either type \"ABORT<Return>\", or \
resolve the conflicts, stage the touched files with 'git add' and \ resolve the conflicts, stage *all* touched files with 'git add', and \
type \"RESOLVED<Return>\"" type \"RESOLVED<Return>\""
unset ANSWER unset ANSWER
while [ "$ANSWER" != "RESOLVED" ] ; do while [ "$ANSWER" != "RESOLVED" ] ; do
...@@ -195,24 +193,6 @@ type \"RESOLVED<Return>\"" ...@@ -195,24 +193,6 @@ type \"RESOLVED<Return>\""
# Takes a file containing the patch to apply as first argument. # Takes a file containing the patch to apply as first argument.
apply_patch() { apply_patch() {
patch $REVERSE_PATCH -p1 < "$1" > "$PATCH_OUTPUT_FILE" || \ git apply --index --reject $REVERSE_PATCH "$1" || \
{ cat "$PATCH_OUTPUT_FILE" && wait_for_resolving_conflicts; } wait_for_resolving_conflicts "$1";
tee < "$PATCH_OUTPUT_FILE" >(grep "patching file" \
| awk '{print $NF}' >> "$TOUCHED_FILES_FILE")
rm "$PATCH_OUTPUT_FILE"
}
stage_files() {
# Stage added and modified files.
TOUCHED_FILES=$(cat "$TOUCHED_FILES_FILE")
for FILE in $TOUCHED_FILES ; do
git add "$FILE"
done
# Stage deleted files.
DELETED_FILES=$(git status -s -uno --porcelain | grep "^ D" \
| awk '{print $NF}')
for FILE in $DELETED_FILES ; do
git rm "$FILE"
done
rm -f "$TOUCHED_FILES_FILE"
} }
...@@ -186,7 +186,6 @@ if [ $START_STEP -le $CURRENT_STEP ] ; then ...@@ -186,7 +186,6 @@ if [ $START_STEP -le $CURRENT_STEP ] ; then
if [ -n "$EXTRA_PATCH" ] ; then if [ -n "$EXTRA_PATCH" ] ; then
apply_patch "$EXTRA_PATCH" apply_patch "$EXTRA_PATCH"
fi fi
stage_files
fi fi
let CURRENT_STEP+=1 let CURRENT_STEP+=1
......
...@@ -268,7 +268,6 @@ if [ $START_STEP -le $CURRENT_STEP ] ; then ...@@ -268,7 +268,6 @@ if [ $START_STEP -le $CURRENT_STEP ] ; then
echo ">>> Step $CURRENT_STEP: Apply squashed changes." echo ">>> Step $CURRENT_STEP: Apply squashed changes."
rm -f "$TOUCHED_FILES_FILE" rm -f "$TOUCHED_FILES_FILE"
apply_patch "$PATCH_FILE" apply_patch "$PATCH_FILE"
stage_files
rm -f "$PATCH_FILE" rm -f "$PATCH_FILE"
fi fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment