| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 # Copyright 2012 the V8 project authors. All rights reserved. | 2 # Copyright 2012 the V8 project authors. All rights reserved. |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following | 10 # copyright notice, this list of conditions and the following |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 cat << EOF | 42 cat << EOF |
| 43 usage: $0 [OPTIONS]... [BRANCH] [REVISION]... | 43 usage: $0 [OPTIONS]... [BRANCH] [REVISION]... |
| 44 | 44 |
| 45 Performs the necessary steps to merge revisions from bleeding_edge | 45 Performs the necessary steps to merge revisions from bleeding_edge |
| 46 to other branches, including trunk. | 46 to other branches, including trunk. |
| 47 | 47 |
| 48 OPTIONS: | 48 OPTIONS: |
| 49 -h Show this message | 49 -h Show this message |
| 50 -s Specify the step where to start work. Default: 0. | 50 -s Specify the step where to start work. Default: 0. |
| 51 -p Specify a patch file to apply as part of the merge | 51 -p Specify a patch file to apply as part of the merge |
| 52 -m Specify a commit message for the patch |
| 52 -r Reverse specified patches | 53 -r Reverse specified patches |
| 53 EOF | 54 EOF |
| 54 } | 55 } |
| 55 | 56 |
| 56 persist_patch_commit_hashes() { | 57 persist_patch_commit_hashes() { |
| 57 echo "PATCH_COMMIT_HASHES=( ${PATCH_COMMIT_HASHES[@]} )" > $COMMIT_HASHES_FILE | 58 echo "PATCH_COMMIT_HASHES=( ${PATCH_COMMIT_HASHES[@]} )" > $COMMIT_HASHES_FILE |
| 58 } | 59 } |
| 59 | 60 |
| 60 restore_patch_commit_hashes() { | 61 restore_patch_commit_hashes() { |
| 61 source $COMMIT_HASHES_FILE | 62 source $COMMIT_HASHES_FILE |
| 62 } | 63 } |
| 63 | 64 |
| 64 restore_patch_commit_hashes_if_unset() { | 65 restore_patch_commit_hashes_if_unset() { |
| 65 [[ "${#PATCH_COMMIT_HASHES[@]}" == 0 ]] && restore_patch_commit_hashes | 66 [[ "${#PATCH_COMMIT_HASHES[@]}" == 0 ]] && restore_patch_commit_hashes |
| 66 [[ "${#PATCH_COMMIT_HASHES[@]}" == 0 ]] && [[ -z "$EXTRA_PATCH" ]] && \ | 67 [[ "${#PATCH_COMMIT_HASHES[@]}" == 0 ]] && [[ -z "$EXTRA_PATCH" ]] && \ |
| 67 die "Variable PATCH_COMMIT_HASHES could not be restored." | 68 die "Variable PATCH_COMMIT_HASHES could not be restored." |
| 68 } | 69 } |
| 69 | 70 |
| 70 ########## Option parsing | 71 ########## Option parsing |
| 71 | 72 |
| 72 while getopts ":hs:fp:r" OPTION ; do | 73 while getopts ":hs:fp:rm:" OPTION ; do |
| 73 case $OPTION in | 74 case $OPTION in |
| 74 h) usage | 75 h) usage |
| 75 exit 0 | 76 exit 0 |
| 76 ;; | 77 ;; |
| 77 p) EXTRA_PATCH=$OPTARG | 78 p) EXTRA_PATCH=$OPTARG |
| 78 ;; | 79 ;; |
| 79 f) rm -f "$ALREADY_MERGING_SENTINEL_FILE" | 80 f) rm -f "$ALREADY_MERGING_SENTINEL_FILE" |
| 80 ;; | 81 ;; |
| 81 r) REVERSE_PATCH="--reverse" | 82 r) REVERSE_PATCH="--reverse" |
| 82 ;; | 83 ;; |
| 84 m) NEW_COMMIT_MSG=$OPTARG |
| 85 ;; |
| 83 s) START_STEP=$OPTARG | 86 s) START_STEP=$OPTARG |
| 84 ;; | 87 ;; |
| 85 ?) echo "Illegal option: -$OPTARG" | 88 ?) echo "Illegal option: -$OPTARG" |
| 86 usage | 89 usage |
| 87 exit 1 | 90 exit 1 |
| 88 ;; | 91 ;; |
| 89 esac | 92 esac |
| 90 done | 93 done |
| 91 let OPTION_COUNT=$OPTIND-1 | 94 let OPTION_COUNT=$OPTIND-1 |
| 92 shift $OPTION_COUNT | 95 shift $OPTION_COUNT |
| 93 | 96 |
| 94 ########## Regular workflow | 97 ########## Regular workflow |
| 95 | 98 |
| 96 # If there is a merge in progress, abort. | 99 # If there is a merge in progress, abort. |
| 97 [[ -e "$ALREADY_MERGING_SENTINEL_FILE" ]] && [[ $START_STEP -eq 0 ]] \ | 100 [[ -e "$ALREADY_MERGING_SENTINEL_FILE" ]] && [[ $START_STEP -eq 0 ]] \ |
| 98 && die "A merge is already in progress" | 101 && die "A merge is already in progress" |
| 99 touch "$ALREADY_MERGING_SENTINEL_FILE" | 102 touch "$ALREADY_MERGING_SENTINEL_FILE" |
| 100 | 103 |
| 101 initial_environment_checks | 104 initial_environment_checks |
| 102 | 105 |
| 103 if [ $START_STEP -le $CURRENT_STEP ] ; then | 106 if [ $START_STEP -le $CURRENT_STEP ] ; then |
| 104 if [ ${#@} -lt 2 ] && [ -z "$EXTRA_PATCH" ] ; then | 107 if [ ${#@} -lt 2 ] ; then |
| 105 die "Either a patch file or revision numbers must be specified" | 108 if [ -z "$EXTRA_PATCH" ] ; then |
| 109 die "Either a patch file or revision numbers must be specified" |
| 110 fi |
| 111 if [ -z "$NEW_COMMIT_MSG" ] ; then |
| 112 die "You must specify a merge comment if no patches are specified" |
| 113 fi |
| 106 fi | 114 fi |
| 107 echo ">>> Step $CURRENT_STEP: Preparation" | 115 echo ">>> Step $CURRENT_STEP: Preparation" |
| 108 MERGE_TO_BRANCH=$1 | 116 MERGE_TO_BRANCH=$1 |
| 109 [[ -n "$MERGE_TO_BRANCH" ]] || die "Please specify a branch to merge to" | 117 [[ -n "$MERGE_TO_BRANCH" ]] || die "Please specify a branch to merge to" |
| 110 shift | 118 shift |
| 111 persist "MERGE_TO_BRANCH" | 119 persist "MERGE_TO_BRANCH" |
| 112 common_prepare | 120 common_prepare |
| 113 fi | 121 fi |
| 114 | 122 |
| 115 let CURRENT_STEP+=1 | 123 let CURRENT_STEP+=1 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 127 current=0 | 135 current=0 |
| 128 for REVISION in "$@" ; do | 136 for REVISION in "$@" ; do |
| 129 NEXT_HASH=$(git svn find-rev "r$REVISION" svn/bleeding_edge) | 137 NEXT_HASH=$(git svn find-rev "r$REVISION" svn/bleeding_edge) |
| 130 [[ -n "$NEXT_HASH" ]] \ | 138 [[ -n "$NEXT_HASH" ]] \ |
| 131 || die "Cannot determine git hash for r$REVISION" | 139 || die "Cannot determine git hash for r$REVISION" |
| 132 PATCH_COMMIT_HASHES[$current]="$NEXT_HASH" | 140 PATCH_COMMIT_HASHES[$current]="$NEXT_HASH" |
| 133 [[ -n "$REVISION_LIST" ]] && REVISION_LIST="$REVISION_LIST," | 141 [[ -n "$REVISION_LIST" ]] && REVISION_LIST="$REVISION_LIST," |
| 134 REVISION_LIST="$REVISION_LIST r$REVISION" | 142 REVISION_LIST="$REVISION_LIST r$REVISION" |
| 135 let current+=1 | 143 let current+=1 |
| 136 done | 144 done |
| 137 if [ -z "$REVISION_LIST" ] ; then | 145 if [ -n "$REVISION_LIST" ] ; then |
| 138 NEW_COMMIT_MSG="Applied patch to $MERGE_TO_BRANCH branch." | |
| 139 else | |
| 140 if [ -n "$REVERSE_PATCH" ] ; then | 146 if [ -n "$REVERSE_PATCH" ] ; then |
| 141 NEW_COMMIT_MSG="Rollback of$REVISION_LIST in $MERGE_TO_BRANCH branch." | 147 NEW_COMMIT_MSG="Rollback of$REVISION_LIST in $MERGE_TO_BRANCH branch." |
| 142 else | 148 else |
| 143 NEW_COMMIT_MSG="Merged$REVISION_LIST into $MERGE_TO_BRANCH branch." | 149 NEW_COMMIT_MSG="Merged$REVISION_LIST into $MERGE_TO_BRANCH branch." |
| 144 fi; | 150 fi; |
| 145 fi; | 151 fi; |
| 146 | 152 |
| 147 echo "$NEW_COMMIT_MSG" > $COMMITMSG_FILE | 153 echo "$NEW_COMMIT_MSG" > $COMMITMSG_FILE |
| 148 echo "" >> $COMMITMSG_FILE | 154 echo "" >> $COMMITMSG_FILE |
| 149 for HASH in ${PATCH_COMMIT_HASHES[@]} ; do | 155 for HASH in ${PATCH_COMMIT_HASHES[@]} ; do |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 restore_if_unset "TO_URL" | 271 restore_if_unset "TO_URL" |
| 266 restore_if_unset "REVISION_LIST" | 272 restore_if_unset "REVISION_LIST" |
| 267 restore_version_if_unset "NEW" | 273 restore_version_if_unset "NEW" |
| 268 common_cleanup | 274 common_cleanup |
| 269 echo "*** SUMMARY ***" | 275 echo "*** SUMMARY ***" |
| 270 echo "version: $NEWMAJOR.$NEWMINOR.$NEWBUILD.$NEWPATCH" | 276 echo "version: $NEWMAJOR.$NEWMINOR.$NEWBUILD.$NEWPATCH" |
| 271 echo "branch: $TO_URL" | 277 echo "branch: $TO_URL" |
| 272 echo "svn revision: $SVN_REVISION" | 278 echo "svn revision: $SVN_REVISION" |
| 273 [[ -n "$REVISION_LIST" ]] && echo "patches:$REVISION_LIST" | 279 [[ -n "$REVISION_LIST" ]] && echo "patches:$REVISION_LIST" |
| 274 fi | 280 fi |
| OLD | NEW |