}
########## Option parsing
+REVERT_FROM_BLEEDING_EDGE=0
-while getopts ":hs:fp:rm:" OPTION ; do
+while getopts ":hs:fp:rm:R" OPTION ; do
case $OPTION in
h) usage
exit 0
;;
s) START_STEP=$OPTARG
;;
+ R) REVERSE_PATCH="--reverse"
+ REVERT_FROM_BLEEDING_EDGE=1
+ ;;
?) echo "Illegal option: -$OPTARG"
usage
exit 1
initial_environment_checks
if [ $START_STEP -le $CURRENT_STEP ] ; then
- if [ ${#@} -lt 2 ] ; then
+ let MIN_EXPECTED_ARGS=2-$REVERT_FROM_BLEEDING_EDGE
+ if [ ${#@} -lt $MIN_EXPECTED_ARGS ] ; then
if [ -z "$EXTRA_PATCH" ] ; then
die "Either a patch file or revision numbers must be specified"
fi
fi
fi
echo ">>> Step $CURRENT_STEP: Preparation"
- MERGE_TO_BRANCH=$1
- [[ -n "$MERGE_TO_BRANCH" ]] || die "Please specify a branch to merge to"
- shift
+ if [ $REVERT_FROM_BLEEDING_EDGE==1 ] ; then
+ MERGE_TO_BRANCH="bleeding_edge"
+ else
+ MERGE_TO_BRANCH=$1
+ [[ -n "$MERGE_TO_BRANCH" ]] || die "Please specify a branch to merge to"
+ shift
+ fi
persist "MERGE_TO_BRANCH"
common_prepare
fi
done
if [ -n "$REVISION_LIST" ] ; then
if [ -n "$REVERSE_PATCH" ] ; then
- NEW_COMMIT_MSG="Rollback of$REVISION_LIST in $MERGE_TO_BRANCH branch."
+ if [ $REVERT_FROM_BLEEDING_EDGE -eq 0 ] ; then
+ NEW_COMMIT_MSG="Rollback of$REVISION_LIST in $MERGE_TO_BRANCH branch."
+ else
+ NEW_COMMIT_MSG="Revert$REVISION_LIST."
+ fi
else
NEW_COMMIT_MSG="Merged$REVISION_LIST into $MERGE_TO_BRANCH branch."
fi;
fi
let CURRENT_STEP+=1
-if [ $START_STEP -le $CURRENT_STEP ] ; then
+if [ $START_STEP -le $CURRENT_STEP ] && [ $REVERT_FROM_BLEEDING_EDGE -eq 0 ] ; then
echo ">>> Step $CURRENT_STEP: Prepare $VERSION_FILE."
# These version numbers are used again for creating the tag
read_and_persist_version
fi
let CURRENT_STEP+=1
-if [ $START_STEP -le $CURRENT_STEP ] ; then
+if [ $START_STEP -le $CURRENT_STEP ] && [ $REVERT_FROM_BLEEDING_EDGE -eq 0 ] ; then
echo ">>> Step $CURRENT_STEP: Increment version number."
restore_if_unset "PATCH"
NEWPATCH=$(($PATCH + 1))
fi
let CURRENT_STEP+=1
-if [ $START_STEP -le $CURRENT_STEP ] ; then
+if [ $START_STEP -le $CURRENT_STEP ] && [ $REVERT_FROM_BLEEDING_EDGE -eq 0 ] ; then
echo ">>> Step $CURRENT_STEP: Determine svn commit revision"
restore_if_unset "NEW_COMMIT_MSG"
restore_if_unset "MERGE_TO_BRANCH"
fi
let CURRENT_STEP+=1
-if [ $START_STEP -le $CURRENT_STEP ] ; then
+if [ $START_STEP -le $CURRENT_STEP ] && [ $REVERT_FROM_BLEEDING_EDGE -eq 0 ] ; then
echo ">>> Step $CURRENT_STEP: Create the tag."
restore_if_unset "SVN_REVISION"
restore_version_if_unset "NEW"
restore_if_unset "REVISION_LIST"
restore_version_if_unset "NEW"
common_cleanup
- echo "*** SUMMARY ***"
- echo "version: $NEWMAJOR.$NEWMINOR.$NEWBUILD.$NEWPATCH"
- echo "branch: $TO_URL"
- echo "svn revision: $SVN_REVISION"
- [[ -n "$REVISION_LIST" ]] && echo "patches:$REVISION_LIST"
+ if [ $REVERT_FROM_BLEEDING_EDGE==0 ] ; then
+ echo "*** SUMMARY ***"
+ echo "version: $NEWMAJOR.$NEWMINOR.$NEWBUILD.$NEWPATCH"
+ echo "branch: $TO_URL"
+ echo "svn revision: $SVN_REVISION"
+ [[ -n "$REVISION_LIST" ]] && echo "patches:$REVISION_LIST"
+ fi
fi