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