mirror of
https://github.com/Q3Rally-Team/q3rally.git
synced 2024-11-25 05:11:00 +00:00
Add new script for merging ioq3 changes
The new resync_ioq3.sh is _almostly_ automatic if there is no merge conflicts. Though it probably doesn't handle everything that can go wrong. resync_svn.sh requires a lot of manual intervention to fix generated .patch file when there is binary files changed and manually copying the files from ioq3. Also have to manually add/remove files from version control. resync_svn.sh requires manually removing body of commit messages from the generated .log for the commit message.
This commit is contained in:
parent
b9c6fc91af
commit
7ca41f7c2f
3 changed files with 174 additions and 416 deletions
|
@ -43,8 +43,8 @@ ifndef BUILD_DEFINES
|
||||||
BUILD_DEFINES =
|
BUILD_DEFINES =
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# ioquake3 svn version that this is based on
|
# ioquake3 git commit that this is based on
|
||||||
IOQ3_REVISION = 6925
|
IOQ3_REVISION = bc8737d7
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
#
|
#
|
||||||
|
@ -346,7 +346,7 @@ ifeq ($(wildcard .git),.git)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
ifdef IOQ3_REVISION
|
ifdef IOQ3_REVISION
|
||||||
VERSION:=$(VERSION)_IOQ3r$(IOQ3_REVISION)
|
VERSION:=$(VERSION)_IOQ3+$(IOQ3_REVISION)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
171
engine/resync_ioq3.sh
Executable file
171
engine/resync_ioq3.sh
Executable file
|
@ -0,0 +1,171 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
OLD_COMMIT=`grep "IOQ3_REVISION =" "Makefile" | cut -f3 -d' '`
|
||||||
|
NEW_COMMIT="ioquake3/main"
|
||||||
|
|
||||||
|
DRY_RUN=0
|
||||||
|
|
||||||
|
if [ $DRY_RUN -eq 0 ]; then
|
||||||
|
if [ `git diff | wc -l` -ne 0 -o `git diff --staged | wc -l` -ne 0 ]; then
|
||||||
|
echo "Cannot merge ioq3 changes while there are local changes."
|
||||||
|
echo "Maybe 'git stash' and then afterward run 'git stash pop'?"
|
||||||
|
echo "See 'git diff' and/or 'git diff --staged' for changes."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
git remote add ioquake3 https://github.com/ioquake/ioq3.git
|
||||||
|
git fetch ioquake3
|
||||||
|
|
||||||
|
# Resolve commit from name to abbreviated hash
|
||||||
|
OLD_COMMIT=`git log -1 --pretty=format:%h $OLD_COMMIT`
|
||||||
|
NEW_COMMIT=`git log -1 --pretty=format:%h $NEW_COMMIT`
|
||||||
|
|
||||||
|
echo "ioquake3 resync to commit $NEW_COMMIT from $OLD_COMMIT"
|
||||||
|
echo
|
||||||
|
|
||||||
|
PATCH=resync_${OLD_COMMIT}_to_${NEW_COMMIT}.patch
|
||||||
|
LOG=resync_${OLD_COMMIT}_to_${NEW_COMMIT}.log
|
||||||
|
|
||||||
|
if [ ! -f "$PATCH" ]; then
|
||||||
|
git diff $OLD_COMMIT..$NEW_COMMIT |
|
||||||
|
sed "s|^+++ b/autoupdater-readme.txt$|+++ b/docs/autoupdater-readme.txt|g;
|
||||||
|
s|^+++ b/ChangeLog$|+++ b/docs/ChangeLog|g;
|
||||||
|
s|^+++ b/COPYING.txt$|+++ b/docs/COPYING.txt|g;
|
||||||
|
s|^+++ b/id-readme.txt$|+++ b/docs/id-readme.txt|g;
|
||||||
|
s|^+++ b/md4-readme.txt$|+++ b/docs/md4-readme.txt|g;
|
||||||
|
s|^+++ b/opengl2-readme.md$|+++ b/docs/opengl2-readme.md|g;
|
||||||
|
s|^+++ b/README.md$|+++ b/docs/README.md|g;
|
||||||
|
s|^+++ b/TODO$|+++ b/docs/TODO|g;
|
||||||
|
s|^+++ b/voip-readme.txt$|+++ b/docs/voip-readme.txt|g;" > "$PATCH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "$LOG" ]; then
|
||||||
|
echo "ioquake3 resync to commit $NEW_COMMIT from $OLD_COMMIT" > "$LOG"
|
||||||
|
echo "" >> "$LOG"
|
||||||
|
git log --pretty=format:%s $OLD_COMMIT..$NEW_COMMIT | tac >> "$LOG"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Added/changed binary files
|
||||||
|
BINARY_FILES=`grep -a -e "^Binary files /dev/null and b/.* differ$" -e "^Binary files a/.* and b/.* differ$" "$PATCH"`
|
||||||
|
if [ "x$BINARY_FILES" != "x" ]; then
|
||||||
|
BINARY_FILES=`echo "$BINARY_FILES" | sed 's|^Binary files .* and b/\(.*\) differ$|\1|g' | sort`
|
||||||
|
|
||||||
|
echo "Added/changed binary files:"
|
||||||
|
echo "$BINARY_FILES"
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Removed binary files
|
||||||
|
REMOVED_BINARY_FILES=`grep -a -e "^Binary files a/.* and /dev/null differ$" "$PATCH"`
|
||||||
|
if [ "x$REMOVED_BINARY_FILES" != "x" ]; then
|
||||||
|
REMOVED_BINARY_FILES=`echo "$REMOVED_BINARY_FILES" | sed 's|^Binary files a/\(.*\) and /dev/null differ$|\1|g' | sort`
|
||||||
|
|
||||||
|
echo "Removed binary files:"
|
||||||
|
echo "$REMOVED_BINARY_FILES"
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Match the following but only print the filename (e.g. example/file.c).
|
||||||
|
#
|
||||||
|
# --- /dev/null
|
||||||
|
# +++ b/example/file.c
|
||||||
|
#
|
||||||
|
# TODO?: Parse the file in a loop here instead of this sed nightmare?
|
||||||
|
#
|
||||||
|
ADDED_FILES=`cat "$PATCH" | sed -n '{N; /^--- \/dev\/null\n+++ b\/.*$/{p}; D}' | sed 's|^+++ b/\(.*\)$|\1|g' | grep -v "/dev/null" | sort`
|
||||||
|
if [ "x$ADDED_FILES" != "x" ]; then
|
||||||
|
echo "Added text files:"
|
||||||
|
echo "$ADDED_FILES"
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Match the following but only print the filename (e.g. example/file.c).
|
||||||
|
#
|
||||||
|
# --- a/example/file.c
|
||||||
|
# +++ /dev/null
|
||||||
|
#
|
||||||
|
REMOVED_FILES=`cat "$PATCH" | sed -n '{N; /^--- a\/.*\n+++ \/dev\/null$/{p}; D}' | sed 's|^--- a/\(.*\)$|\1|g' | grep -v "/dev/null" | sort`
|
||||||
|
if [ "x$REMOVED_FILES" != "x" ]; then
|
||||||
|
echo "Removed text files:"
|
||||||
|
echo "$REMOVED_FILES"
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
|
||||||
|
# This is changed and renamed files.
|
||||||
|
CHANGED_FILES=`cat "$PATCH" | sed -n '{N; /^--- a\/.*\n+++ b\/.*$/{p}; D}' | sed 's|^+++ b/\(.*\)$|\1|g' | grep -v "^--- a/" | sort`
|
||||||
|
if [ "x$CHANGED_FILES" != "x" ]; then
|
||||||
|
echo "Changed text files:"
|
||||||
|
echo "$CHANGED_FILES"
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $DRY_RUN -eq 0 ]; then
|
||||||
|
# --force disables asking about missing files.
|
||||||
|
patch --force --merge --no-backup-if-mismatch -p1 -i "$PATCH"
|
||||||
|
|
||||||
|
# Use xargs -n1 to run each command separate so git doesn't skip all if one file is missing.
|
||||||
|
|
||||||
|
if [ "x$BINARY_FILES" != "x" ]; then
|
||||||
|
echo $BINARY_FILES | xargs -n1 git checkout $NEW_COMMIT --
|
||||||
|
echo $BINARY_FILES | xargs -n1 git add --
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "x$REMOVED_BINARY_FILES" != "x" ]; then
|
||||||
|
echo $REMOVED_BINARY_FILES | xargs -n1 git rm --
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "x$ADDED_FILES" != "x" ]; then
|
||||||
|
echo $ADDED_FILES | xargs -n1 git add --
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Renamed files need to be added.
|
||||||
|
if [ "x$CHANGED_FILES" != "x" ]; then
|
||||||
|
echo $CHANGED_FILES | xargs -n1 git add --
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "x$REMOVED_FILES" != "x" ]; then
|
||||||
|
echo $REMOVED_FILES | xargs -n1 git rm --
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Update ioq3 revision in Makefile.
|
||||||
|
sed "s/IOQ3_REVISION = $OLD_COMMIT/IOQ3_REVISION = $NEW_COMMIT/" Makefile > Makefile.temp
|
||||||
|
mv Makefile.temp Makefile
|
||||||
|
|
||||||
|
git commit -a --file="$LOG"
|
||||||
|
|
||||||
|
# Report files that failed to merge.
|
||||||
|
UNMERGED_FILES=`git grep -l "<<<<<<<" | grep -v "resync_ioq3.sh"`
|
||||||
|
if [ "x$UNMERGED_FILES" != "x" ]; then
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
echo "Some files failed to merge automatically and contain:"
|
||||||
|
echo
|
||||||
|
echo "<<<<<<<"
|
||||||
|
echo " q3rally text"
|
||||||
|
echo "======="
|
||||||
|
echo " ioquake3 text"
|
||||||
|
echo ">>>>>>>"
|
||||||
|
echo
|
||||||
|
echo "Edit and manually merge the following files and then run 'git commit -a --amend'"
|
||||||
|
echo
|
||||||
|
echo "$UNMERGED_FILES"
|
||||||
|
echo
|
||||||
|
else
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
echo "All files merged automatically."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo
|
||||||
|
echo "dry-run: no changes made"
|
||||||
|
fi
|
||||||
|
|
|
@ -1,413 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# Creates a patch in the current directory to resync a branched
|
|
||||||
# working copy to a newer revision of a main Subversion Repository.
|
|
||||||
#
|
|
||||||
# Created to resync standalone games based on ioquake3 (ioq3).
|
|
||||||
# (Such as Turtle Arena, Smokin' Guns, and many more)
|
|
||||||
#
|
|
||||||
# ~ZTurtleMan
|
|
||||||
#
|
|
||||||
|
|
||||||
#
|
|
||||||
# Most of the variables that are used are listed below.
|
|
||||||
#
|
|
||||||
|
|
||||||
# Show usage; 1 = show full usage, 2 = show mini usage
|
|
||||||
USAGE=0
|
|
||||||
|
|
||||||
# For command line parsing
|
|
||||||
NEXT_ARG=""
|
|
||||||
|
|
||||||
# Revisions
|
|
||||||
HEAD_REV=""
|
|
||||||
CURRENT_REV=""
|
|
||||||
DEFAULT_RESYNC_REV="HEAD"
|
|
||||||
|
|
||||||
# Name of the main branch
|
|
||||||
DEFAULT_MAINNAME="Main"
|
|
||||||
|
|
||||||
# Default SVN path to create the patch/log from
|
|
||||||
DEFAULT_SVN_PATH="svn://svn.example.com/trunk"
|
|
||||||
|
|
||||||
# Magic tokens in $CFGFILE
|
|
||||||
# "MAIN_REVISION = current-revision"
|
|
||||||
DEFAULT_MAINREVISION="MAIN_REVISION"
|
|
||||||
# "MAIN_SVN = svn path"
|
|
||||||
DEFAULT_MAINSVN="MAIN_SVN"
|
|
||||||
|
|
||||||
# True if config file was used to get current revision
|
|
||||||
USED_CFGFILE=0
|
|
||||||
|
|
||||||
# Name of local file where "$MAINREVISION = ..." is stored.
|
|
||||||
CFGFILE="Makefile"
|
|
||||||
|
|
||||||
# Patch/log prefix, followed by '${CURRENT_REV}to$RESYNC_REV.ext'
|
|
||||||
DEFAULT_OUTPREFIX="resync_"
|
|
||||||
|
|
||||||
APPLY_PATCH=0
|
|
||||||
SAVE_LOG=1
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# ioquake3 resync specfic
|
|
||||||
#
|
|
||||||
DEFAULT_MAINNAME="ioquake3"
|
|
||||||
|
|
||||||
# Default SVN path
|
|
||||||
DEFAULT_SVN_PATH="https://github.com/ioquake/ioq3/trunk/"
|
|
||||||
|
|
||||||
# Magic tokens
|
|
||||||
DEFAULT_MAINREVISION="IOQ3_REVISION"
|
|
||||||
# For consistency...
|
|
||||||
DEFAULT_MAINSVN="IOQ3_SVN"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Set to the default value
|
|
||||||
MAINREVISION=$DEFAULT_MAINREVISION
|
|
||||||
MAINSVN=$DEFAULT_MAINSVN
|
|
||||||
RESYNC_REV=$DEFAULT_RESYNC_REV
|
|
||||||
OUTPREFIX=$DEFAULT_OUTPREFIX
|
|
||||||
MAINNAME=$DEFAULT_MAINNAME
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Read command line arguments
|
|
||||||
#
|
|
||||||
for ARG in `echo $*`
|
|
||||||
do
|
|
||||||
|
|
||||||
#
|
|
||||||
# Single argument options
|
|
||||||
#
|
|
||||||
|
|
||||||
if [ "$ARG" = "--help" ] || [ "$ARG" = "-help" ] || [ "$ARG" = "-h" ]
|
|
||||||
then
|
|
||||||
USAGE=1
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$ARG" = "--apply-patch" ]
|
|
||||||
then
|
|
||||||
APPLY_PATCH=1
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$ARG" = "--no-log" ]
|
|
||||||
then
|
|
||||||
SAVE_LOG=0
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Arguments that have a token after it
|
|
||||||
#
|
|
||||||
|
|
||||||
if [ "$ARG" = "--svn" ] || [ "$ARG" = "--current-rev" ] || [ "$ARG" = "--resync-rev" ] || [ "$ARG" = "--cfgfile" ] || [ "$ARG" = "--svn-token" ] || [ "$ARG" = "--rev-token" ] || [ "$ARG" = "--prefix" ] || [ "$ARG" = "--mainname" ]
|
|
||||||
then
|
|
||||||
NEXT_ARG="$ARG"
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$NEXT_ARG" in
|
|
||||||
--svn)
|
|
||||||
SVN_PATH="$ARG"
|
|
||||||
;;
|
|
||||||
--current-rev)
|
|
||||||
CURRENT_REV="$ARG"
|
|
||||||
;;
|
|
||||||
--resync-rev)
|
|
||||||
RESYNC_REV="$ARG"
|
|
||||||
;;
|
|
||||||
--cfgfile)
|
|
||||||
CFGFILE="$ARG"
|
|
||||||
;;
|
|
||||||
--svn-token)
|
|
||||||
MAINSVN="$ARG"
|
|
||||||
;;
|
|
||||||
--rev-token)
|
|
||||||
MAINREVISION="$ARG"
|
|
||||||
;;
|
|
||||||
--prefix)
|
|
||||||
OUTPREFIX="$ARG"
|
|
||||||
;;
|
|
||||||
--mainname)
|
|
||||||
MAINNAME="$ARG"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Unknown argument '$ARG'"
|
|
||||||
USAGE=2
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
NEXT_ARG=""
|
|
||||||
|
|
||||||
done
|
|
||||||
|
|
||||||
# Check for missing ARG!
|
|
||||||
if [ "$NEXT_ARG" != "" ] && [ ! "$USAGE" -eq 1 ]
|
|
||||||
then
|
|
||||||
echo "Error: Missing ARG for $NEXT_ARG!"
|
|
||||||
USAGE=2
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check for missing current revision!
|
|
||||||
if [ "$CURRENT_REV" = "" ] && [ "$CFGFILE" = "" ] && [ ! "$USAGE" -eq 1 ]
|
|
||||||
then
|
|
||||||
echo "$0: you have to specify the current revision"
|
|
||||||
USAGE=2
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check for missing config file!
|
|
||||||
if [ ! "$CFGFILE" = "" ] && [ ! -f "$CFGFILE" ] && [ ! "$USAGE" -eq 1 ]
|
|
||||||
then
|
|
||||||
echo "$0: you have to specify a existing readable/writable file."
|
|
||||||
USAGE=2
|
|
||||||
fi
|
|
||||||
|
|
||||||
#
|
|
||||||
# Show usage, the user asked to see it.
|
|
||||||
#
|
|
||||||
if [ $USAGE -eq 1 ]
|
|
||||||
then
|
|
||||||
echo "Usage: $0 OPTIONS... CURRENTREV..."
|
|
||||||
echo " Creates a patch in the current directory to resync a branched"
|
|
||||||
echo " working copy to a newer revision of a main Subversion Repository."
|
|
||||||
echo ""
|
|
||||||
echo " CURRENTREV"
|
|
||||||
echo " You must pass ether --current-rev [rev] or --cfgfile [file]"
|
|
||||||
echo ""
|
|
||||||
echo " OPTIONS"
|
|
||||||
echo " --help Show this help"
|
|
||||||
echo " -help"
|
|
||||||
echo " -h"
|
|
||||||
echo " --apply-patch apply patch, otherwise just download"
|
|
||||||
echo " --no-log don't save svn log file"
|
|
||||||
echo " --svn [text] path to main Subversion Repository"
|
|
||||||
echo " (default: $DEFAULT_SVN_PATH)"
|
|
||||||
echo " --current-rev [rev] branched off revision from main svn"
|
|
||||||
echo " --resync-rev [rev] resync to main svn at revision (default: $DEFAULT_RESYNC_REV)"
|
|
||||||
echo " --cfgfile [file] file to get config from"
|
|
||||||
echo " '$DEFAULT_MAINSVN = svn path'"
|
|
||||||
echo " '$DEFAULT_MAINREVISION = current-revision'"
|
|
||||||
echo " $DEFAULT_MAINREVISION is updated when --apply-patch is used"
|
|
||||||
echo " --svn-token [text] set token for --cfgfile to find svn path"
|
|
||||||
echo " (default: $DEFAULT_MAINSVN)"
|
|
||||||
echo " --rev-token [text] set token for --cfgfile to find current-revision"
|
|
||||||
echo " (default: $DEFAULT_MAINREVISION)"
|
|
||||||
echo " --prefix [text] prefix for output patch and log files"
|
|
||||||
echo " (default: $DEFAULT_OUTPREFIX)"
|
|
||||||
echo " --mainname [text] name of the main branch, for log"
|
|
||||||
echo " (default: $DEFAULT_MAINNAME)"
|
|
||||||
echo " [rev] requires integer or 'HEAD'"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#
|
|
||||||
# Mini usage message for miss formated command.
|
|
||||||
#
|
|
||||||
if [ $USAGE -eq 2 ]
|
|
||||||
then
|
|
||||||
echo "Try \`$0 --help' for more information."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Set SVN_PATH (if not passed on command line)
|
|
||||||
#
|
|
||||||
if [ "$SVN_PATH" = "" ]
|
|
||||||
then
|
|
||||||
|
|
||||||
# Get svn path from $CFGFILE
|
|
||||||
if [ -f "$CFGFILE" ]
|
|
||||||
then
|
|
||||||
SVN_PATH=`grep "$MAINSVN =" "$CFGFILE" | cut -f3 -d' '`
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if found the svn path
|
|
||||||
if [ "$SVN_PATH" = "" ]
|
|
||||||
then
|
|
||||||
SVN_PATH=$DEFAULT_SVN_PATH
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
#
|
|
||||||
# Set current revision (if not passed on command line)
|
|
||||||
#
|
|
||||||
if [ "$CURRENT_REV" = "" ]
|
|
||||||
then
|
|
||||||
# Get current revision from $CFGFILE
|
|
||||||
if [ -f "$CFGFILE" ]
|
|
||||||
then
|
|
||||||
CURRENT_REV=`grep "$MAINREVISION =" "$CFGFILE" | cut -f3 -d' '`
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if found the current revision
|
|
||||||
if [ "$CURRENT_REV" != "" ]
|
|
||||||
then
|
|
||||||
USED_CFGFILE=1
|
|
||||||
else
|
|
||||||
echo "$0 error: failed to find $MAINREVISION in $CFGFILE."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# Change "HEAD" to integer!
|
|
||||||
# Get the HEAD svn log (Which has the revision number),
|
|
||||||
# ------------------------------------------------------------------------
|
|
||||||
# r1754 | tjw | 2009-12-08 16:36:48 -0600 (Tue, 08 Dec 2009) | 2 lines
|
|
||||||
#
|
|
||||||
# * build the dedicated server with voip support (benmachine)
|
|
||||||
#
|
|
||||||
# ------------------------------------------------------------------------
|
|
||||||
# We only want the line with the revision,
|
|
||||||
# r1754 | tjw | 2009-12-08 16:36:48 -0600 (Tue, 08 Dec 2009) | 2 lines
|
|
||||||
# The revision nubmer is in the first field, ...
|
|
||||||
# r1754
|
|
||||||
# Cut characters after 'r' through end!
|
|
||||||
# 1754
|
|
||||||
|
|
||||||
HEAD_REV=`svn log $SVN_PATH -rHEAD | grep "^r[0-9]" | cut -f1 -d' ' | cut -c 2-`
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# There are some places we can't use "HEAD" so just use the integer.
|
|
||||||
if [ "$CURRENT_REV" = "HEAD" ]
|
|
||||||
then
|
|
||||||
CURRENT_REV=$HEAD_REV
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$CURRENT_REV" -eq "$HEAD_REV" ]
|
|
||||||
then
|
|
||||||
# Were already up to date!
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# CURRENT_REV can't be more than the HEAD_REV
|
|
||||||
if [ "$CURRENT_REV" -gt "$HEAD_REV" ]
|
|
||||||
then
|
|
||||||
echo "$0 error: current revision can't be greater than the HEAD revision."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
if [ "$RESYNC_REV" = "HEAD" ]
|
|
||||||
then
|
|
||||||
RESYNC_REV=$HEAD_REV
|
|
||||||
fi
|
|
||||||
|
|
||||||
# RESYNC_REV must be more than the CURRENT_REV
|
|
||||||
if [ ! "$RESYNC_REV" -gt "$CURRENT_REV" ]
|
|
||||||
then
|
|
||||||
echo "$0 error: resync revision must be more then the current revision."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$RESYNC_REV" -gt "$HEAD_REV" ]
|
|
||||||
then
|
|
||||||
echo "$0 error: resync revision can't be greater than the HEAD revision."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Create patch
|
|
||||||
#
|
|
||||||
|
|
||||||
PATCH="$OUTPREFIX${CURRENT_REV}to$RESYNC_REV.patch"
|
|
||||||
PATCH_NOBINARY="$OUTPREFIX${CURRENT_REV}to$RESYNC_REV-nobinary.patch"
|
|
||||||
|
|
||||||
# Get patch from CURRENT_REV to RESYNC_REV in $SVN_PATH
|
|
||||||
if [ ! -f "$PATCH" ] ; then
|
|
||||||
svn diff $SVN_PATH@$CURRENT_REV $SVN_PATH@$RESYNC_REV > $PATCH
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
binaryChanges=`grep -e "Index: .*\.a" -e "Index: .*\.dll" -e "Index: .*\.dylib" $PATCH`
|
|
||||||
if [ "x$binaryChanges" != "x" ]
|
|
||||||
then
|
|
||||||
binaryChanges=`echo "$binaryChanges" | sed 's/Index: //g'`
|
|
||||||
echo "Patch has binary files which need to be manually updated."
|
|
||||||
echo "You need to manually remove their diff sections from patch too."
|
|
||||||
echo
|
|
||||||
echo "$binaryChanges"
|
|
||||||
echo
|
|
||||||
# filter diff creates a broken patch
|
|
||||||
#if [ ! -f "$PATCH_NOBINARY" ] ; then
|
|
||||||
# filterdiff -x "*.a" -x "*.dll" -x "*.dylib" $PATCH > $PATCH_NOBINARY
|
|
||||||
#fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Output svn log messages
|
|
||||||
#
|
|
||||||
|
|
||||||
if [ "$SAVE_LOG" -eq 1 ]
|
|
||||||
then
|
|
||||||
LOG="$OUTPREFIX${CURRENT_REV}to$RESYNC_REV.log"
|
|
||||||
|
|
||||||
if [ ! -f "$LOG" ] ; then
|
|
||||||
echo "$MAINNAME resync to revision $RESYNC_REV from $CURRENT_REV.\n" > $LOG
|
|
||||||
svn log $SVN_PATH -r "`expr $CURRENT_REV + 1`:$RESYNC_REV" | grep -v "^$" \
|
|
||||||
| grep -v "^------*$" | grep -v "| [0-9]* lines$" \
|
|
||||||
| grep -v "| 1 line$" >> $LOG
|
|
||||||
|
|
||||||
echo "\n\nLog Messages: (Full)\n" >> $LOG
|
|
||||||
svn log $SVN_PATH -r "`expr $CURRENT_REV + 1`:$RESYNC_REV" >> $LOG
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Apply patch
|
|
||||||
#
|
|
||||||
|
|
||||||
if [ "$APPLY_PATCH" -eq 1 ]
|
|
||||||
then
|
|
||||||
|
|
||||||
if [ -f "$PATCH_NOBINARY" ]
|
|
||||||
then
|
|
||||||
APPLY_PATCH_FILE=$PATCH_NOBINARY
|
|
||||||
else
|
|
||||||
APPLY_PATCH_FILE=$PATCH
|
|
||||||
fi
|
|
||||||
|
|
||||||
#
|
|
||||||
# Apply patch
|
|
||||||
#
|
|
||||||
# TODO: Can I check the return value to see if patching failed? (So I can tell user to fix it manually)
|
|
||||||
#
|
|
||||||
# Only shows warnings/errors about failed patching [a existing file].
|
|
||||||
patch -p0 -i $APPLY_PATCH_FILE | grep -v "patching file" | grep -v "Hunk #"
|
|
||||||
|
|
||||||
#
|
|
||||||
# Remove patch?
|
|
||||||
# We shouldn't need it (The failed patch sections are saved as "file-to-patch-with-ext.rej",
|
|
||||||
# unless there is no source to patch.
|
|
||||||
#
|
|
||||||
#rm $PATCH
|
|
||||||
#rm $PATCH_NOBINARY
|
|
||||||
|
|
||||||
|
|
||||||
if [ "$USED_CFGFILE" -eq 1 ]
|
|
||||||
then
|
|
||||||
|
|
||||||
#
|
|
||||||
# Update '$MAINREVISION =' in $CFGFILE
|
|
||||||
#
|
|
||||||
|
|
||||||
sed "s/$MAINREVISION = $CURRENT_REV/$MAINREVISION = $RESYNC_REV/" $CFGFILE > $CFGFILE.temp
|
|
||||||
rm $CFGFILE
|
|
||||||
mv $CFGFILE.temp $CFGFILE
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Finish!
|
|
||||||
exit 0
|
|
||||||
|
|
Loading…
Reference in a new issue