Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: tools/merge-to-branch.sh

Issue 85413004: Add -R option to merge-to-branch script to revert from bleeding_edge. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 source $COMMIT_HASHES_FILE 62 source $COMMIT_HASHES_FILE
63 } 63 }
64 64
65 restore_patch_commit_hashes_if_unset() { 65 restore_patch_commit_hashes_if_unset() {
66 [[ "${#PATCH_COMMIT_HASHES[@]}" == 0 ]] && restore_patch_commit_hashes 66 [[ "${#PATCH_COMMIT_HASHES[@]}" == 0 ]] && restore_patch_commit_hashes
67 [[ "${#PATCH_COMMIT_HASHES[@]}" == 0 ]] && [[ -z "$EXTRA_PATCH" ]] && \ 67 [[ "${#PATCH_COMMIT_HASHES[@]}" == 0 ]] && [[ -z "$EXTRA_PATCH" ]] && \
68 die "Variable PATCH_COMMIT_HASHES could not be restored." 68 die "Variable PATCH_COMMIT_HASHES could not be restored."
69 } 69 }
70 70
71 ########## Option parsing 71 ########## Option parsing
72 REVERT_FROM_BLEEDING_EDGE=0
72 73
73 while getopts ":hs:fp:rm:" OPTION ; do 74 while getopts ":hs:fp:rm:R" OPTION ; do
74 case $OPTION in 75 case $OPTION in
75 h) usage 76 h) usage
76 exit 0 77 exit 0
77 ;; 78 ;;
78 p) EXTRA_PATCH=$OPTARG 79 p) EXTRA_PATCH=$OPTARG
79 ;; 80 ;;
80 f) rm -f "$ALREADY_MERGING_SENTINEL_FILE" 81 f) rm -f "$ALREADY_MERGING_SENTINEL_FILE"
81 ;; 82 ;;
82 r) REVERSE_PATCH="--reverse" 83 r) REVERSE_PATCH="--reverse"
83 ;; 84 ;;
84 m) NEW_COMMIT_MSG=$OPTARG 85 m) NEW_COMMIT_MSG=$OPTARG
85 ;; 86 ;;
86 s) START_STEP=$OPTARG 87 s) START_STEP=$OPTARG
87 ;; 88 ;;
89 R) REVERSE_PATCH="--reverse"
90 REVERT_FROM_BLEEDING_EDGE=1
91 ;;
88 ?) echo "Illegal option: -$OPTARG" 92 ?) echo "Illegal option: -$OPTARG"
89 usage 93 usage
90 exit 1 94 exit 1
91 ;; 95 ;;
92 esac 96 esac
93 done 97 done
94 let OPTION_COUNT=$OPTIND-1 98 let OPTION_COUNT=$OPTIND-1
95 shift $OPTION_COUNT 99 shift $OPTION_COUNT
96 100
97 ########## Regular workflow 101 ########## Regular workflow
98 102
99 # If there is a merge in progress, abort. 103 # If there is a merge in progress, abort.
100 [[ -e "$ALREADY_MERGING_SENTINEL_FILE" ]] && [[ $START_STEP -eq 0 ]] \ 104 [[ -e "$ALREADY_MERGING_SENTINEL_FILE" ]] && [[ $START_STEP -eq 0 ]] \
101 && die "A merge is already in progress" 105 && die "A merge is already in progress"
102 touch "$ALREADY_MERGING_SENTINEL_FILE" 106 touch "$ALREADY_MERGING_SENTINEL_FILE"
103 107
104 initial_environment_checks 108 initial_environment_checks
105 109
106 if [ $START_STEP -le $CURRENT_STEP ] ; then 110 if [ $START_STEP -le $CURRENT_STEP ] ; then
107 if [ ${#@} -lt 2 ] ; then 111 let MIN_EXPECTED_ARGS=2-$REVERT_FROM_BLEEDING_EDGE
112 if [ ${#@} -lt $MIN_EXPECTED_ARGS ] ; then
108 if [ -z "$EXTRA_PATCH" ] ; then 113 if [ -z "$EXTRA_PATCH" ] ; then
109 die "Either a patch file or revision numbers must be specified" 114 die "Either a patch file or revision numbers must be specified"
110 fi 115 fi
111 if [ -z "$NEW_COMMIT_MSG" ] ; then 116 if [ -z "$NEW_COMMIT_MSG" ] ; then
112 die "You must specify a merge comment if no patches are specified" 117 die "You must specify a merge comment if no patches are specified"
113 fi 118 fi
114 fi 119 fi
115 echo ">>> Step $CURRENT_STEP: Preparation" 120 echo ">>> Step $CURRENT_STEP: Preparation"
116 MERGE_TO_BRANCH=$1 121 if [ $REVERT_FROM_BLEEDING_EDGE==1 ] ; then
117 [[ -n "$MERGE_TO_BRANCH" ]] || die "Please specify a branch to merge to" 122 MERGE_TO_BRANCH="bleeding_edge"
118 shift 123 else
124 MERGE_TO_BRANCH=$1
125 [[ -n "$MERGE_TO_BRANCH" ]] || die "Please specify a branch to merge to"
126 shift
127 fi
119 persist "MERGE_TO_BRANCH" 128 persist "MERGE_TO_BRANCH"
120 common_prepare 129 common_prepare
121 fi 130 fi
122 131
123 let CURRENT_STEP+=1 132 let CURRENT_STEP+=1
124 if [ $START_STEP -le $CURRENT_STEP ] ; then 133 if [ $START_STEP -le $CURRENT_STEP ] ; then
125 echo ">>> Step $CURRENT_STEP: Create a fresh branch for the patch." 134 echo ">>> Step $CURRENT_STEP: Create a fresh branch for the patch."
126 restore_if_unset "MERGE_TO_BRANCH" 135 restore_if_unset "MERGE_TO_BRANCH"
127 git checkout -b $BRANCHNAME svn/$MERGE_TO_BRANCH \ 136 git checkout -b $BRANCHNAME svn/$MERGE_TO_BRANCH \
128 || die "Creating branch $BRANCHNAME failed." 137 || die "Creating branch $BRANCHNAME failed."
129 fi 138 fi
130 139
131 let CURRENT_STEP+=1 140 let CURRENT_STEP+=1
132 if [ $START_STEP -le $CURRENT_STEP ] ; then 141 if [ $START_STEP -le $CURRENT_STEP ] ; then
133 echo ">>> Step $CURRENT_STEP: Find the git \ 142 echo ">>> Step $CURRENT_STEP: Find the git \
134 revisions associated with the patches." 143 revisions associated with the patches."
135 current=0 144 current=0
136 for REVISION in "$@" ; do 145 for REVISION in "$@" ; do
137 NEXT_HASH=$(git svn find-rev "r$REVISION" svn/bleeding_edge) 146 NEXT_HASH=$(git svn find-rev "r$REVISION" svn/bleeding_edge)
138 [[ -n "$NEXT_HASH" ]] \ 147 [[ -n "$NEXT_HASH" ]] \
139 || die "Cannot determine git hash for r$REVISION" 148 || die "Cannot determine git hash for r$REVISION"
140 PATCH_COMMIT_HASHES[$current]="$NEXT_HASH" 149 PATCH_COMMIT_HASHES[$current]="$NEXT_HASH"
141 [[ -n "$REVISION_LIST" ]] && REVISION_LIST="$REVISION_LIST," 150 [[ -n "$REVISION_LIST" ]] && REVISION_LIST="$REVISION_LIST,"
142 REVISION_LIST="$REVISION_LIST r$REVISION" 151 REVISION_LIST="$REVISION_LIST r$REVISION"
143 let current+=1 152 let current+=1
144 done 153 done
145 if [ -n "$REVISION_LIST" ] ; then 154 if [ -n "$REVISION_LIST" ] ; then
146 if [ -n "$REVERSE_PATCH" ] ; then 155 if [ -n "$REVERSE_PATCH" ] ; then
147 NEW_COMMIT_MSG="Rollback of$REVISION_LIST in $MERGE_TO_BRANCH branch." 156 if [ $REVERT_FROM_BLEEDING_EDGE -eq 0 ] ; then
157 NEW_COMMIT_MSG="Rollback of$REVISION_LIST in $MERGE_TO_BRANCH branch."
158 else
159 NEW_COMMIT_MSG="Revert$REVISION_LIST."
160 fi
148 else 161 else
149 NEW_COMMIT_MSG="Merged$REVISION_LIST into $MERGE_TO_BRANCH branch." 162 NEW_COMMIT_MSG="Merged$REVISION_LIST into $MERGE_TO_BRANCH branch."
150 fi; 163 fi;
151 fi; 164 fi;
152 165
153 echo "$NEW_COMMIT_MSG" > $COMMITMSG_FILE 166 echo "$NEW_COMMIT_MSG" > $COMMITMSG_FILE
154 echo "" >> $COMMITMSG_FILE 167 echo "" >> $COMMITMSG_FILE
155 for HASH in ${PATCH_COMMIT_HASHES[@]} ; do 168 for HASH in ${PATCH_COMMIT_HASHES[@]} ; do
156 PATCH_MERGE_DESCRIPTION=$(git log -1 --format=%s $HASH) 169 PATCH_MERGE_DESCRIPTION=$(git log -1 --format=%s $HASH)
157 echo "$PATCH_MERGE_DESCRIPTION" >> $COMMITMSG_FILE 170 echo "$PATCH_MERGE_DESCRIPTION" >> $COMMITMSG_FILE
(...skipping 24 matching lines...) Expand all
182 echo "Applying patch for $HASH to $MERGE_TO_BRANCH..." 195 echo "Applying patch for $HASH to $MERGE_TO_BRANCH..."
183 git log -1 -p $HASH > "$TEMPORARY_PATCH_FILE" 196 git log -1 -p $HASH > "$TEMPORARY_PATCH_FILE"
184 apply_patch "$TEMPORARY_PATCH_FILE" 197 apply_patch "$TEMPORARY_PATCH_FILE"
185 done 198 done
186 if [ -n "$EXTRA_PATCH" ] ; then 199 if [ -n "$EXTRA_PATCH" ] ; then
187 apply_patch "$EXTRA_PATCH" 200 apply_patch "$EXTRA_PATCH"
188 fi 201 fi
189 fi 202 fi
190 203
191 let CURRENT_STEP+=1 204 let CURRENT_STEP+=1
192 if [ $START_STEP -le $CURRENT_STEP ] ; then 205 if [ $START_STEP -le $CURRENT_STEP ] && [ $REVERT_FROM_BLEEDING_EDGE -eq 0 ] ; t hen
193 echo ">>> Step $CURRENT_STEP: Prepare $VERSION_FILE." 206 echo ">>> Step $CURRENT_STEP: Prepare $VERSION_FILE."
194 # These version numbers are used again for creating the tag 207 # These version numbers are used again for creating the tag
195 read_and_persist_version 208 read_and_persist_version
196 fi 209 fi
197 210
198 let CURRENT_STEP+=1 211 let CURRENT_STEP+=1
199 if [ $START_STEP -le $CURRENT_STEP ] ; then 212 if [ $START_STEP -le $CURRENT_STEP ] && [ $REVERT_FROM_BLEEDING_EDGE -eq 0 ] ; t hen
200 echo ">>> Step $CURRENT_STEP: Increment version number." 213 echo ">>> Step $CURRENT_STEP: Increment version number."
201 restore_if_unset "PATCH" 214 restore_if_unset "PATCH"
202 NEWPATCH=$(($PATCH + 1)) 215 NEWPATCH=$(($PATCH + 1))
203 confirm "Automatically increment PATCH_LEVEL? (Saying 'n' will fire up \ 216 confirm "Automatically increment PATCH_LEVEL? (Saying 'n' will fire up \
204 your EDITOR on $VERSION_FILE so you can make arbitrary changes. When \ 217 your EDITOR on $VERSION_FILE so you can make arbitrary changes. When \
205 you're done, save the file and exit your EDITOR.)" 218 you're done, save the file and exit your EDITOR.)"
206 if [ $? -eq 0 ] ; then 219 if [ $? -eq 0 ] ; then
207 echo $NEWPATCH $VERSION_FILE 220 echo $NEWPATCH $VERSION_FILE
208 sed -e "/#define PATCH_LEVEL/s/[0-9]*$/$NEWPATCH/" \ 221 sed -e "/#define PATCH_LEVEL/s/[0-9]*$/$NEWPATCH/" \
209 -i.bak "$VERSION_FILE" || die "Could not increment patch level" 222 -i.bak "$VERSION_FILE" || die "Could not increment patch level"
(...skipping 17 matching lines...) Expand all
227 echo ">>> Step $CURRENT_STEP: Commit to the repository." 240 echo ">>> Step $CURRENT_STEP: Commit to the repository."
228 restore_if_unset "MERGE_TO_BRANCH" 241 restore_if_unset "MERGE_TO_BRANCH"
229 git checkout $BRANCHNAME \ 242 git checkout $BRANCHNAME \
230 || die "cannot ensure that the current branch is $BRANCHNAME" 243 || die "cannot ensure that the current branch is $BRANCHNAME"
231 wait_for_lgtm 244 wait_for_lgtm
232 PRESUBMIT_TREE_CHECK="skip" git cl dcommit \ 245 PRESUBMIT_TREE_CHECK="skip" git cl dcommit \
233 || die "failed to commit to $MERGE_TO_BRANCH" 246 || die "failed to commit to $MERGE_TO_BRANCH"
234 fi 247 fi
235 248
236 let CURRENT_STEP+=1 249 let CURRENT_STEP+=1
237 if [ $START_STEP -le $CURRENT_STEP ] ; then 250 if [ $START_STEP -le $CURRENT_STEP ] && [ $REVERT_FROM_BLEEDING_EDGE -eq 0 ] ; t hen
238 echo ">>> Step $CURRENT_STEP: Determine svn commit revision" 251 echo ">>> Step $CURRENT_STEP: Determine svn commit revision"
239 restore_if_unset "NEW_COMMIT_MSG" 252 restore_if_unset "NEW_COMMIT_MSG"
240 restore_if_unset "MERGE_TO_BRANCH" 253 restore_if_unset "MERGE_TO_BRANCH"
241 git svn fetch || die "'git svn fetch' failed." 254 git svn fetch || die "'git svn fetch' failed."
242 COMMIT_HASH=$(git log -1 --format=%H --grep="$NEW_COMMIT_MSG" \ 255 COMMIT_HASH=$(git log -1 --format=%H --grep="$NEW_COMMIT_MSG" \
243 svn/$MERGE_TO_BRANCH) 256 svn/$MERGE_TO_BRANCH)
244 [[ -z "$COMMIT_HASH" ]] && die "Unable to map git commit to svn revision" 257 [[ -z "$COMMIT_HASH" ]] && die "Unable to map git commit to svn revision"
245 SVN_REVISION=$(git svn find-rev $COMMIT_HASH) 258 SVN_REVISION=$(git svn find-rev $COMMIT_HASH)
246 echo "subversion revision number is r$SVN_REVISION" 259 echo "subversion revision number is r$SVN_REVISION"
247 persist "SVN_REVISION" 260 persist "SVN_REVISION"
248 fi 261 fi
249 262
250 let CURRENT_STEP+=1 263 let CURRENT_STEP+=1
251 if [ $START_STEP -le $CURRENT_STEP ] ; then 264 if [ $START_STEP -le $CURRENT_STEP ] && [ $REVERT_FROM_BLEEDING_EDGE -eq 0 ] ; t hen
252 echo ">>> Step $CURRENT_STEP: Create the tag." 265 echo ">>> Step $CURRENT_STEP: Create the tag."
253 restore_if_unset "SVN_REVISION" 266 restore_if_unset "SVN_REVISION"
254 restore_version_if_unset "NEW" 267 restore_version_if_unset "NEW"
255 echo "Creating tag svn/tags/$NEWMAJOR.$NEWMINOR.$NEWBUILD.$NEWPATCH" 268 echo "Creating tag svn/tags/$NEWMAJOR.$NEWMINOR.$NEWBUILD.$NEWPATCH"
256 if [ "$MERGE_TO_BRANCH" == "trunk" ] ; then 269 if [ "$MERGE_TO_BRANCH" == "trunk" ] ; then
257 TO_URL="$MERGE_TO_BRANCH" 270 TO_URL="$MERGE_TO_BRANCH"
258 else 271 else
259 TO_URL="branches/$MERGE_TO_BRANCH" 272 TO_URL="branches/$MERGE_TO_BRANCH"
260 fi 273 fi
261 svn copy -r $SVN_REVISION \ 274 svn copy -r $SVN_REVISION \
262 https://v8.googlecode.com/svn/$TO_URL \ 275 https://v8.googlecode.com/svn/$TO_URL \
263 https://v8.googlecode.com/svn/tags/$NEWMAJOR.$NEWMINOR.$NEWBUILD.$NEWPATCH \ 276 https://v8.googlecode.com/svn/tags/$NEWMAJOR.$NEWMINOR.$NEWBUILD.$NEWPATCH \
264 -m "Tagging version $NEWMAJOR.$NEWMINOR.$NEWBUILD.$NEWPATCH" 277 -m "Tagging version $NEWMAJOR.$NEWMINOR.$NEWBUILD.$NEWPATCH"
265 persist "TO_URL" 278 persist "TO_URL"
266 fi 279 fi
267 280
268 let CURRENT_STEP+=1 281 let CURRENT_STEP+=1
269 if [ $START_STEP -le $CURRENT_STEP ] ; then 282 if [ $START_STEP -le $CURRENT_STEP ] ; then
270 echo ">>> Step $CURRENT_STEP: Cleanup." 283 echo ">>> Step $CURRENT_STEP: Cleanup."
271 restore_if_unset "SVN_REVISION" 284 restore_if_unset "SVN_REVISION"
272 restore_if_unset "TO_URL" 285 restore_if_unset "TO_URL"
273 restore_if_unset "REVISION_LIST" 286 restore_if_unset "REVISION_LIST"
274 restore_version_if_unset "NEW" 287 restore_version_if_unset "NEW"
275 common_cleanup 288 common_cleanup
276 echo "*** SUMMARY ***" 289 if [ $REVERT_FROM_BLEEDING_EDGE==0 ] ; then
277 echo "version: $NEWMAJOR.$NEWMINOR.$NEWBUILD.$NEWPATCH" 290 echo "*** SUMMARY ***"
278 echo "branch: $TO_URL" 291 echo "version: $NEWMAJOR.$NEWMINOR.$NEWBUILD.$NEWPATCH"
279 echo "svn revision: $SVN_REVISION" 292 echo "branch: $TO_URL"
280 [[ -n "$REVISION_LIST" ]] && echo "patches:$REVISION_LIST" 293 echo "svn revision: $SVN_REVISION"
294 [[ -n "$REVISION_LIST" ]] && echo "patches:$REVISION_LIST"
295 fi
281 fi 296 fi
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698