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

Side by Side Diff: tools/dartium/start_dartium_roll.sh

Issue 2976303002: Remove Dartium for TIP of origin/master (Closed)
Patch Set: Updated Created 3 years, 5 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
« no previous file with comments | « tools/dartium/generate_patches.sh ('k') | tools/dartium/test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env bash
2
3 set -e
4
5 # Requirements:
6 # sudo apt-get install xclip
7
8
9 # e.g. 1908 ROLL
10 # ./start_dartium_roll.sh --verbose --directory ~/dartium-roll --old-branch 1847 --old-revision 251904 --new-branch 1908 --new-revision 259084 --chrome --pre-ro ll
11 # ./start_dartium_roll.sh --verbose --directory ~/dartium-roll --old-branch 1847 --old-revision 251904 --new-branch 1908 --new-revision 259084 --chrome --roll
12 # ./start_dartium_roll.sh --verbose --directory ~/dartium-roll --old-branch 1847 --old-revision 251904 --new-branch 1908 --new-revision 259084 --chrome --info
13 # ./start_dartium_roll.sh --verbose --directory ~/dartium-roll --old-branch 1847 --old-revision 167304 --new-branch 1908 --new-revision 169907 --blink --pre-rol l
14 # ./start_dartium_roll.sh --verbose --directory ~/dartium-roll --old-branch 1847 --old-revision 167304 --new-branch 1908 --new-revision 169907 --blink --roll
15 # ./start_dartium_roll.sh --verbose --directory ~/dartium-roll --old-branch 1847 --old-revision 167304 --new-branch 1908 --new-revision 169907 --blink --info
16
17 # e.g., 1916 ROLL
18 # ~/./start_dartium_roll.sh --verbose --directory /media/TB/dartium-1916 --old-b ranch 1908 --old-revision 259084 --new-branch 1916 --new-revision 260298 --chrom e --pre-roll
19
20 # ~/./start_dartium_roll.sh --verbose --directory /media/TB/dartium-1916 --old-b ranch 1908 --old-revision 169907 --new-branch 1916 --new-revision 170313 --blink --pre-roll
21
22 E_INVALID_ARG=128
23
24 function usage {
25 echo "Usage: $0 [--options]"
26 echo "Options:"
27 echo " --[no-]verbose: display information about each step"
28 echo " --directory base: base directory of local git repository"
29 echo " (e.g., ~/dartium-roll implies directory"
30 echo " ~/dartium-roll/src and"
31 echo " ~/dartium-roll/src/third_party/WebKit)**"
32 echo " --chrome: for the Chrome branch (not with --blink)**"
33 echo " --blink: for the Blink branch (not with --chrome)**"
34 echo " --old-branch name: name of previous true branch (e.g., use 1847 "
35 echo " for version 34.0.1847.92) *"
36 echo " --old-revision revision: revision of base trunk for $OLD version *"
37 echo " --new-branch name: name of new true branch to create *"
38 echo " --new-revision revision: revision of base trunk for new branch *"
39 echo " --pre-roll: display commands to prepare for the roll"
40 echo " --roll: display Git commands to execute for creating "
41 echo " branches for the roll"
42 echo " --info: display hashes for $BASE and $LAST on each"
43 echo " branch (stripped$OLD, trunkdata$OLD, and"
44 echo " trunkdata$NEW)"
45 echo " --help: this message"
46 echo
47 echo "* - required"
48 echo
49 echo "* Script will prompt interactively if options not given."
50 echo "** Argument must be specified."
51 echo
52 exit 1
53 }
54
55
56 function verbose_message {
57 if [ "$do_verbose" = 1 ]; then
58 if [ "${1}" = "" ]; then
59 echo
60 else
61 echo -e "...${1}..."
62 fi
63 fi
64 }
65
66
67 # Does the file src/.git/config contains the added lines pointing to the chrome
68 # remote dart$OLD and dart$NEW branches for src/ (e.g, dart1847 and dart1908):
69 #
70 # [svn-remote "dart$OLD"]
71 # url = svn://svn.chromium.org/chrome/branches/dart/$OLD/src
72 # fetch = :refs/remotes/dart1847
73 # [svn-remote "dart$NEW"]
74 # url = svn://svn.chromium.org/chrome/branches/dart/$NEW/src
75 # fetch = :refs/remotes/dart1908
76 #
77 # and does the file src/third_party/WebKit/.git/config contains the added lines
78 # for blink:
79 #
80 # [svn-remote "dart$OLD"]
81 # url = svn://svn.chromium.org/blink/branches/dart/$OLD/src
82 # fetch = :refs/remotes/dart1847
83 # [svn-remote "dart$NEW"]
84 # url = svn://svn.chromium.org/blink/branches/dart/$NEW/src
85 # fetch = :refs/remotes/dart1908
86 #
87 function validate_remotes {
88 verbose_message "Validating Remotes"
89
90 if [ "$do_which" = "chrome" ]; then
91 # Ensure remote for old Dartium release exist (e.g., remotes/dart1847)
92 remote_dart_last=$(git branch -a | grep "remotes/dart${do_old_branch}")
93 # Ensure remote for new Dartium release exist (e.g., remotes/dart1908)
94 remote_dart_new=$(git branch -a | grep "remotes/dart${do_new_branch}")
95 if [ "$remote_dart_last" = "" ]; then
96 $(display_error "missing old remotes/dart${do_old_branch}")
97 exit -1
98 fi
99 if [ "$remote_dart_new" = "" ]; then
100 $(display_error "missing new remotes/dart${do_new_branch}")
101 exit -1
102 fi
103 elif [ "$do_which" = "blink" ]; then
104 # Ensure remote for old Dartium release exist (e.g., remotes/dart1847)
105 remote_dart_last=$(git branch -a | grep "remotes/blink-svn/${do_old_branch}" )
106 # Ensure remote for new Dartium release exist (e.g., remotes/dart1908)
107 remote_dart_new=$(git branch -a | grep "remotes/blink-svn/multivm-${do_new_b ranch}")
108
109 if [ "$remote_dart_last" = "" ]; then
110 $(display_error "missing old remotes/blink-svn/${do_old_branch}")
111 exit -1
112 fi
113 if [ "$remote_dart_new" = "" ]; then
114 $(display_error "missing new remotes/blink-svn/multivm-${do_new_branch}")
115 exit -1
116 fi
117 else
118 $(display_error "--chrome or --blink must be specified")
119 exit -1
120 fi
121 }
122
123 function stripped_exist {
124 local branch_name=$(git branch --no-color --list $(stripped_name) | sed 's/^[ \t\*]*//')
125 echo $branch_name
126 }
127
128 # Does the branch trunkdart$OLD or trunkdart$NEW exist where $OLD is previous
129 # branch (e.g. 1847) and $NEW is new branch to roll (e.g., 1908)
130 # $(trunk_exist ${do_old_branch}) or $(trunk_exist ${do_new_branch})
131 # Strip out the spaces and * (implies current branch) then return the branch nam e.
132 function trunk_exist {
133 local branch_name=$(git branch --list --no-color trunkdart${1} | sed 's/^[ \t\ *]*//' | tail -n 1)
134 echo $branch_name
135 }
136
137 function validate_repository {
138 verbose_message "Validating Repository"
139
140 strip_branch=${stripped_name}
141
142 # Validate that branches exist.
143 stripped_found=${stripped_exist}
144 old_branch_found=$(trunk_exist ${do_old_branch})
145 new_branch_found=$(trunk_exist ${do_new_branch})
146
147 if [ "$stripped_found" != "" ]; then
148 $(display_error "branch ${strip_branch} already exist")
149 exit -1
150 fi
151
152 if [ "$old_branch_found" != "" ]; then
153 $(display_error "branch trunkdart${do_old_branch} already exist")
154 exit -1
155 fi
156
157 if [ "$new_branch_found" != "" ]; then
158 $(display_error "branch trunkdart${do_new_branch} already exist")
159 exit -1
160 fi
161 }
162
163 function display_error() {
164 echo -e "\n\e[1;31mERROR: ${1}\e[0m\n" >&2
165 exit 1
166 }
167
168
169 # Given a revision number $1 return the trunk's hash code for that revision.
170 function hash_trunk_revision {
171 # Chrome trunk hash code for [NewChromeCommit]
172 hash_trunk=$(git log master --grep=src@${1} --pretty=format:'%H' -n 1)
173 }
174
175
176 # Return the last revision for a branch. Used by new trunk roll for the
177 # DEPS file for the last revision to use during build.
178 function last_revision() {
179 echo $(git svn log ${1} --oneline -1 | cut -d '|' -f1 | sed "s/r//")
180 }
181
182
183 # Return the branch for strippedOOOO use bash line:
184 # $(stripped_name)
185 function stripped_name {
186 echo "stripped${do_old_branch}"
187 }
188
189
190 # Give a branch name return the trunk release for that branch.
191 function trunkdart_name {
192 echo "trunkdart${1}"
193 }
194
195
196 # Compute the hash codes for the previous branch hash_base is the first commit
197 # and hash_last is final commit.
198 function hash_codes_base_last {
199 # Get the first commit for previous Dartium roll on chrome branch.
200 hash_base=$(git rev-list ${1} --pretty=format:'%H' | tail -n 1)
201
202 # Get the last commit for previous Dartium roll on chrome branch.
203 hash_last=$(git log ${1} --pretty=format:'%H' -1)
204 }
205
206
207 # Compute the hash codes for the previous branch hash_base is the first commit
208 # and hash_last is final commit.
209 function hash_codes_base2_last2 {
210 # Get the last commit for previous Dartium roll on chrome branch.
211 hash_last2=$(git log ${1} --pretty=format:'%H' -1)
212
213 local search
214 if [ "$do_which" = "chrome" ]; then
215 search="chrome/trunk/src@${do_old_revision}"
216 else
217 search="blink/branches/dart/multivm-${do_new_revision}@${do_old_revision}"
218 fi
219
220 # Get the first commit for previous Dartium roll on chrome branch.
221 hash_base2=$(git log ${1} --grep=@${do_old_revision} --pretty=format:'%H' | ta il -1)
222 }
223
224
225 # Pad right/left up to 80 spaces.
226 # Parameter $1 string to pad.
227 # Parameter $2 is max length to post-pad with spaces.
228 # Parameter $3 if specified padd to the right otherwise pad to the right.
229 # Returns string right padded with spaces.
230 function space_pad() {
231 local spaces=$(printf '%0.1s' " "{1..80})
232 local spaces_pad=${spaces:0:$2}
233 local padding=$(printf "%s" "${spaces_pad:${#1}}")
234
235 if [[ "$3" = "" ]]; then
236 # Pad to the right [default].
237 echo "${1}${padding}"
238 else
239 # Pad to the left.
240 echo "${padding}${1}"
241 fi
242 }
243
244
245 # Format the line '| URL: <url> |'.
246 # Paramter $1 - url to format
247 # Returns the formatted and space padded line for display_hashes.
248 function display_url() {
249 # Line length is 65, skipped # 9 characters at beginning '| URL: '
250 # and last character '|'. Up to 55 characters of padding.
251 local format_url=$(space_pad $1 55)
252 local valid_url=$(valid_branch_url $1)
253 if [[ "$valid_url" = "" ]]; then
254 # Error format padding is same as above remote_url 55;
255 local format_err=$(space_pad "WARNING ON TRUNK - FIX IMMEDIATELY" 55)
256 # Output in red, the problem, both lines the URL and the warning message.
257 echo -e "| URL: \e[1;31m${format_url}\e[0m|\n| \e[1;31m${format_err }\e[0m|"
258 else
259 # URL looks good.
260 echo "| URL: ${format_url}|"
261 fi
262 }
263
264
265 function display_hashes {
266 if [ "$do_info_hashes" = 1 ]; then
267 local format_which=$(space_pad $do_which 6 1)
268 stripped_branch=$(stripped_name)
269 # stripped$OLD found
270 stripped_found=$(stripped_exist)
271 if [ "$stripped_found" != "" ]; then
272 hash_codes_base_last ${stripped_branch}
273 hash_trunk_revision ${do_old_revision}
274 # Display the first/last commit hash for stripped$OLD branch and the
275 # trunk hash for $OLD@do_last_revsion.
276 echo "================================================================="
277 local format_branch=$(space_pad $stripped_branch 32 1)
278 echo "| \$OLD: ${format_which} dart${do_old_branch}@${do_old_revision}${f ormat_branch} |"
279 local remote_url=$(url_branch $stripped_branch)
280
281 # TODO(terry): Testing failure below remove before checkin
282 # local remote_url=$(url_branch "master")
283
284 echo "$(display_url $remote_url)"
285 echo "|---------------------------------------------------------------|"
286 local format_hash=$(space_pad $hash_base 51)
287 echo "| \$BASE | ${format_hash} |"
288 echo "|---------------------------------------------------------------|"
289 format_hash=$(space_pad $hash_last 51)
290 echo "| \$LAST | ${format_hash} |"
291 echo "================================================================="
292 echo
293 else
294 echo "${stripped_branch} not found"
295 echo
296 fi
297
298 # trunkdart$OLD found
299 branch_trunkdart_old=$(trunkdart_name ${do_old_branch})
300 old_branch_found=$(trunk_exist ${do_old_branch})
301 if [ "$old_branch_found" != "" ]; then
302 hash_codes_base2_last2 ${branch_trunkdart_old}
303 hash_trunk_revision ${do_old_revision}
304 # Display the first/last commit hash for trunkdart$OLD branch and the
305 # trunk hash for $OLD@do_last_revsion.
306 echo "================================================================="
307 local format_branch=$(space_pad $branch_trunkdart_old 32 1)
308 echo "| \$OLD ${format_which} dart${do_old_branch}@${do_old_revision}${f ormat_branch} |"
309 local remote_url=$(url_branch $branch_trunkdart_old)
310 echo "$(display_url $remote_url)"
311 echo "|---------------------------------------------------------------|"
312 local format_base2=$(space_pad $hash_base2 51)
313 echo "| \$BASE2 | ${format_base2} |"
314 echo "|---------------------------------------------------------------|"
315 local format_last2=$(space_pad $hash_last2 51)
316 echo "| \$LAST2 | ${format_last2} |"
317 echo "================================================================="
318 echo
319 else
320 echo "${branch_trunkdart_old} not found"
321 echo
322 fi
323
324 # trunkdart$NEW found
325 branch_trunkdart_new=$(trunkdart_name ${do_new_branch})
326 new_branch_found=$(trunk_exist ${do_new_branch})
327 if [ "$new_branch_found" != "" ]; then
328 hash_trunk_revision ${do_new_revision}
329 # Display the trunk hash for $NEW@do_new_revsion.
330 echo "================================================================="
331 local format_branch=$(space_pad $branch_trunkdart_new 32 1)
332 echo "| \$NEW ${format_which} dart${do_new_branch}@${do_new_revision}${f ormat_branch} |"
333 local remote_url=$(url_branch $branch_trunkdart_new)
334 echo "$(display_url $remote_url)"
335 echo "|---------------------------------------------------------------|"
336 local revision=$(last_revision $branch_trunkdart_new)
337 local format_revision=$(space_pad $revision 43)
338 echo "| last revision | ${format_revision} |"
339 echo "================================================================="
340 echo
341 else
342 echo "${branch_trunkdart_new} not found"
343 echo
344 fi
345 fi
346 }
347
348
349 function switch_branch() {
350 $(git checkout ${1} --quiet)
351 local curr_branch=$(git name-rev --name-only HEAD)
352 if [[ "$curr_branch" != "$1" ]]; then
353 $(display_error "Unable to switch to branch $1 - pending commits/add?")
354 exit -1
355 fi
356 echo $curr_branch
357 }
358
359
360 # Check that the branch is not pointing to either blink or chrome trunk.
361 # These branches should be pointing to either:
362 # svn://svn.chromium.org/chrome/branches/dart/NNNN
363 # svn://svn.chromium.org/blink/branches/dart/NNNN
364 #
365 # $1 parameter - branch-name to make current branch and check repository
366 # name.
367 function check_branch() {
368 local old_branch=$(git name-rev --name-only HEAD)
369 local curr_branch=$(switch_branch $1)
370 local trunk_url;
371
372 if [ "$do_which" = "chrome" ]; then
373 # Chrome
374 trunk_url='Committing to svn://svn.chromium.org/chrome/trunk/src ...'
375 elif [ "$do_which" = "blink" ]; then
376 # Blink
377 trunk_url='Committing to svn://svn.chromium.org/blink/trunk ...'
378 else
379 $(display_error "Neither blink or chrome specified")
380 exit -1
381 fi
382
383 local remote_commit=$(git svn dcommit --dry-run | head -1 | grep "${trunk_url} ")
384
385 curr_branch=$(switch_branch $old_branch)
386 if [[ "$curr_branch" != "$old_branch" ]]; then
387 $(display_error "Unable to switch back to original branch ${old_branch}")
388 exit -1
389 fi
390
391 if [[ "$remote_commit" != "" ]]; then
392 $(display_error "Branch ${1} is NOT pointing to the Dart branch repository b ut pointing to trunk.")
393 exit -1
394 fi
395
396 echo "Local branch '${1}' is based on the remote branch/dart repository."
397 }
398
399
400 # Given an URL of a remote repository passed as parameter $1 (e.g., from
401 # url_branch function) return the URL passed in if valid or return empty
402 # string "".
403 function valid_branch_url() {
404 # Compute what the remote repository should be:
405 # svn://svn.chromium.org/${do_which}/branches/dart/${do_old_branch}/src
406 # e.g., svn://svn.chromium.org/chrome/branches/dart/1847/src
407 # or blink:
408 # svn://svn.chromium.org/blink/branches/dart/${do_old_branch}
409 # e.g., svn://svn.chromium.org/blink/branches/dart/1847
410 local src_dir=""
411 if [[ "$do_which" = "chrome" ]]; then
412 src_dir="/src"
413 fi
414 local old_remote="svn://svn.chromium.org/${do_which}/branches/dart/${do_old_br anch}${src_dir}"
415 local new_remote="svn://svn.chromium.org/${do_which}/branches/dart/${do_new_br anch}${src_dir}"
416
417 echo $(echo "$1" | grep -e "${old_remote}" -e "${new_remote}")
418 }
419
420
421 # Returns the remote repository URL associated with a branch.
422 # Parameter $1 is the branch name.
423 function url_branch() {
424 local old_branch=$(git name-rev --name-only HEAD)
425 local curr_branch=$(switch_branch $1)
426
427 local remote_commit=$(git svn dcommit --dry-run | head -1 | sed 's/Committing to //' | sed 's/ ...//')
428
429 curr_branch=$(switch_branch $old_branch)
430
431 echo "${remote_commit}"
432 }
433
434
435 # Ensure that any created branches (stripped$OLD, trunkdart$OLD and
436 # trunkdart$NEW) are not pointing to either the blink or chrome trunks.
437 function validate_branches() {
438 # stripped branch
439 local stripped_found=$(stripped_exist)
440 if [ "$stripped_found" != "" ]; then
441 local branch_name=$(stripped_name)
442 local check_result=$(check_branch ${branch_name})
443 printf "%s\n" "$check_result"
444 fi
445
446 # trunkdart$OLD
447 local branch_trunkdart_old=$(trunkdart_name ${do_old_branch})
448 local old_branch_found=$(trunk_exist ${do_old_branch})
449 if [ "$old_branch_found" != "" ]; then
450 local check_result=$(check_branch $branch_trunkdart_old)
451 printf "%s\n" "$check_result"
452 fi
453
454 # trunkdart$NEW
455 local branch_trunkdart_new=$(trunkdart_name ${do_new_branch})
456 local new_branch_found=$(trunk_exist ${do_new_branch})
457 if [ "$new_branch_found" != "" ]; then
458 local check_result=$(check_branch $branch_trunkdart_new)
459 printf "%s\n" "$check_result"
460 fi
461 }
462
463
464 function display_roll_commands() {
465 if [ "$roll_branches" = 1 ]; then
466 if [ "$do_which" = "chrome" ]; then
467 roll_chrome_commands
468 elif [ "$do_which" = "blink" ]; then
469 roll_blink_commands
470 fi
471 fi
472 }
473
474
475 # Show commands to create SVN branch folder and remote repository for new roll.
476 function display_remote_repository_creation() {
477 # TODO(terry): Use the diretory passed in instead of hard-coded dartium-NNNN
478 # TODO(terry): Should execute each command with a Y or N and command runs.
479 # TODO(terry): Echo output from commands especially clone and rebase using "OUTP UT=$(git cl rebase); echo $OUTPUT"
480 # TODO(terry): Add ability to copy to clipboard programmatically us 'echo "hi" | xclip -selection clipboard'
481 # copies hi to clipboard.
482 echo "Do the following pre-roll setup"
483 if [ "$do_which" = "chrome" ]; then
484 echo " mkdir dartium-${do_new_branch}"
485 echo " cd dartium-${do_new_branch}"
486 echo " svn mkdir -m \"Preparing Chrome 35/${do_new_branch} branch\" "\
487 "svn://svn.chromium.org/chrome/branches/dart/${do_new_branch}"
488 echo " svn cp -m \"Branching for ${do_new_branch} @${do_new_revision}\" "\
489 "svn://svn.chromium.org/chrome/trunk/src@${do_new_revision} "\
490 "svn://svn.chromium.org/chrome/branches/dart/${do_new_branch}/src"
491 echo " git svn clone -r241107 svn://svn.chromium.org/chrome/trunk/src src"
492 echo
493 echo " cd src"
494 echo " git cl rebase"
495 echo
496 echo "-----After rebase finishes-----"
497 echo
498 echo " 1. Add the below lines to src/.git/config"
499 echo
500 echo "[svn-remote \"dart${do_old_branch}\"]"
501 echo " url = svn://svn.chromium.org/chrome/branches/dart/${do_old_branc h}/src"
502 echo " fetch = :refs/remotes/dart${do_old_branch}"
503 echo "[svn-remote \"dart${do_new_branch}\"]"
504 echo " url = svn://svn.chromium.org/chrome/branches/dart/${do_new_branc h}/src"
505 echo " fetch = :refs/remotes/dart${do_new_branch}"
506 echo
507 echo " 2. Get the code"
508 echo
509 echo " cd src"
510 echo " git svn fetch dart${do_old_branch} && git svn fetch dart${do_new_b ranch}"
511 elif [ "$do_which" = "blink" ]; then
512 echo " Directory dartium-${do_new_branch} exists."
513 echo " cd dartium-${do_new_branch}"
514 echo " svn cp -m \"Branching ${do_new_branch} @${do_new_revision}\" "\
515 "svn://svn.chromium.org/blink/trunk@${do_new_revision} "\
516 "svn://svn.chromium.org/blink/branches/dart/${do_new_branch}"
517
518 echo " git svn clone --trunk=trunk --branches=branches/dart"\
519 " --prefix=blink-svn/ -r165883:HEAD " \
520 "svn://svn.chromium.org/blink src/third_party/WebKit"
521 echo
522 echo " cd src/third_party/WebKit"
523 echo " git cl rebase"
524 echo
525 echo "-----After rebase finishes-----"
526 echo
527 echo " 1. Add the below lines to src/third_party/WebKit/.git/config"
528 echo
529 echo "[svn-remote \"dart${do_old_branch}\"]"
530 echo " url = svn://svn.chromium.org/blink/branches/dart/${do_old_branch }"
531 echo " fetch = :refs/remotes/dart${do_old_branch}"
532 echo "[svn-remote \"dart${do_new_branch}\"]"
533 echo " url = svn://svn.chromium.org/blink/branches/dart/${do_new_branch }"
534 echo " fetch = :refs/remotes/dart${do_new_branch}"
535 echo
536 echo " 2. Get the code"
537 echo
538 echo " cd src/third_party/WebKit"
539 #TODO(terry): Should the fetch be remotes/blink-svn/multivm-${do_new_branch}
540 echo " git svn fetch dart${do_old_branch} && git svn fetch dart${do_new_b ranch}"
541 fi
542 }
543
544 # Displays each of the 3 steps, of GIT commands, to create the
545 # branches for a Dartium roll.
546 #
547 # Givin the following Dartium roll information:
548 # Previous Dartium roll 1847 @251094 ($OLD)
549 # New Dartium roll to make 1908 @ 259084 ($NEW)
550 #
551 # Three branches will be created a stripped[$OLD], trunkdart[$OLD]
552 # and trunkdart[$NEW].
553 #
554 # |==============================================|
555 # | $OLD | 1847 |
556 # |----------------------------------------------|
557 # | $OLD_REV | 251094 |
558 # |----------------------------------------------|
559 # | $NEW | 1908 |
560 # |----------------------------------------------|
561 # | $NEW_REV | 259084 |
562 # |==============================================|
563 #
564 # stripped$OLD - Branch with upstream patches stripped out.
565 # trunkdart$OLD - Branch with all patches for $OLD.
566 # trunkdart$NEW - Branch of a new Chromium/Blink release with
567 # cherry-picked $OLD commits from trunkdart$OLD.
568 #
569 # stripped$OLD, trunkdart$OLD points the SVN remote repository
570 #
571 # svn://svn.chromium.org/chrome/branches/dart/1847/src
572 #
573 # trunkdart$NEW points to the SVN remote repository
574 # svn://svn.chromium.org/chrome/branches/dart/1908/src
575 #
576 # STEP 1.
577 # -------
578 # Create the stripped$OLD:
579 # > git checkout -b stripped$OLD dart$OLD
580 # > git rebase -i $BASE
581 #
582 # e.g., git checkout -b stripped1847 dart1847
583 # git rebase -i 3345f6a26911beda2ed352e887549bc514acb4bd
584 #
585 # Rebasing with -i will launch an editor, show all commits after $BASE and let
586 # you interactively remove any upstream commits from trunk. Upstream commits
587 # have a format of "Incrementing VERSION to 32.0.1847.78". Then save and quit
588 # the editor.
589 #
590 # $BASE and $LAST are computed by this script and is returned in the
591 # 'git rebase -i <hash-code>' command.
592 #
593 # NOTE: How $BASE and $LAST are computed:
594 # ---------------------------------------
595 # $BASE, first commit in $OLD, is computed by:
596 # > git rev-list stripped1847 --pretty=format:'%H' | tail -n 1
597 # Return a GIT hash code e.g., 3345f6a26911beda2ed352e887549bc514acb4bd
598 #
599 # $LAST, last commit in $NEW, is computed by:
600 # > git log stripped1847 --pretty=format:'%H' -1
601 # Return a GIT hash code e.g., 44d12cd4b7e041f8d06f8735f1af08abb66825c4
602 #
603 # STEP 2.
604 # -------
605 # Create the trunkdart$OLD e.g.,
606 # > git checkout -b trunkdart$OLD $BASE
607 # > git cherry-pick $BASE..$LAST
608 #
609 # e.g., git checkout -b trunkdart1847
610 #
611 # Create branch trunkdart$OLD and reapplies all Dart-related work on $OLD (from
612 # the stripped branch created in Step1.). This cherry-pick should not have any
613 # conflicts as you are rebasing onto exactly the same source code layout.
614 #
615 # STEP 3.
616 # -------
617 # Create the branch for $NEW (trunkdart$NEW):
618 # > git checkout -b trunkdart$NEW dart$NEW
619 # > git cherry-pick $BASE2..$LAST2
620 #
621 # Important points trunkdart$NEW is attached to the remote SVN repository create d
622 # in pre-steps.
623 #
624 # e.g., git checkout -b trunkdart1908 dart1908
625 # git cherry-pick xxxx..xxxx
626 #
627 # $BASE2 should be the same as $BASE to validate with:
628 #
629 # > git log trunkdart$OLD --grep=@$OLD_REV --pretty=format:'%H' | tail -1
630 #
631 # e.g., git log trunkdart1847 --grep=251094 --pretty=format:'%H' | tail -1
632 # 3345f6a26911beda2ed352e887549bc514acb4bd
633 #
634 # $LAST2 is the last commit in $OLD in trunkdart$OLD computed by:
635 #
636 # > git log trunkdart$OLD --pretty=format:'%H' -1
637 #
638 # e.g., > git log trunkdart1847 --pretty=format:'%H' -1
639 # 2549d8ecd211ee6fed6699d70f319e077b425be4
640 #
641 # The we'll cherry-pick commits from $OLD.
642 # e.g.,
643 # > git cherry-pick 3345f6a26911beda2ed352e887549bc514acb4bd..2549d8ecd211ee6f ed6699d70f319e077b425be4
644 #
645 # Cherry picking is an iterative process. Each commit in the $OLD branch is
646 # applied to the $NEW branch any conflicts will need to fixed.
647 #
648 # Fix each file conflict(s) in a particular commit:
649 #
650 # > vim <filename>
651 # > git add <filename>
652 #
653 # When all file conflicts for a particular commit are done then:
654 #
655 # > git commit -a -m "Merged $OLD"
656 #
657 # Continue the original cherry-picking
658 # > git cherry-pick --continue
659 #
660 #
661 # ********************************************************************
662 # * IMPORTANT: *
663 # ********************************************************************
664 #
665 # When all commits are made to our new trunk (trunkdart$NEW). Then try an
666 # initial dcommit with the --dry-run option.
667 #
668 # > git svn dcommit --dry-run
669 #
670 # e.g., git svn dcommit --dry-run
671 # Committing to svn://svn.chromium.org/chrome/branches/dart/1908/src . ..
672 # diff-tree 48e85b5f247696c432d9dbb55c37f88f4df8a06a~1 48e85b5f247696c 432d9dbb55c37f88f4df8a06a
673 # ...
674 #
675 # It is important to check the first line "Committing to " the repository
676 # should be the new remote SVN e.g., svn://svn.chromium.org/chrome/branches/dart /1908/src ...
677 #
678 # IT SHOULD NOT BE "svn://svn.chromium.org/chrome/trunk/src ..." this will
679 # dcommit the changes to the chrome trunk and break the chromium build.
680 #
681 function roll_chrome_commands() {
682 stripped_found=$(stripped_exist)
683 old_branch_found=$(trunk_exist ${do_old_branch})
684 new_branch_found=$(trunk_exist ${do_new_branch})
685
686 echo
687 echo "================================================"
688 echo "| git commands to run: |"
689 echo "================================================"
690
691 remoteOld=dart${do_old_branch}
692 strip_branch=$(stripped_name)
693
694 if [ "$stripped_found" = "" ]; then
695 echo "------------------ Step 1. ---------------------"
696 echo
697
698 # Git command to create stripped old branch.
699 echo "git checkout -b ${strip_branch} ${remoteOld}"
700
701 # Get hashes for base for do_old_branch.
702 hash_codes_base_last ${remoteOld}
703
704 echo "git rebase -i ${hash_base}"
705 echo
706 elif [ "$old_branch_found" = "" ]; then
707 echo "------------------ Step 2. ---------------------"
708 echo
709
710 # Get hashes for base, last and base hash from trunk for the last branch.
711 hash_codes_base_last ${strip_branch}
712
713 # Git command to create old branch with only changes from base to last
714 # commits for that branch. Checkout based on stripped$OLD first commit
715 # $BASE.
716 branch_trunkdart_old=$(trunkdart_name ${do_old_branch})
717 echo "git checkout -b ${branch_trunkdart_old} ${hash_base}"
718
719 echo "git cherry-pick ${hash_base}..${hash_last}"
720 echo
721 elif [ "$new_branch_found" = "" ]; then
722 echo "------------------ Step 3. ---------------------"
723 echo
724
725 # Git command to create new branch to roll.
726 branch_trunkdart_new=$(trunkdart_name ${do_new_branch})
727
728 # get base and last commit hashes of the trunkdart$OLD
729 hash_codes_base2_last2 ${branch_trunkdart_old}
730
731 echo "git checkout -b ${branch_trunkdart_new} ${remoteOld}"
732
733 echo "git cherry-pick ${hash_base2}..${hash_last2}"
734 echo
735 else
736 echo "===== Nothing to do - Roll setup complete. ====="
737 fi
738
739 echo "================================================"
740 }
741
742
743 function roll_blink_commands() {
744 stripped_found=$(stripped_exist)
745 old_branch_found=$(trunk_exist ${do_old_branch})
746 new_branch_found=$(trunk_exist ${do_new_branch})
747
748 echo
749 echo "================================================"
750 echo "| git commands to run: |"
751 echo "================================================"
752
753 remoteOld=dart${do_old_branch}
754 strip_branch=$(stripped_name)
755
756 if [ "$stripped_found" = "" ]; then
757 echo "------------------ Step 1. ---------------------"
758 echo
759
760 # Git command to create stripped old branch.
761 echo "git checkout -b ${strip_branch} ${remoteOld}"
762
763 # Get hashes for base dir do_old_branch.
764 hash_codes_base_last ${remoteOld}
765
766 eho "git rebase -i ${hash_base}"
767 echo
768 elif [ "$old_branch_found" = "" ]; then
769 echo "------------------ Step 2. ---------------------"
770 echo
771
772 # Get hashes for base, last and base hash from trunk for the last branch.
773 hash_codes_base_last ${strip_branch}
774
775 # Git command to create old branch with only changes from base to last
776 # commits for that branch. Checkout based on stripped$OLD first commit
777 # $BASE.
778 branch_trunkdart_old=$(trunkdart_name ${do_old_branch})
779 echo "git checkout -b ${branch_trunkdart_old} ${hash_base}"
780
781 echo "git cherry-pick ${hash_base}..${hash_last}"
782 echo
783 elif [ "$new_branch_found" = "" ]; then
784 echo "------------------ Step 3. ---------------------"
785 echo
786
787
788 # Git command to create new branch to roll.
789 branch_trunkdart_new=$(trunkdart_name ${do_new_branch})
790
791 # get base and last commit hashes of the trunkdart$OLD
792 hash_codes_base2_last2 ${branch_trunkdart_old}
793
794 echo "git checkout -b ${branch_trunkdart_new} ${remoteOld}"
795
796 echo "git cherry-pick ${hash_base2}..${hash_last2}"
797 echo
798 else
799 echo "===== Nothing to do - Roll setup complete. ====="
800 fi
801
802 echo "================================================"
803 }
804
805
806 # checkout strippedOOOO and trunkdartNNNN
807 create_branches=0
808
809 do_info_hashes=0
810
811 base_dir=""
812
813 # Display the pre-roll commands; if specified nothing else is displayed.
814 do_pre_roll=0
815
816 # which branch chrome or blink
817 do_which=""
818
819 # Display detail information about all major steps
820 do_verbose=0
821
822 # $OLD branch
823 do_old_branch=""
824 do_old_revision=""
825
826 # $NEW branch
827 do_new_branch=""
828 do_new_revision=""
829
830 curr_switch=""
831 for var in "$@"
832 do
833 case "$var" in
834 --help)
835 usage
836 exit
837 ;;
838 --verbose)
839 do_verbose=1
840 curr_switch=""
841 ;;
842 --no-verbose)
843 do_verbose=0
844 curr_switch=""
845 ;;
846 --chrome)
847 if [ "$do_which" != "" ]; then
848 $(display_error "--chrome can not be specified with --blink")
849 exit $E_INVALID_ARG
850 fi
851 do_which="chrome"
852 curr_switch=""
853 ;;
854 --blink)
855 if [ "$do_which" != "" ]; then
856 $(display_error "--blink can not be specified with --chrome")
857 exit $E_INVALID_ARG
858 fi
859 do_which="blink"
860 curr_switch=""
861 ;;
862 --pre-roll)
863 do_pre_roll=1
864 curr_switch=""
865 ;;
866 --roll)
867 roll_branches=1
868 curr_switch=""
869 ;;
870 --info)
871 do_info_hashes=1
872 curr_switch=""
873 ;;
874 --directory)
875 curr_switch="base-directory" # takes an argument.
876 ;;
877 --old-branch)
878 curr_switch="old-branch" # takes an argument.
879 ;;
880 --new-branch)
881 curr_switch="new-branch" # takes an argument.
882 ;;
883 --old-revision)
884 curr_switch="old-revision" # takes an argument.
885 ;;
886 --new-revision)
887 curr_switch="new-revision" # takes an argument.
888 ;;
889 *)
890 prefix=${var:0:2}
891 if [ "$prefix" = "--" ]; then
892 $(display_error "unexpected switch ${var}")
893 exit $E_INVALID_ARG
894 fi
895 case "$curr_switch" in
896 base-directory)
897 base_dir="${var}"
898 ;;
899 old-branch)
900 do_old_branch="${var}"
901 ;;
902 old-revision)
903 do_old_revision="${var}"
904 ;;
905 new-branch)
906 do_new_branch="${var}"
907 ;;
908 new-revision)
909 do_new_revision="${var}"
910 ;;
911 *)
912 if [ "$curr_switch" != "" ]; then
913 $(display_error "unexpected paramter for ${curr_switch}")
914 exit $E_INVALID_ARG
915 else
916 $(display_error "unexpected switch ${var}")
917 exit $E_INVALID_ARG
918 fi
919 ;;
920 esac
921 curr_switch=""
922 ;;
923 esac
924 done
925
926 # Insure that everything is known otherwise prompt information.
927 if [ "$base_dir" = "" ]; then
928 echo "--directory switch must be specified."
929 exit $E_INVALID_ARG
930 fi
931
932 if [ "$do_which" == "" ]; then
933 echo "--chrome or --blink switch must be specified."
934 exit $E_INVALID_ARG
935 fi
936
937 if [ "$do_old_branch" = "" ]; then
938 echo "Enter LAST ${do_which} true branch (e.g., Chrome version 34.0.1847.92 tr ue branch is 1847)"
939 read do_old_branch
940 fi
941
942 if [ "$do_old_revision" = "" ]; then
943 echo "Enter LAST ${do_which} base trunk revision #"
944 read do_old_revision
945 fi
946
947 if [ "$do_new_branch" = "" ]; then
948 echo "Enter NEW ${do_which} true branch (e.g., Chrome version 35.0.1908.4 true branch is 1908)"
949 read do_new_branch
950 fi
951
952 if [ "$do_new_revision" = "" ]; then
953 echo "Enter NEW ${do_which} base trunk revision #"
954 read do_new_revision
955 fi
956
957 echo
958 echo "Rolling new branch ${do_new_branch}@${do_new_revision}"
959
960 verbose_message
961 verbose_message "Previous branch ${do_old_branch}@${do_old_revision}"
962 verbose_message "New branch ${do_new_branch}@${do_new_revision}"
963 verbose_message
964
965 if [[ "$do_pre_roll" = "1" ]]; then
966 display_remote_repository_creation
967 exit 1
968 fi
969
970 pushd . > /dev/null
971
972 if [ "$base_dir" != "" ]; then
973 cd ${base_dir}
974 fi
975
976 cd src
977
978 if [ "$do_which" = "blink" ]; then
979 cd third_party/WebKit
980 fi
981
982 # Disable ^C and ^Z while running script.
983 trap '' INT
984 trap '' TSTP
985
986 validate_remotes
987
988 display_roll_commands
989
990 display_hashes
991
992 # Insure that all local branches for the roll are NOT based on the chrome or
993 # blink trunks.
994 validate_branches
995
996 # Re-enable ^C and ^Z.
997 trap - INT
998 trap - TSTP
999
1000 popd > /dev/null
1001
OLDNEW
« no previous file with comments | « tools/dartium/generate_patches.sh ('k') | tools/dartium/test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698