| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 # Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
| 3 # | 3 # |
| 4 # Use of this source code is governed by a BSD-style license | 4 # Use of this source code is governed by a BSD-style license |
| 5 # that can be found in the LICENSE file in the root of the source | 5 # that can be found in the LICENSE file in the root of the source |
| 6 # tree. An additional intellectual property rights grant can be found | 6 # tree. An additional intellectual property rights grant can be found |
| 7 # in the file PATENTS. All contributing project authors may | 7 # in the file PATENTS. All contributing project authors may |
| 8 # be found in the AUTHORS file in the root of the source tree. | 8 # be found in the AUTHORS file in the root of the source tree. |
| 9 | 9 |
| 10 """Script to roll chromium_revision in the WebRTC DEPS file.""" | 10 """Script to roll chromium_revision in the WebRTC DEPS file.""" |
| 11 | 11 |
| 12 import argparse | 12 import argparse |
| 13 import base64 | 13 import base64 |
| 14 import collections | 14 import collections |
| 15 import logging | 15 import logging |
| 16 import os | 16 import os |
| 17 import re | 17 import re |
| 18 import subprocess | 18 import subprocess |
| 19 import sys | 19 import sys |
| 20 import urllib | 20 import urllib |
| 21 | 21 |
| 22 | 22 |
| 23 CHROMIUM_LKGR_URL = 'https://chromium-status.appspot.com/lkgr' | |
| 24 CHROMIUM_SRC_URL = 'https://chromium.googlesource.com/chromium/src' | 23 CHROMIUM_SRC_URL = 'https://chromium.googlesource.com/chromium/src' |
| 25 CHROMIUM_COMMIT_TEMPLATE = CHROMIUM_SRC_URL + '/+/%s' | 24 CHROMIUM_COMMIT_TEMPLATE = CHROMIUM_SRC_URL + '/+/%s' |
| 26 CHROMIUM_FILE_TEMPLATE = CHROMIUM_SRC_URL + '/+/%s/%s' | 25 CHROMIUM_FILE_TEMPLATE = CHROMIUM_SRC_URL + '/+/%s/%s' |
| 27 | 26 |
| 28 COMMIT_POSITION_RE = re.compile('^Cr-Commit-Position: .*#([0-9]+).*$') | 27 COMMIT_POSITION_RE = re.compile('^Cr-Commit-Position: .*#([0-9]+).*$') |
| 29 CLANG_REVISION_RE = re.compile(r'^CLANG_REVISION=(\d+)$') | 28 CLANG_REVISION_RE = re.compile(r'^CLANG_REVISION=(\d+)$') |
| 30 ROLL_BRANCH_NAME = 'roll_chromium_revision' | 29 ROLL_BRANCH_NAME = 'roll_chromium_revision' |
| 31 | 30 |
| 32 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | 31 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 33 CHECKOUT_ROOT_DIR = os.path.realpath(os.path.join(SCRIPT_DIR, os.pardir, | 32 CHECKOUT_ROOT_DIR = os.path.realpath(os.path.join(SCRIPT_DIR, os.pardir, |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 if not dry_run and not skip_try: | 345 if not dry_run and not skip_try: |
| 347 _RunCommand(['git', 'cl', 'try']) | 346 _RunCommand(['git', 'cl', 'try']) |
| 348 | 347 |
| 349 | 348 |
| 350 def main(): | 349 def main(): |
| 351 p = argparse.ArgumentParser() | 350 p = argparse.ArgumentParser() |
| 352 p.add_argument('--clean', action='store_true', default=False, | 351 p.add_argument('--clean', action='store_true', default=False, |
| 353 help='Removes any previous local roll branch.') | 352 help='Removes any previous local roll branch.') |
| 354 p.add_argument('-r', '--revision', | 353 p.add_argument('-r', '--revision', |
| 355 help=('Chromium Git revision to roll to. Defaults to the ' | 354 help=('Chromium Git revision to roll to. Defaults to the ' |
| 356 'Chromium LKGR revision if omitted.')) | 355 'Chromium HEAD revision if omitted.')) |
| 357 p.add_argument('--dry-run', action='store_true', default=False, | 356 p.add_argument('--dry-run', action='store_true', default=False, |
| 358 help=('Calculate changes and modify DEPS, but don\'t create ' | 357 help=('Calculate changes and modify DEPS, but don\'t create ' |
| 359 'any local branch, commit, upload CL or send any ' | 358 'any local branch, commit, upload CL or send any ' |
| 360 'tryjobs.')) | 359 'tryjobs.')) |
| 361 p.add_argument('-s', '--skip-try', action='store_true', default=False, | 360 p.add_argument('-s', '--skip-try', action='store_true', default=False, |
| 362 help='Do everything except sending tryjobs.') | 361 help='Do everything except sending tryjobs.') |
| 363 p.add_argument('-v', '--verbose', action='store_true', default=False, | 362 p.add_argument('-v', '--verbose', action='store_true', default=False, |
| 364 help='Be extra verbose in printing of log messages.') | 363 help='Be extra verbose in printing of log messages.') |
| 365 opts = p.parse_args() | 364 opts = p.parse_args() |
| 366 | 365 |
| 367 if opts.verbose: | 366 if opts.verbose: |
| 368 logging.basicConfig(level=logging.DEBUG) | 367 logging.basicConfig(level=logging.DEBUG) |
| 369 else: | 368 else: |
| 370 logging.basicConfig(level=logging.INFO) | 369 logging.basicConfig(level=logging.INFO) |
| 371 | 370 |
| 372 if not _IsTreeClean(): | 371 if not _IsTreeClean(): |
| 373 logging.error('Please clean your local checkout first.') | 372 logging.error('Please clean your local checkout first.') |
| 374 return 1 | 373 return 1 |
| 375 | 374 |
| 376 if opts.clean: | 375 if opts.clean: |
| 377 _RemovePreviousRollBranch(opts.dry_run) | 376 _RemovePreviousRollBranch(opts.dry_run) |
| 378 | 377 |
| 379 _EnsureUpdatedMasterBranch(opts.dry_run) | 378 _EnsureUpdatedMasterBranch(opts.dry_run) |
| 380 | 379 |
| 381 if not opts.revision: | 380 if not opts.revision: |
| 382 lkgr_contents = ReadUrlContent(CHROMIUM_LKGR_URL) | 381 stdout, _ = _RunCommand(['git', 'ls-remote', CHROMIUM_SRC_URL, 'HEAD']) |
| 383 logging.info('No revision specified. Using LKGR: %s', lkgr_contents[0]) | 382 head_rev = stdout.strip().split('\t')[0] |
| 384 opts.revision = lkgr_contents[0] | 383 logging.info('No revision specified. Using HEAD: %s', head_rev) |
| 384 opts.revision = head_rev |
| 385 | 385 |
| 386 deps_filename = os.path.join(CHECKOUT_ROOT_DIR, 'DEPS') | 386 deps_filename = os.path.join(CHECKOUT_ROOT_DIR, 'DEPS') |
| 387 local_deps = ParseLocalDepsFile(deps_filename) | 387 local_deps = ParseLocalDepsFile(deps_filename) |
| 388 current_cr_rev = local_deps['vars']['chromium_revision'] | 388 current_cr_rev = local_deps['vars']['chromium_revision'] |
| 389 | 389 |
| 390 current_cr_deps = ParseRemoteCrDepsFile(current_cr_rev) | 390 current_cr_deps = ParseRemoteCrDepsFile(current_cr_rev) |
| 391 new_cr_deps = ParseRemoteCrDepsFile(opts.revision) | 391 new_cr_deps = ParseRemoteCrDepsFile(opts.revision) |
| 392 | 392 |
| 393 changed_deps = sorted(CalculateChangedDeps(current_cr_deps, new_cr_deps)) | 393 changed_deps = sorted(CalculateChangedDeps(current_cr_deps, new_cr_deps)) |
| 394 clang_change = CalculateChangedClang(opts.revision) | 394 clang_change = CalculateChangedClang(opts.revision) |
| 395 if changed_deps or clang_change: | 395 if changed_deps or clang_change: |
| 396 commit_msg = GenerateCommitMessage(current_cr_rev, opts.revision, | 396 commit_msg = GenerateCommitMessage(current_cr_rev, opts.revision, |
| 397 changed_deps, clang_change) | 397 changed_deps, clang_change) |
| 398 logging.debug('Commit message:\n%s', commit_msg) | 398 logging.debug('Commit message:\n%s', commit_msg) |
| 399 else: | 399 else: |
| 400 logging.info('No deps changes detected when rolling from %s to %s. ' | 400 logging.info('No deps changes detected when rolling from %s to %s. ' |
| 401 'Aborting without action.', current_cr_rev, opts.revision) | 401 'Aborting without action.', current_cr_rev, opts.revision) |
| 402 return 0 | 402 return 0 |
| 403 | 403 |
| 404 _CreateRollBranch(opts.dry_run) | 404 _CreateRollBranch(opts.dry_run) |
| 405 UpdateDeps(deps_filename, current_cr_rev, opts.revision) | 405 UpdateDeps(deps_filename, current_cr_rev, opts.revision) |
| 406 _LocalCommit(commit_msg, opts.dry_run) | 406 _LocalCommit(commit_msg, opts.dry_run) |
| 407 _UploadCL(opts.dry_run) | 407 _UploadCL(opts.dry_run) |
| 408 _LaunchTrybots(opts.dry_run, opts.skip_try) | 408 _LaunchTrybots(opts.dry_run, opts.skip_try) |
| 409 return 0 | 409 return 0 |
| 410 | 410 |
| 411 | 411 |
| 412 if __name__ == '__main__': | 412 if __name__ == '__main__': |
| 413 sys.exit(main()) | 413 sys.exit(main()) |
| OLD | NEW |