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

Side by Side Diff: tools/push-to-trunk.sh

Issue 9463041: Refactored push-to-trunk.sh and merge-to-branch.sh. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fixes for push-to-trunk.sh Created 8 years, 9 months 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 | « tools/merge-to-branch.sh ('k') | 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 2011 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
11 # disclaimer in the documentation and/or other materials provided 11 # disclaimer in the documentation and/or other materials provided
12 # with the distribution. 12 # with the distribution.
(...skipping 11 matching lines...) Expand all
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 28
29 29
30 ########## Global variable definitions 30 ########## Global variable definitions
31 31
32 BRANCHNAME=prepare-push 32 BRANCHNAME=prepare-push
33 TRUNKBRANCH=trunk-push 33 TRUNKBRANCH=trunk-push
34 TEMP_BRANCH=v8-push-to-trunk-script-temporary-branch
35 VERSION_FILE="src/version.cc"
36 PERSISTFILE_BASENAME=/tmp/v8-push-to-trunk-tempfile 34 PERSISTFILE_BASENAME=/tmp/v8-push-to-trunk-tempfile
37 CHANGELOG_ENTRY_FILE="$PERSISTFILE_BASENAME-changelog-entry" 35 CHROME_PATH=
38 PATCH_FILE="$PERSISTFILE_BASENAME-patch"
39 COMMITMSG_FILE="$PERSISTFILE_BASENAME-commitmsg"
40 TOUCHED_FILES_FILE="$PERSISTFILE_BASENAME-touched-files"
41 TRUNK_REVISION_FILE="$PERSISTFILE_BASENAME-trunkrevision"
42 STEP=0
43
44 36
45 ########## Function definitions 37 ########## Function definitions
46 38
39 source $(dirname $BASH_SOURCE)/common-includes.sh
40
47 usage() { 41 usage() {
48 cat << EOF 42 cat << EOF
49 usage: $0 OPTIONS 43 usage: $0 OPTIONS
50 44
51 Performs the necessary steps for a V8 push to trunk. Only works for \ 45 Performs the necessary steps for a V8 push to trunk. Only works for \
52 git checkouts. 46 git checkouts.
53 47
54 OPTIONS: 48 OPTIONS:
55 -h Show this message 49 -h Show this message
56 -s Specify the step where to start work. Default: 0. 50 -s Specify the step where to start work. Default: 0.
57 -l Manually specify the git commit ID of the last push to trunk. 51 -l Manually specify the git commit ID of the last push to trunk.
52 -c Specify the path to your Chromium src/ directory to automate the
53 V8 roll.
58 EOF 54 EOF
59 } 55 }
60 56
61 die() {
62 [[ -n "$1" ]] && echo "Error: $1"
63 echo "Exiting."
64 exit 1
65 }
66
67 confirm() {
68 echo -n "$1 [Y/n] "
69 read ANSWER
70 if [[ -z "$ANSWER" || "$ANSWER" == "Y" || "$ANSWER" == "y" ]] ; then
71 return 0
72 else
73 return 1
74 fi
75 }
76
77 delete_branch() {
78 local MATCH=$(git branch | grep $1 | awk '{print $NF}' )
79 if [ "$MATCH" == "$1" ] ; then
80 confirm "Branch $1 exists, do you want to delete it?"
81 if [ $? -eq 0 ] ; then
82 git branch -D $1 || die "Deleting branch '$1' failed."
83 echo "Branch $1 deleted."
84 else
85 die "Can't continue. Please delete branch $1 and try again."
86 fi
87 fi
88 }
89
90 # Persist and restore variables to support canceling/resuming execution
91 # of this script.
92 persist() {
93 local VARNAME=$1
94 local FILE="$PERSISTFILE_BASENAME-$VARNAME"
95 echo "${!VARNAME}" > $FILE
96 }
97
98 restore() {
99 local VARNAME=$1
100 local FILE="$PERSISTFILE_BASENAME-$VARNAME"
101 local VALUE="$(cat $FILE)"
102 eval "$VARNAME=\"$VALUE\""
103 }
104
105 restore_if_unset() {
106 local VARNAME=$1
107 [[ -z "${!VARNAME}" ]] && restore "$VARNAME"
108 [[ -z "${!VARNAME}" ]] && die "Variable '$VARNAME' could not be restored."
109 }
110
111
112 ########## Option parsing 57 ########## Option parsing
113 58
114 while getopts ":hs:l:" OPTION ; do 59 while getopts ":hs:l:c:" OPTION ; do
115 case $OPTION in 60 case $OPTION in
116 h) usage 61 h) usage
117 exit 0 62 exit 0
118 ;; 63 ;;
119 s) STEP=$OPTARG 64 s) START_STEP=$OPTARG
120 ;; 65 ;;
121 l) LASTPUSH=$OPTARG 66 l) LASTPUSH=$OPTARG
122 ;; 67 ;;
68 c) CHROME_PATH=$OPTARG
69 ;;
123 ?) echo "Illegal option: -$OPTARG" 70 ?) echo "Illegal option: -$OPTARG"
124 usage 71 usage
125 exit 1 72 exit 1
126 ;; 73 ;;
127 esac 74 esac
128 done 75 done
129 76
130 77
131 ########## Regular workflow 78 ########## Regular workflow
132 79
133 # Cancel if this is not a git checkout. 80 initial_environment_checks
134 [[ -d .git ]] \
135 || die "This is not a git checkout, this script won't work for you."
136 81
137 # Cancel if EDITOR is unset or not executable. 82 if [ $START_STEP -le $CURRENT_STEP ] ; then
138 [[ -n "$EDITOR" && -x "$(which $EDITOR)" ]] \ 83 echo ">>> Step $CURRENT_STEP: Preparation"
139 || die "Please set your EDITOR environment variable, you'll need it." 84 common_prepare
140
141 if [ $STEP -le 0 ] ; then
142 echo ">>> Step 0: Preparation"
143 # Check for a clean workdir.
144 [[ -z "$(git status -s -uno)" ]] \
145 || die "Workspace is not clean. Please commit or undo your changes."
146
147 # Persist current branch.
148 CURRENT_BRANCH=$(git status -s -b -uno | grep "^##" | awk '{print $2}')
149 persist "CURRENT_BRANCH"
150 # Get ahold of a safe temporary branch and check it out.
151 if [ "$CURRENT_BRANCH" != "$TEMP_BRANCH" ] ; then
152 delete_branch $TEMP_BRANCH
153 git checkout -b $TEMP_BRANCH
154 fi
155 # Delete branches if they exist.
156 delete_branch $BRANCHNAME
157 delete_branch $TRUNKBRANCH 85 delete_branch $TRUNKBRANCH
158 fi 86 fi
159 87
160 if [ $STEP -le 1 ] ; then 88 let CURRENT_STEP+=1
161 echo ">>> Step 1: Fetch unfetched revisions." 89 if [ $START_STEP -le $CURRENT_STEP ] ; then
162 git svn fetch || die "'git svn fetch' failed." 90 echo ">>> Step $CURRENT_STEP: Create a fresh branch."
163 fi
164
165 if [ $STEP -le 2 ] ; then
166 echo ">>> Step 2: Create a fresh branch."
167 git checkout -b $BRANCHNAME svn/bleeding_edge \ 91 git checkout -b $BRANCHNAME svn/bleeding_edge \
168 || die "Creating branch $BRANCHNAME failed." 92 || die "Creating branch $BRANCHNAME failed."
169 fi 93 fi
170 94
171 if [ $STEP -le 3 ] ; then 95 let CURRENT_STEP+=1
172 echo ">>> Step 3: Detect commit ID of last push to trunk." 96 if [ $START_STEP -le $CURRENT_STEP ] ; then
97 echo ">>> Step $CURRENT_STEP: Detect commit ID of last push to trunk."
173 [[ -n "$LASTPUSH" ]] || LASTPUSH=$(git log -1 --format=%H ChangeLog) 98 [[ -n "$LASTPUSH" ]] || LASTPUSH=$(git log -1 --format=%H ChangeLog)
174 LOOP=1 99 LOOP=1
175 while [ $LOOP -eq 1 ] ; do 100 while [ $LOOP -eq 1 ] ; do
176 # Print assumed commit, circumventing git's pager. 101 # Print assumed commit, circumventing git's pager.
177 git log -1 $LASTPUSH | cat 102 git log -1 $LASTPUSH | cat
178 confirm "Is the commit printed above the last push to trunk?" 103 confirm "Is the commit printed above the last push to trunk?"
179 if [ $? -eq 0 ] ; then 104 if [ $? -eq 0 ] ; then
180 LOOP=0 105 LOOP=0
181 else 106 else
182 LASTPUSH=$(git log -1 --format=%H $LASTPUSH^ ChangeLog) 107 LASTPUSH=$(git log -1 --format=%H $LASTPUSH^ ChangeLog)
183 fi 108 fi
184 done 109 done
185 persist "LASTPUSH" 110 persist "LASTPUSH"
186 fi 111 fi
187 112
188 if [ $STEP -le 4 ] ; then 113 let CURRENT_STEP+=1
189 echo ">>> Step 4: Prepare raw ChangeLog entry." 114 if [ $START_STEP -le $CURRENT_STEP ] ; then
190 # These version numbers are used again later for the trunk commit. 115 echo ">>> Step $CURRENT_STEP: Prepare raw ChangeLog entry."
191 MAJOR=$(grep "#define MAJOR_VERSION" "$VERSION_FILE" | awk '{print $NF}') 116 # These version numbers are used again later for the trunk commit.
192 persist "MAJOR" 117 read_and_persist_version
193 MINOR=$(grep "#define MINOR_VERSION" "$VERSION_FILE" | awk '{print $NF}')
194 persist "MINOR"
195 BUILD=$(grep "#define BUILD_NUMBER" "$VERSION_FILE" | awk '{print $NF}')
196 persist "BUILD"
197 118
198 DATE=$(date +%Y-%m-%d) 119 DATE=$(date +%Y-%m-%d)
199 persist "DATE" 120 persist "DATE"
200 echo "$DATE: Version $MAJOR.$MINOR.$BUILD" > "$CHANGELOG_ENTRY_FILE" 121 echo "$DATE: Version $MAJOR.$MINOR.$BUILD" > "$CHANGELOG_ENTRY_FILE"
201 echo "" >> "$CHANGELOG_ENTRY_FILE" 122 echo "" >> "$CHANGELOG_ENTRY_FILE"
202 COMMITS=$(git log $LASTPUSH..HEAD --format=%H) 123 COMMITS=$(git log $LASTPUSH..HEAD --format=%H)
203 for commit in $COMMITS ; do 124 for commit in $COMMITS ; do
204 # Get the commit's title line. 125 # Get the commit's title line.
205 git log -1 $commit --format="%w(80,8,8)%s" >> "$CHANGELOG_ENTRY_FILE" 126 git log -1 $commit --format="%w(80,8,8)%s" >> "$CHANGELOG_ENTRY_FILE"
206 # Grep for "BUG=xxxx" lines in the commit message and convert them to 127 # Grep for "BUG=xxxx" lines in the commit message and convert them to
207 # "(issue xxxx)". 128 # "(issue xxxx)".
208 git log -1 $commit --format="%B" \ 129 git log -1 $commit --format="%B" \
209 | grep "^BUG=" | grep -v "BUG=$" \ 130 | grep "^BUG=" | grep -v "BUG=$" | grep -v "BUG=none$" \
210 | sed -e 's/^/ /' \ 131 | sed -e 's/^/ /' \
211 | sed -e 's/BUG=v8:\(.*\)$/(issue \1)/' \ 132 | sed -e 's/BUG=v8:\(.*\)$/(issue \1)/' \
212 | sed -e 's/BUG=\(.*\)$/(Chromium issue \1)/' \ 133 | sed -e 's/BUG=\(.*\)$/(Chromium issue \1)/' \
213 >> "$CHANGELOG_ENTRY_FILE" 134 >> "$CHANGELOG_ENTRY_FILE"
214 # Append the commit's author for reference. 135 # Append the commit's author for reference.
215 git log -1 $commit --format="%w(80,8,8)(%an)" >> "$CHANGELOG_ENTRY_FILE" 136 git log -1 $commit --format="%w(80,8,8)(%an)" >> "$CHANGELOG_ENTRY_FILE"
216 echo "" >> "$CHANGELOG_ENTRY_FILE" 137 echo "" >> "$CHANGELOG_ENTRY_FILE"
217 done 138 done
139 echo " Performance and stability improvements on all platforms." \
140 >> "$CHANGELOG_ENTRY_FILE"
218 fi 141 fi
219 142
220 if [ $STEP -le 5 ] ; then 143 let CURRENT_STEP+=1
221 echo ">>> Step 5: Edit ChangeLog entry." 144 if [ $START_STEP -le $CURRENT_STEP ] ; then
145 echo ">>> Step $CURRENT_STEP: Edit ChangeLog entry."
222 echo -n "Please press <Return> to have your EDITOR open the ChangeLog entry, \ 146 echo -n "Please press <Return> to have your EDITOR open the ChangeLog entry, \
223 then edit its contents to your liking. When you're done, save the file and \ 147 then edit its contents to your liking. When you're done, save the file and \
224 exit your EDITOR. " 148 exit your EDITOR. "
225 read ANSWER 149 read ANSWER
226 $EDITOR "$CHANGELOG_ENTRY_FILE" 150 $EDITOR "$CHANGELOG_ENTRY_FILE"
227 NEWCHANGELOG=$(mktemp) 151 NEWCHANGELOG=$(mktemp)
228 # Eliminate any trailing newlines by going through a shell variable. 152 # Eliminate any trailing newlines by going through a shell variable.
229 # Also (1) eliminate tabs, (2) fix too little and (3) too much indentation, 153 # Also (1) eliminate tabs, (2) fix too little and (3) too much indentation,
230 # and (4) eliminate trailing whitespace. 154 # and (4) eliminate trailing whitespace.
231 CHANGELOGENTRY=$(cat "$CHANGELOG_ENTRY_FILE" \ 155 CHANGELOGENTRY=$(cat "$CHANGELOG_ENTRY_FILE" \
232 | sed -e 's/\t/ /g' \ 156 | sed -e 's/\t/ /g' \
233 | sed -e 's/^ \{1,7\}\([^ ]\)/ \1/g' \ 157 | sed -e 's/^ \{1,7\}\([^ ]\)/ \1/g' \
234 | sed -e 's/^ \{9,80\}\([^ ]\)/ \1/g' \ 158 | sed -e 's/^ \{9,80\}\([^ ]\)/ \1/g' \
235 | sed -e 's/ \+$//') 159 | sed -e 's/ \+$//')
236 [[ -n "$CHANGELOGENTRY" ]] || die "Empty ChangeLog entry." 160 [[ -n "$CHANGELOGENTRY" ]] || die "Empty ChangeLog entry."
237 echo "$CHANGELOGENTRY" > "$NEWCHANGELOG" 161 echo "$CHANGELOGENTRY" > "$NEWCHANGELOG"
238 echo "" >> "$NEWCHANGELOG" # Explicitly insert two empty lines. 162 echo "" >> "$NEWCHANGELOG" # Explicitly insert two empty lines.
239 echo "" >> "$NEWCHANGELOG" 163 echo "" >> "$NEWCHANGELOG"
240 cat ChangeLog >> "$NEWCHANGELOG" 164 cat ChangeLog >> "$NEWCHANGELOG"
241 mv "$NEWCHANGELOG" ChangeLog 165 mv "$NEWCHANGELOG" ChangeLog
242 fi 166 fi
243 167
244 if [ $STEP -le 6 ] ; then 168 let CURRENT_STEP+=1
245 echo ">>> Step 6: Increment version number." 169 if [ $START_STEP -le $CURRENT_STEP ] ; then
170 echo ">>> Step $CURRENT_STEP: Increment version number."
246 restore_if_unset "BUILD" 171 restore_if_unset "BUILD"
247 NEWBUILD=$(($BUILD + 1)) 172 NEWBUILD=$(($BUILD + 1))
248 confirm "Automatically increment BUILD_NUMBER? (Saying 'n' will fire up \ 173 confirm "Automatically increment BUILD_NUMBER? (Saying 'n' will fire up \
249 your EDITOR on $VERSION_FILE so you can make arbitrary changes. When \ 174 your EDITOR on $VERSION_FILE so you can make arbitrary changes. When \
250 you're done, save the file and exit your EDITOR.)" 175 you're done, save the file and exit your EDITOR.)"
251 if [ $? -eq 0 ] ; then 176 if [ $? -eq 0 ] ; then
252 sed -e "/#define BUILD_NUMBER/s/[0-9]*$/$NEWBUILD/" \ 177 sed -e "/#define BUILD_NUMBER/s/[0-9]*$/$NEWBUILD/" \
253 -i "$VERSION_FILE" 178 -i "$VERSION_FILE"
254 else 179 else
255 $EDITOR "$VERSION_FILE" 180 $EDITOR "$VERSION_FILE"
256 fi 181 fi
257 NEWMAJOR=$(grep "#define MAJOR_VERSION" "$VERSION_FILE" | awk '{print $NF}') 182 read_and_persist_version "NEW"
258 persist "NEWMAJOR"
259 NEWMINOR=$(grep "#define MINOR_VERSION" "$VERSION_FILE" | awk '{print $NF}')
260 persist "NEWMINOR"
261 NEWBUILD=$(grep "#define BUILD_NUMBER" "$VERSION_FILE" | awk '{print $NF}')
262 persist "NEWBUILD"
263 fi 183 fi
264 184
265 if [ $STEP -le 7 ] ; then 185 let CURRENT_STEP+=1
266 echo ">>> Step 7: Commit to local branch." 186 if [ $START_STEP -le $CURRENT_STEP ] ; then
267 restore_if_unset "NEWMAJOR" 187 echo ">>> Step $CURRENT_STEP: Commit to local branch."
268 restore_if_unset "NEWMINOR" 188 restore_version_if_unset "NEW"
269 restore_if_unset "NEWBUILD"
270 PREPARE_COMMIT_MSG="Prepare push to trunk. \ 189 PREPARE_COMMIT_MSG="Prepare push to trunk. \
271 Now working on version $NEWMAJOR.$NEWMINOR.$NEWBUILD." 190 Now working on version $NEWMAJOR.$NEWMINOR.$NEWBUILD."
272 persist "PREPARE_COMMIT_MSG" 191 persist "PREPARE_COMMIT_MSG"
273 git commit -a -m "$PREPARE_COMMIT_MSG" \ 192 git commit -a -m "$PREPARE_COMMIT_MSG" \
274 || die "'git commit -a' failed." 193 || die "'git commit -a' failed."
275 fi 194 fi
276 195
277 if [ $STEP -le 8 ] ; then 196 upload_step
278 echo ">>> Step 8: Upload for code review."
279 echo -n "Please enter the email address of a V8 reviewer for your patch: "
280 read REVIEWER
281 git cl upload -r $REVIEWER --send-mail \
282 || die "'git cl upload' failed, please try again."
283 fi
284 197
285 if [ $STEP -le 9 ] ; then 198 let CURRENT_STEP+=1
286 echo ">>> Step 9: Commit to the repository." 199 if [ $START_STEP -le $CURRENT_STEP ] ; then
287 echo "Please wait for an LGTM, then type \"LGTM<Return>\" to commit your \ 200 echo ">>> Step $CURRENT_STEP: Commit to the repository."
288 change. (If you need to iterate on the patch, do so in another shell. Do not \ 201 wait_for_lgtm
289 modify the existing local commit's commit message.)"
290 unset ANSWER
291 while [ "$ANSWER" != "LGTM" ] ; do
292 [[ -n "$ANSWER" ]] && echo "That was not 'LGTM'."
293 echo -n "> "
294 read ANSWER
295 done
296 # Re-read the ChangeLog entry (to pick up possible changes). 202 # Re-read the ChangeLog entry (to pick up possible changes).
297 cat ChangeLog | awk --posix '{ 203 cat ChangeLog | awk --posix '{
298 if ($0 ~ /^[0-9]{4}-[0-9]{2}-[0-9]{2}:/) { 204 if ($0 ~ /^[0-9]{4}-[0-9]{2}-[0-9]{2}:/) {
299 if (in_firstblock == 1) { 205 if (in_firstblock == 1) {
300 exit 0; 206 exit 0;
301 } else { 207 } else {
302 in_firstblock = 1; 208 in_firstblock = 1;
303 } 209 }
304 }; 210 };
305 print $0; 211 print $0;
306 }' > "$CHANGELOG_ENTRY_FILE" 212 }' > "$CHANGELOG_ENTRY_FILE"
307 git cl dcommit || die "'git cl dcommit' failed, please try again." 213 git cl dcommit || die "'git cl dcommit' failed, please try again."
308 fi 214 fi
309 215
310 if [ $STEP -le 10 ] ; then 216 let CURRENT_STEP+=1
311 echo ">>> Step 10: Fetch straggler commits that sneaked in between \ 217 if [ $START_STEP -le $CURRENT_STEP ] ; then
312 steps 1 and 9." 218 echo ">>> Step $CURRENT_STEP: Fetch straggler commits that sneaked in \
219 since this script was started."
313 git svn fetch || die "'git svn fetch' failed." 220 git svn fetch || die "'git svn fetch' failed."
314 git checkout svn/bleeding_edge 221 git checkout svn/bleeding_edge
315 restore_if_unset "PREPARE_COMMIT_MSG" 222 restore_if_unset "PREPARE_COMMIT_MSG"
316 PREPARE_COMMIT_HASH=$(git log -1 --format=%H --grep="$PREPARE_COMMIT_MSG") 223 PREPARE_COMMIT_HASH=$(git log -1 --format=%H --grep="$PREPARE_COMMIT_MSG")
317 persist "PREPARE_COMMIT_HASH" 224 persist "PREPARE_COMMIT_HASH"
318 fi 225 fi
319 226
320 if [ $STEP -le 11 ] ; then 227 let CURRENT_STEP+=1
321 echo ">>> Step 11: Squash commits into one." 228 if [ $START_STEP -le $CURRENT_STEP ] ; then
229 echo ">>> Step $CURRENT_STEP: Squash commits into one."
322 # Instead of relying on "git rebase -i", we'll just create a diff, because 230 # Instead of relying on "git rebase -i", we'll just create a diff, because
323 # that's easier to automate. 231 # that's easier to automate.
324 restore_if_unset "PREPARE_COMMIT_HASH" 232 restore_if_unset "PREPARE_COMMIT_HASH"
325 git diff svn/trunk $PREPARE_COMMIT_HASH > "$PATCH_FILE" 233 git diff svn/trunk $PREPARE_COMMIT_HASH > "$PATCH_FILE"
326 # Convert the ChangeLog entry to commit message format: 234 # Convert the ChangeLog entry to commit message format:
327 # - remove date 235 # - remove date
328 # - remove indentation 236 # - remove indentation
329 # - merge paragraphs into single long lines, keeping empty lines between them. 237 # - merge paragraphs into single long lines, keeping empty lines between them.
330 restore_if_unset "DATE" 238 restore_if_unset "DATE"
331 CHANGELOGENTRY=$(cat "$CHANGELOG_ENTRY_FILE") 239 CHANGELOGENTRY=$(cat "$CHANGELOG_ENTRY_FILE")
332 echo "$CHANGELOGENTRY" \ 240 echo "$CHANGELOGENTRY" \
333 | sed -e "s/^$DATE: //" \ 241 | sed -e "s/^$DATE: //" \
334 | sed -e 's/^ *//' \ 242 | sed -e 's/^ *//' \
335 | awk '{ 243 | awk '{
336 if (need_space == 1) { 244 if (need_space == 1) {
337 printf(" "); 245 printf(" ");
338 }; 246 };
339 printf("%s", $0); 247 printf("%s", $0);
340 if ($0 ~ /^$/) { 248 if ($0 ~ /^$/) {
341 printf("\n\n"); 249 printf("\n\n");
342 need_space = 0; 250 need_space = 0;
343 } else { 251 } else {
344 need_space = 1; 252 need_space = 1;
345 } 253 }
346 }' > "$COMMITMSG_FILE" || die "Commit message editing failed." 254 }' > "$COMMITMSG_FILE" || die "Commit message editing failed."
347 LOOP=1
348 while [ $LOOP -eq 1 ] ; do
349 echo "This is the trunk commit message:"
350 echo "--------------------"
351 cat "$COMMITMSG_FILE"
352 echo -e "\n--------------------"
353 confirm "Does this look good to you? (Saying 'n' will fire up your \
354 EDITOR so you can change the commit message. When you're done, save the \
355 file and exit your EDITOR.)"
356 if [ $? -eq 0 ] ; then
357 LOOP=0
358 else
359 $EDITOR "$COMMITMSG_FILE"
360 fi
361 done
362 rm -f "$CHANGELOG_ENTRY_FILE" 255 rm -f "$CHANGELOG_ENTRY_FILE"
363 fi 256 fi
364 257
365 if [ $STEP -le 12 ] ; then 258 let CURRENT_STEP+=1
366 echo ">>> Step 12: Create a new branch from trunk." 259 if [ $START_STEP -le $CURRENT_STEP ] ; then
260 echo ">>> Step $CURRENT_STEP: Create a new branch from trunk."
367 git checkout -b $TRUNKBRANCH svn/trunk \ 261 git checkout -b $TRUNKBRANCH svn/trunk \
368 || die "Checking out a new branch '$TRUNKBRANCH' failed." 262 || die "Checking out a new branch '$TRUNKBRANCH' failed."
369 fi 263 fi
370 264
371 if [ $STEP -le 13 ] ; then 265 let CURRENT_STEP+=1
372 echo ">>> Step 13: Apply squashed changes." 266 if [ $START_STEP -le $CURRENT_STEP ] ; then
373 patch -p1 < "$PATCH_FILE" | tee >(awk '{print $NF}' >> "$TOUCHED_FILES_FILE") 267 echo ">>> Step $CURRENT_STEP: Apply squashed changes."
374 [[ $? -eq 0 ]] || die "Applying the patch to trunk failed." 268 rm -f "$TOUCHED_FILES_FILE"
375 # Stage added and modified files. 269 apply_patch "$PATCH_FILE"
376 TOUCHED_FILES=$(cat "$TOUCHED_FILES_FILE") 270 stage_files
377 for FILE in $TOUCHED_FILES ; do
378 git add "$FILE"
379 done
380 # Stage deleted files.
381 DELETED_FILES=$(git status -s -uno --porcelain | grep "^ D" \
382 | awk '{print $NF}')
383 for FILE in $DELETED_FILES ; do
384 git rm "$FILE"
385 done
386 rm -f "$PATCH_FILE" 271 rm -f "$PATCH_FILE"
387 rm -f "$TOUCHED_FILES_FILE"
388 fi 272 fi
389 273
390 if [ $STEP -le 14 ] ; then 274 let CURRENT_STEP+=1
391 echo ">>> Step 14: Set correct version for trunk." 275 if [ $START_STEP -le $CURRENT_STEP ] ; then
392 restore_if_unset "MAJOR" 276 echo ">>> Step $CURRENT_STEP: Set correct version for trunk."
393 restore_if_unset "MINOR" 277 restore_version_if_unset
394 restore_if_unset "BUILD"
395 sed -e "/#define MAJOR_VERSION/s/[0-9]*$/$MAJOR/" \ 278 sed -e "/#define MAJOR_VERSION/s/[0-9]*$/$MAJOR/" \
396 -e "/#define MINOR_VERSION/s/[0-9]*$/$MINOR/" \ 279 -e "/#define MINOR_VERSION/s/[0-9]*$/$MINOR/" \
397 -e "/#define BUILD_NUMBER/s/[0-9]*$/$BUILD/" \ 280 -e "/#define BUILD_NUMBER/s/[0-9]*$/$BUILD/" \
398 -e "/#define PATCH_LEVEL/s/[0-9]*$/0/" \ 281 -e "/#define PATCH_LEVEL/s/[0-9]*$/0/" \
399 -e "/#define IS_CANDIDATE_VERSION/s/[0-9]*$/0/" \ 282 -e "/#define IS_CANDIDATE_VERSION/s/[0-9]*$/0/" \
400 -i "$VERSION_FILE" || die "Patching $VERSION_FILE failed." 283 -i "$VERSION_FILE" || die "Patching $VERSION_FILE failed."
401 fi 284 fi
402 285
403 if [ $STEP -le 15 ] ; then 286 let CURRENT_STEP+=1
404 echo ">>> Step 15: Commit to local trunk branch." 287 if [ $START_STEP -le $CURRENT_STEP ] ; then
288 echo ">>> Step $CURRENT_STEP: Commit to local trunk branch."
405 git add "$VERSION_FILE" 289 git add "$VERSION_FILE"
406 git commit -F "$COMMITMSG_FILE" || die "'git commit' failed." 290 git commit -F "$COMMITMSG_FILE" || die "'git commit' failed."
407 rm -f "$COMMITMSG_FILE" 291 rm -f "$COMMITMSG_FILE"
408 fi 292 fi
409 293
410 if [ $STEP -le 16 ] ; then 294 let CURRENT_STEP+=1
411 echo ">>> Step 16: Sanity check." 295 if [ $START_STEP -le $CURRENT_STEP ] ; then
296 echo ">>> Step $CURRENT_STEP: Sanity check."
412 confirm "Please check if your local checkout is sane: Inspect $VERSION_FILE, \ 297 confirm "Please check if your local checkout is sane: Inspect $VERSION_FILE, \
413 compile, run tests. Do you want to commit this new trunk revision to the \ 298 compile, run tests. Do you want to commit this new trunk revision to the \
414 repository?" 299 repository?"
415 [[ $? -eq 0 ]] || die "Execution canceled." 300 [[ $? -eq 0 ]] || die "Execution canceled."
416 fi 301 fi
417 302
418 if [ $STEP -le 17 ] ; then 303 let CURRENT_STEP+=1
419 echo ">>> Step 17. Commit to SVN." 304 if [ $START_STEP -le $CURRENT_STEP ] ; then
305 echo ">>> Step $CURRENT_STEP: Commit to SVN."
420 git svn dcommit | tee >(grep -E "^Committed r[0-9]+" \ 306 git svn dcommit | tee >(grep -E "^Committed r[0-9]+" \
421 | sed -e 's/^Committed r\([0-9]\+\)/\1/' \ 307 | sed -e 's/^Committed r\([0-9]\+\)/\1/' \
422 > "$TRUNK_REVISION_FILE") \ 308 > "$TRUNK_REVISION_FILE") \
423 || die "'git svn dcommit' failed." 309 || die "'git svn dcommit' failed."
310 TRUNK_REVISION=$(cat "$TRUNK_REVISION_FILE")
311 persist "TRUNK_REVISION"
312 rm -f "$TRUNK_REVISION_FILE"
424 fi 313 fi
425 314
426 if [ $STEP -le 18 ] ; then 315 let CURRENT_STEP+=1
427 echo ">>> Step 18: Tag the new revision." 316 if [ $START_STEP -le $CURRENT_STEP ] ; then
428 restore_if_unset "MAJOR" 317 echo ">>> Step $CURRENT_STEP: Tag the new revision."
429 restore_if_unset "MINOR" 318 restore_version_if_unset
430 restore_if_unset "BUILD"
431 git svn tag $MAJOR.$MINOR.$BUILD -m "Tagging version $MAJOR.$MINOR.$BUILD" \ 319 git svn tag $MAJOR.$MINOR.$BUILD -m "Tagging version $MAJOR.$MINOR.$BUILD" \
432 || die "'git svn tag' failed." 320 || die "'git svn tag' failed."
433 fi 321 fi
434 322
435 if [ $STEP -le 19 ] ; then 323 if [ -n "$CHROME_PATH" ] ; then
436 echo ">>> Step 19: Cleanup." 324
437 restore_if_unset "CURRENT_BRANCH" 325 let CURRENT_STEP+=1
438 git checkout -f $CURRENT_BRANCH 326 if [ $START_STEP -le $CURRENT_STEP ] ; then
439 [[ "$TEMP_BRANCH" != "$CURRENT_BRANCH" ]] && git branch -D $TEMP_BRANCH 327 echo ">>> Step $CURRENT_STEP: Switch to Chromium checkout."
440 [[ "$BRANCHNAME" != "$CURRENT_BRANCH" ]] && git branch -D $BRANCHNAME 328 V8_PATH=$(pwd)
329 persist "V8_PATH"
330 cd "$CHROME_PATH"
331 initial_environment_checks
332 # Check for a clean workdir.
333 [[ -z "$(git status -s -uno)" ]] \
334 || die "Workspace is not clean. Please commit or undo your changes."
335 fi
336
337 let CURRENT_STEP+=1
338 if [ $START_STEP -le $CURRENT_STEP ] ; then
339 echo ">>> Step $CURRENT_STEP: Update the checkout and create a new branch."
340 git checkout master || die "'git checkout master' failed."
341 git pull || die "'git pull' failed, please try again."
342 restore_if_unset "TRUNK_REVISION"
343 git checkout -b "v8-roll-$TRUNK_REVISION" \
344 || die "Failed to checkout a new branch."
345 fi
346
347 let CURRENT_STEP+=1
348 if [ $START_STEP -le $CURRENT_STEP ] ; then
349 echo ">>> Step $CURRENT_STEP: Create and upload CL."
350 # Patch DEPS file.
351 sed -e "/\"v8_revision\": /s/\"[0-9]+\"/\"$TRUNK_REVISION\"/" \
352 -i DEPS
353 restore_version_if_unset
354 echo -n "Please enter the email address of a reviewer for the roll CL: "
355 read REVIEWER
356 git commit -am "Update V8 to version $MAJOR.$MINOR.$BUILD.
357
358 TBR=$REVIEWER" || die "'git commit' failed."
359 git cl upload --send-mail --use-commit-queue \
360 || die "'git cl upload' failed, please try again."
361 echo "CL uploaded and sent to commit queue."
362 fi
363
364 let CURRENT_STEP+=1
365 if [ $START_STEP -le $CURRENT_STEP ] ; then
366 echo ">>> Step $CURRENT_STEP: Returning to V8 checkout."
367 restore_if_unset "V8_PATH"
368 cd "$V8_PATH"
369 fi
370 fi # if [ -n "$CHROME_PATH" ]
371
372 let CURRENT_STEP+=1
373 if [ $START_STEP -le $CURRENT_STEP ] ; then
374 echo ">>> Step $CURRENT_STEP: Done!"
375 restore_version_if_unset
376 restore_if_unset "TRUNK_REVISION"
377 if [ -n "$CHROME_PATH" ] ; then
378 echo "Congratulations, you have successfully created the trunk revision \
379 $MAJOR.$MINOR.$BUILD and rolled it into Chromium. Please don't forget to \
380 update the v8rel spreadsheet:"
381 else
382 echo "Congratulations, you have successfully created the trunk revision \
383 $MAJOR.$MINOR.$BUILD. Please don't forget to roll this new version into \
384 Chromium, and to update the v8rel spreadsheet:"
385 fi
386 echo -e "$MAJOR.$MINOR.$BUILD\ttrunk\t$TRUNK_REVISION"
387 common_cleanup
441 [[ "$TRUNKBRANCH" != "$CURRENT_BRANCH" ]] && git branch -D $TRUNKBRANCH 388 [[ "$TRUNKBRANCH" != "$CURRENT_BRANCH" ]] && git branch -D $TRUNKBRANCH
442 fi 389 fi
443
444 if [ $STEP -le 20 ] ; then
445 echo ">>> Step 20: Done!"
446 restore_if_unset "MAJOR"
447 restore_if_unset "MINOR"
448 restore_if_unset "BUILD"
449 echo "Congratulations, you have successfully created the trunk revision \
450 $MAJOR.$MINOR.$BUILD. Please don't forget to roll this new version into \
451 Chromium, and to update the v8rel spreadsheet:"
452 TRUNK_REVISION=$(cat "$TRUNK_REVISION_FILE")
453 echo -e "$MAJOR.$MINOR.$BUILD\ttrunk\t$TRUNK_REVISION"
454 # Clean up all temporary files.
455 rm -f "$PERSISTFILE_BASENAME"*
456 fi
OLDNEW
« no previous file with comments | « tools/merge-to-branch.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698