| 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 30 matching lines...) Expand all Loading... |
| 41 usage() { | 41 usage() { |
| 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 EOF | 52 EOF |
| 52 } | 53 } |
| 53 | 54 |
| 54 persist_patch_commit_hashes() { | 55 persist_patch_commit_hashes() { |
| 55 echo "PATCH_COMMIT_HASHES=( ${PATCH_COMMIT_HASHES[@]} )" > $COMMIT_HASHES_FILE | 56 echo "PATCH_COMMIT_HASHES=( ${PATCH_COMMIT_HASHES[@]} )" > $COMMIT_HASHES_FILE |
| 56 } | 57 } |
| 57 | 58 |
| 58 restore_patch_commit_hashes() { | 59 restore_patch_commit_hashes() { |
| 59 source $COMMIT_HASHES_FILE | 60 source $COMMIT_HASHES_FILE |
| 60 } | 61 } |
| 61 | 62 |
| 62 restore_patch_commit_hashes_if_unset() { | 63 restore_patch_commit_hashes_if_unset() { |
| 63 [[ "${#PATCH_COMMIT_HASHES[@]}" == 0 ]] && restore_patch_commit_hashes | 64 [[ "${#PATCH_COMMIT_HASHES[@]}" == 0 ]] && restore_patch_commit_hashes |
| 64 [[ "${#PATCH_COMMIT_HASHES[@]}" == 0 ]] && \ | 65 [[ "${#PATCH_COMMIT_HASHES[@]}" == 0 ]] && [[ -z "$EXTRA_PATCH" ]] && \ |
| 65 die "Variable PATCH_COMMIT_HASHES could not be restored." | 66 die "Variable PATCH_COMMIT_HASHES could not be restored." |
| 66 } | 67 } |
| 67 | 68 |
| 68 ########## Option parsing | 69 ########## Option parsing |
| 69 | 70 |
| 70 while getopts ":hs:f" OPTION ; do | 71 while getopts ":hs:fp:" OPTION ; do |
| 71 case $OPTION in | 72 case $OPTION in |
| 72 h) usage | 73 h) usage |
| 73 exit 0 | 74 exit 0 |
| 74 ;; | 75 ;; |
| 76 p) EXTRA_PATCH=$OPTARG |
| 77 ;; |
| 75 f) rm -f "$ALREADY_MERGING_SENTINEL_FILE" | 78 f) rm -f "$ALREADY_MERGING_SENTINEL_FILE" |
| 76 ;; | 79 ;; |
| 77 s) START_STEP=$OPTARG | 80 s) START_STEP=$OPTARG |
| 78 ;; | 81 ;; |
| 79 ?) echo "Illegal option: -$OPTARG" | 82 ?) echo "Illegal option: -$OPTARG" |
| 80 usage | 83 usage |
| 81 exit 1 | 84 exit 1 |
| 82 ;; | 85 ;; |
| 83 esac | 86 esac |
| 84 done | 87 done |
| 85 let OPTION_COUNT=$OPTIND-1 | 88 let OPTION_COUNT=$OPTIND-1 |
| 86 shift $OPTION_COUNT | 89 shift $OPTION_COUNT |
| 87 | 90 |
| 88 ########## Regular workflow | 91 ########## Regular workflow |
| 89 | 92 |
| 90 # If there is a merge in progress, abort. | 93 # If there is a merge in progress, abort. |
| 91 [[ -e "$ALREADY_MERGING_SENTINEL_FILE" ]] && [[ $START_STEP -eq 0 ]] \ | 94 [[ -e "$ALREADY_MERGING_SENTINEL_FILE" ]] && [[ $START_STEP -eq 0 ]] \ |
| 92 && die "A merge is already in progress" | 95 && die "A merge is already in progress" |
| 93 touch "$ALREADY_MERGING_SENTINEL_FILE" | 96 touch "$ALREADY_MERGING_SENTINEL_FILE" |
| 94 | 97 |
| 95 initial_environment_checks | 98 initial_environment_checks |
| 96 | 99 |
| 97 if [ $START_STEP -le $CURRENT_STEP ] ; then | 100 if [ $START_STEP -le $CURRENT_STEP ] ; then |
| 101 if [ ${#@} -lt 2 ] && [ -z "$EXTRA_PATCH" ] ; then |
| 102 die "Either a patch file or revision numbers must be specified" |
| 103 fi |
| 98 echo ">>> Step $CURRENT_STEP: Preparation" | 104 echo ">>> Step $CURRENT_STEP: Preparation" |
| 99 MERGE_TO_BRANCH=$1 | 105 MERGE_TO_BRANCH=$1 |
| 100 [[ -n "$MERGE_TO_BRANCH" ]] || die "Please specify a branch to merge to" | 106 [[ -n "$MERGE_TO_BRANCH" ]] || die "Please specify a branch to merge to" |
| 101 shift | 107 shift |
| 102 persist "MERGE_TO_BRANCH" | 108 persist "MERGE_TO_BRANCH" |
| 103 common_prepare | 109 common_prepare |
| 104 fi | 110 fi |
| 105 | 111 |
| 106 let CURRENT_STEP+=1 | 112 let CURRENT_STEP+=1 |
| 107 if [ $START_STEP -le $CURRENT_STEP ] ; then | 113 if [ $START_STEP -le $CURRENT_STEP ] ; then |
| 108 echo ">>> Step $CURRENT_STEP: Create a fresh branch for the patch." | 114 echo ">>> Step $CURRENT_STEP: Create a fresh branch for the patch." |
| 109 restore_if_unset "MERGE_TO_BRANCH" | 115 restore_if_unset "MERGE_TO_BRANCH" |
| 110 git checkout -b $BRANCHNAME svn/$MERGE_TO_BRANCH \ | 116 git checkout -b $BRANCHNAME svn/$MERGE_TO_BRANCH \ |
| 111 || die "Creating branch $BRANCHNAME failed." | 117 || die "Creating branch $BRANCHNAME failed." |
| 112 fi | 118 fi |
| 113 | 119 |
| 114 let CURRENT_STEP+=1 | 120 let CURRENT_STEP+=1 |
| 115 if [ $START_STEP -le $CURRENT_STEP ] ; then | 121 if [ $START_STEP -le $CURRENT_STEP ] ; then |
| 116 echo ">>> Step $CURRENT_STEP: Find the git \ | 122 echo ">>> Step $CURRENT_STEP: Find the git \ |
| 117 revisions associated with the patches." | 123 revisions associated with the patches." |
| 118 current=0 | 124 current=0 |
| 119 for REVISION in "$@" ; do | 125 for REVISION in "$@" ; do |
| 120 NEXT_HASH=$(git svn find-rev "r$REVISION" svn/bleeding_edge) | 126 NEXT_HASH=$(git svn find-rev "r$REVISION" svn/bleeding_edge) |
| 121 [[ -n "$NEXT_HASH" ]] \ | 127 [[ -n "$NEXT_HASH" ]] \ |
| 122 || die "Cannot determine git hash for r$REVISION" | 128 || die "Cannot determine git hash for r$REVISION" |
| 123 PATCH_COMMIT_HASHES[$current]="$NEXT_HASH" | 129 PATCH_COMMIT_HASHES[$current]="$NEXT_HASH" |
| 124 [[ -n "$NEW_COMMIT_MSG" ]] && NEW_COMMIT_MSG="$NEW_COMMIT_MSG," | 130 [[ -n "$REVISION_LIST" ]] && REVISION_LIST="$REVISION_LIST," |
| 125 NEW_COMMIT_MSG="$NEW_COMMIT_MSG r$REVISION" | 131 REVISION_LIST="$REVISION_LIST r$REVISION" |
| 126 let current+=1 | 132 let current+=1 |
| 127 done | 133 done |
| 128 NEW_COMMIT_MSG="Merged$NEW_COMMIT_MSG into $MERGE_TO_BRANCH branch." | 134 if [ -z "$REVISION_LIST" ] ; then |
| 135 NEW_COMMIT_MSG="Applied patch to $MERGE_TO_BRANCH branch." |
| 136 else |
| 137 NEW_COMMIT_MSG="Merged$REVISION_LIST into $MERGE_TO_BRANCH branch." |
| 138 fi; |
| 129 | 139 |
| 130 echo "$NEW_COMMIT_MSG" > $COMMITMSG_FILE | 140 echo "$NEW_COMMIT_MSG" > $COMMITMSG_FILE |
| 131 echo "" >> $COMMITMSG_FILE | 141 echo "" >> $COMMITMSG_FILE |
| 132 for HASH in ${PATCH_COMMIT_HASHES[@]} ; do | 142 for HASH in ${PATCH_COMMIT_HASHES[@]} ; do |
| 133 PATCH_MERGE_DESCRIPTION=$(git log -1 --format=%s $HASH) | 143 PATCH_MERGE_DESCRIPTION=$(git log -1 --format=%s $HASH) |
| 134 echo "$PATCH_MERGE_DESCRIPTION" >> $COMMITMSG_FILE | 144 echo "$PATCH_MERGE_DESCRIPTION" >> $COMMITMSG_FILE |
| 135 echo "" >> $COMMITMSG_FILE | 145 echo "" >> $COMMITMSG_FILE |
| 136 done | 146 done |
| 137 for HASH in ${PATCH_COMMIT_HASHES[@]} ; do | 147 for HASH in ${PATCH_COMMIT_HASHES[@]} ; do |
| 138 BUG=$(git log -1 $HASH | grep "BUG=" | awk -F '=' '{print $NF}') | 148 BUG=$(git log -1 $HASH | grep "BUG=" | awk -F '=' '{print $NF}') |
| 139 if [ -n "$BUG" ] ; then | 149 if [ -n "$BUG" ] ; then |
| 140 [[ -n "$BUG_AGGREGATE" ]] && BUG_AGGREGATE="$BUG_AGGREGATE," | 150 [[ -n "$BUG_AGGREGATE" ]] && BUG_AGGREGATE="$BUG_AGGREGATE," |
| 141 BUG_AGGREGATE="$BUG_AGGREGATE$BUG" | 151 BUG_AGGREGATE="$BUG_AGGREGATE$BUG" |
| 142 fi | 152 fi |
| 143 done | 153 done |
| 144 if [ -n "$BUG_AGGREGATE" ] ; then | 154 if [ -n "$BUG_AGGREGATE" ] ; then |
| 145 echo "BUG=$BUG_AGGREGATE" >> $COMMITMSG_FILE | 155 echo "BUG=$BUG_AGGREGATE" >> $COMMITMSG_FILE |
| 146 fi | 156 fi |
| 147 persist "NEW_COMMIT_MSG" | 157 persist "NEW_COMMIT_MSG" |
| 158 persist "REVISION_LIST" |
| 148 persist_patch_commit_hashes | 159 persist_patch_commit_hashes |
| 149 fi | 160 fi |
| 150 | 161 |
| 151 let CURRENT_STEP+=1 | 162 let CURRENT_STEP+=1 |
| 152 if [ $START_STEP -le $CURRENT_STEP ] ; then | 163 if [ $START_STEP -le $CURRENT_STEP ] ; then |
| 153 echo ">>> Step $CURRENT_STEP: Apply patches for selected revisions." | 164 echo ">>> Step $CURRENT_STEP: Apply patches for selected revisions." |
| 154 restore_if_unset "MERGE_TO_BRANCH" | 165 restore_if_unset "MERGE_TO_BRANCH" |
| 155 restore_patch_commit_hashes_if_unset "PATCH_COMMIT_HASHES" | 166 restore_patch_commit_hashes_if_unset "PATCH_COMMIT_HASHES" |
| 156 rm -f "$TOUCHED_FILES_FILE" | 167 rm -f "$TOUCHED_FILES_FILE" |
| 157 for HASH in ${PATCH_COMMIT_HASHES[@]} ; do | 168 for HASH in ${PATCH_COMMIT_HASHES[@]} ; do |
| 158 echo "Applying patch for $HASH to $MERGE_TO_BRANCH..." | 169 echo "Applying patch for $HASH to $MERGE_TO_BRANCH..." |
| 159 git log -1 -p $HASH > "$TEMPORARY_PATCH_FILE" | 170 git log -1 -p $HASH > "$TEMPORARY_PATCH_FILE" |
| 160 apply_patch "$TEMPORARY_PATCH_FILE" | 171 apply_patch "$TEMPORARY_PATCH_FILE" |
| 161 done | 172 done |
| 173 if [ -n "$EXTRA_PATCH" ] ; then |
| 174 apply_patch "$EXTRA_PATCH" |
| 175 fi |
| 162 stage_files | 176 stage_files |
| 163 fi | 177 fi |
| 164 | 178 |
| 165 let CURRENT_STEP+=1 | 179 let CURRENT_STEP+=1 |
| 166 if [ $START_STEP -le $CURRENT_STEP ] ; then | 180 if [ $START_STEP -le $CURRENT_STEP ] ; then |
| 167 echo ">>> Step $CURRENT_STEP: Prepare $VERSION_FILE." | 181 echo ">>> Step $CURRENT_STEP: Prepare $VERSION_FILE." |
| 168 # These version numbers are used again for creating the tag | 182 # These version numbers are used again for creating the tag |
| 169 read_and_persist_version | 183 read_and_persist_version |
| 170 fi | 184 fi |
| 171 | 185 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 echo "Creating tag svn/tags/$NEWMAJOR.$NEWMINOR.$NEWBUILD.$NEWPATCH" | 241 echo "Creating tag svn/tags/$NEWMAJOR.$NEWMINOR.$NEWBUILD.$NEWPATCH" |
| 228 if [ "$MERGE_TO_BRANCH" == "trunk" ] ; then | 242 if [ "$MERGE_TO_BRANCH" == "trunk" ] ; then |
| 229 TO_URL="$MERGE_TO_BRANCH" | 243 TO_URL="$MERGE_TO_BRANCH" |
| 230 else | 244 else |
| 231 TO_URL="branches/$MERGE_TO_BRANCH" | 245 TO_URL="branches/$MERGE_TO_BRANCH" |
| 232 fi | 246 fi |
| 233 svn copy -r $SVN_REVISION \ | 247 svn copy -r $SVN_REVISION \ |
| 234 https://v8.googlecode.com/svn/$TO_URL \ | 248 https://v8.googlecode.com/svn/$TO_URL \ |
| 235 https://v8.googlecode.com/svn/tags/$NEWMAJOR.$NEWMINOR.$NEWBUILD.$NEWPATCH \ | 249 https://v8.googlecode.com/svn/tags/$NEWMAJOR.$NEWMINOR.$NEWBUILD.$NEWPATCH \ |
| 236 -m "Tagging version $NEWMAJOR.$NEWMINOR.$NEWBUILD.$NEWPATCH" | 250 -m "Tagging version $NEWMAJOR.$NEWMINOR.$NEWBUILD.$NEWPATCH" |
| 251 persist "TO_URL" |
| 237 fi | 252 fi |
| 238 | 253 |
| 239 let CURRENT_STEP+=1 | 254 let CURRENT_STEP+=1 |
| 240 if [ $START_STEP -le $CURRENT_STEP ] ; then | 255 if [ $START_STEP -le $CURRENT_STEP ] ; then |
| 241 echo ">>> Step $CURRENT_STEP: Cleanup." | 256 echo ">>> Step $CURRENT_STEP: Cleanup." |
| 257 restore_if_unset "SVN_REVISION" |
| 258 restore_if_unset "TO_URL" |
| 259 restore_if_unset "REVISION_LIST" |
| 260 restore_version_if_unset "NEW" |
| 242 common_cleanup | 261 common_cleanup |
| 262 echo "*** SUMMARY ***" |
| 263 echo "version: $NEWMAJOR.$NEWMINOR.$NEWBUILD.$NEWPATCH" |
| 264 echo "branch: $TO_URL" |
| 265 echo "svn revision: $SVN_REVISION" |
| 266 [[ -n "$REVISION_LIST" ]] && echo "patches:$REVISION_LIST" |
| 243 fi | 267 fi |
| OLD | NEW |