From c12a9ed6f084e1c9265abf66c7228989a5cb94a7 Mon Sep 17 00:00:00 2001 From: "danno@chromium.org" Date: Thu, 29 Mar 2012 07:01:36 +0000 Subject: [PATCH] Allow a commit message to be specified to merge-to-branch.sh R=jkummerow@chromium.org Review URL: https://chromiumcodereview.appspot.com/9844015 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11181 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- tools/common-includes.sh | 11 +++++++++-- tools/merge-to-branch.sh | 18 ++++++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/tools/common-includes.sh b/tools/common-includes.sh index c7d5bc2..d1b8b01 100644 --- a/tools/common-includes.sh +++ b/tools/common-includes.sh @@ -77,20 +77,27 @@ delete_branch() { persist() { local VARNAME=$1 local FILE="$PERSISTFILE_BASENAME-$VARNAME" - echo "${!VARNAME}" > $FILE + local VALUE="${!VARNAME}" + if [ -z "$VALUE" ] ; then + VALUE="__EMPTY__" + fi + echo "$VALUE" > $FILE } restore() { local VARNAME=$1 local FILE="$PERSISTFILE_BASENAME-$VARNAME" local VALUE="$(cat $FILE)" + [[ -z "$VALUE" ]] && die "Variable '$VARNAME' could not be restored." + if [ "$VALUE" == "__EMPTY__" ] ; then + VALUE="" + fi eval "$VARNAME=\"$VALUE\"" } restore_if_unset() { local VARNAME=$1 [[ -z "${!VARNAME}" ]] && restore "$VARNAME" - [[ -z "${!VARNAME}" ]] && die "Variable '$VARNAME' could not be restored." } initial_environment_checks() { diff --git a/tools/merge-to-branch.sh b/tools/merge-to-branch.sh index 85b64d7..aa590a3 100755 --- a/tools/merge-to-branch.sh +++ b/tools/merge-to-branch.sh @@ -49,6 +49,7 @@ OPTIONS: -h Show this message -s Specify the step where to start work. Default: 0. -p Specify a patch file to apply as part of the merge + -m Specify a commit message for the patch -r Reverse specified patches EOF } @@ -69,7 +70,7 @@ restore_patch_commit_hashes_if_unset() { ########## Option parsing -while getopts ":hs:fp:r" OPTION ; do +while getopts ":hs:fp:rm:" OPTION ; do case $OPTION in h) usage exit 0 @@ -80,6 +81,8 @@ while getopts ":hs:fp:r" OPTION ; do ;; r) REVERSE_PATCH="--reverse" ;; + m) NEW_COMMIT_MSG=$OPTARG + ;; s) START_STEP=$OPTARG ;; ?) echo "Illegal option: -$OPTARG" @@ -101,8 +104,13 @@ touch "$ALREADY_MERGING_SENTINEL_FILE" initial_environment_checks if [ $START_STEP -le $CURRENT_STEP ] ; then - if [ ${#@} -lt 2 ] && [ -z "$EXTRA_PATCH" ] ; then - die "Either a patch file or revision numbers must be specified" + if [ ${#@} -lt 2 ] ; then + if [ -z "$EXTRA_PATCH" ] ; then + die "Either a patch file or revision numbers must be specified" + fi + if [ -z "$NEW_COMMIT_MSG" ] ; then + die "You must specify a merge comment if no patches are specified" + fi fi echo ">>> Step $CURRENT_STEP: Preparation" MERGE_TO_BRANCH=$1 @@ -134,9 +142,7 @@ revisions associated with the patches." REVISION_LIST="$REVISION_LIST r$REVISION" let current+=1 done - if [ -z "$REVISION_LIST" ] ; then - NEW_COMMIT_MSG="Applied patch to $MERGE_TO_BRANCH branch." - else + if [ -n "$REVISION_LIST" ] ; then if [ -n "$REVERSE_PATCH" ] ; then NEW_COMMIT_MSG="Rollback of$REVISION_LIST in $MERGE_TO_BRANCH branch." else -- 2.7.4