| 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_SRC_URL = 'https://chromium.googlesource.com/chromium/src' | 23 CHROMIUM_SRC_URL = 'https://chromium.googlesource.com/chromium/src' |
| 24 CHROMIUM_COMMIT_TEMPLATE = CHROMIUM_SRC_URL + '/+/%s' | 24 CHROMIUM_COMMIT_TEMPLATE = CHROMIUM_SRC_URL + '/+/%s' |
| 25 CHROMIUM_LOG_TEMPLATE = CHROMIUM_SRC_URL + '/+log/%s' | 25 CHROMIUM_LOG_TEMPLATE = CHROMIUM_SRC_URL + '/+log/%s' |
| 26 CHROMIUM_FILE_TEMPLATE = CHROMIUM_SRC_URL + '/+/%s/%s' | 26 CHROMIUM_FILE_TEMPLATE = CHROMIUM_SRC_URL + '/+/%s/%s' |
| 27 | 27 |
| 28 COMMIT_POSITION_RE = re.compile('^Cr-Commit-Position: .*#([0-9]+).*$') | 28 COMMIT_POSITION_RE = re.compile('^Cr-Commit-Position: .*#([0-9]+).*$') |
| 29 CLANG_REVISION_RE = re.compile(r'^CLANG_REVISION=(\d+)$') | 29 CLANG_REVISION_RE = re.compile(r'^CLANG_REVISION = \'(\d+)\'$') |
| 30 ROLL_BRANCH_NAME = 'roll_chromium_revision' | 30 ROLL_BRANCH_NAME = 'roll_chromium_revision' |
| 31 | 31 |
| 32 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | 32 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 33 CHECKOUT_ROOT_DIR = os.path.realpath(os.path.join(SCRIPT_DIR, os.pardir, | 33 CHECKOUT_ROOT_DIR = os.path.realpath(os.path.join(SCRIPT_DIR, os.pardir, |
| 34 os.pardir)) | 34 os.pardir)) |
| 35 sys.path.append(CHECKOUT_ROOT_DIR) | 35 sys.path.append(CHECKOUT_ROOT_DIR) |
| 36 import setup_links | 36 import setup_links |
| 37 | 37 |
| 38 sys.path.append(os.path.join(CHECKOUT_ROOT_DIR, 'build')) | 38 sys.path.append(os.path.join(CHECKOUT_ROOT_DIR, 'build')) |
| 39 import find_depot_tools | 39 import find_depot_tools |
| 40 find_depot_tools.add_depot_tools_to_path() | 40 find_depot_tools.add_depot_tools_to_path() |
| 41 from gclient import GClientKeywords | 41 from gclient import GClientKeywords |
| 42 | 42 |
| 43 CLANG_UPDATE_SCRIPT_URL_PATH = 'tools/clang/scripts/update.py' | 43 CLANG_UPDATE_SCRIPT_URL_PATH = 'tools/clang/scripts/update.py' |
| 44 CLANG_UPDATE_SCRIPT_LOCAL_PATH = os.path.join('tools', 'clang', 'scripts', | 44 CLANG_UPDATE_SCRIPT_LOCAL_PATH = os.path.join('tools', 'clang', 'scripts', |
| 45 'update.py') | 45 'update.py') |
| 46 | 46 |
| 47 DepsEntry = collections.namedtuple('DepsEntry', 'path url revision') | 47 DepsEntry = collections.namedtuple('DepsEntry', 'path url revision') |
| 48 ChangedDep = collections.namedtuple('ChangedDep', | 48 ChangedDep = collections.namedtuple('ChangedDep', |
| 49 'path url current_rev new_rev') | 49 'path url current_rev new_rev') |
| 50 | 50 |
| 51 class RollError(Exception): |
| 52 pass |
| 53 |
| 51 | 54 |
| 52 def ParseDepsDict(deps_content): | 55 def ParseDepsDict(deps_content): |
| 53 local_scope = {} | 56 local_scope = {} |
| 54 var = GClientKeywords.VarImpl({}, local_scope) | 57 var = GClientKeywords.VarImpl({}, local_scope) |
| 55 global_scope = { | 58 global_scope = { |
| 56 'File': GClientKeywords.FileImpl, | 59 'File': GClientKeywords.FileImpl, |
| 57 'From': GClientKeywords.FromImpl, | 60 'From': GClientKeywords.FromImpl, |
| 58 'Var': var.Lookup, | 61 'Var': var.Lookup, |
| 59 'deps_os': {}, | 62 'deps_os': {}, |
| 60 } | 63 } |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 new_matching_entries[0].revision)) | 230 new_matching_entries[0].revision)) |
| 228 return result | 231 return result |
| 229 | 232 |
| 230 | 233 |
| 231 def CalculateChangedClang(new_cr_rev): | 234 def CalculateChangedClang(new_cr_rev): |
| 232 def GetClangRev(lines): | 235 def GetClangRev(lines): |
| 233 for line in lines: | 236 for line in lines: |
| 234 match = CLANG_REVISION_RE.match(line) | 237 match = CLANG_REVISION_RE.match(line) |
| 235 if match: | 238 if match: |
| 236 return match.group(1) | 239 return match.group(1) |
| 237 return None | 240 raise RollError('Could not parse Clang revision!') |
| 238 | 241 |
| 239 chromium_src_path = os.path.join(CHECKOUT_ROOT_DIR, 'chromium', 'src', | 242 chromium_src_path = os.path.join(CHECKOUT_ROOT_DIR, 'chromium', 'src', |
| 240 CLANG_UPDATE_SCRIPT_LOCAL_PATH) | 243 CLANG_UPDATE_SCRIPT_LOCAL_PATH) |
| 241 with open(chromium_src_path, 'rb') as f: | 244 with open(chromium_src_path, 'rb') as f: |
| 242 current_lines = f.readlines() | 245 current_lines = f.readlines() |
| 243 current_rev = GetClangRev(current_lines) | 246 current_rev = GetClangRev(current_lines) |
| 244 | 247 |
| 245 new_clang_update_sh = ReadRemoteCrFile(CLANG_UPDATE_SCRIPT_URL_PATH, | 248 new_clang_update_py = ReadRemoteCrFile(CLANG_UPDATE_SCRIPT_URL_PATH, |
| 246 new_cr_rev).splitlines() | 249 new_cr_rev).splitlines() |
| 247 new_rev = GetClangRev(new_clang_update_sh) | 250 new_rev = GetClangRev(new_clang_update_py) |
| 248 return ChangedDep(CLANG_UPDATE_SCRIPT_LOCAL_PATH, None, current_rev, new_rev) | 251 return ChangedDep(CLANG_UPDATE_SCRIPT_LOCAL_PATH, None, current_rev, new_rev) |
| 249 | 252 |
| 250 | 253 |
| 251 def GenerateCommitMessage(current_cr_rev, new_cr_rev, current_commit_pos, | 254 def GenerateCommitMessage(current_cr_rev, new_cr_rev, current_commit_pos, |
| 252 new_commit_pos, changed_deps_list, clang_change): | 255 new_commit_pos, changed_deps_list, clang_change): |
| 253 current_cr_rev = current_cr_rev[0:7] | 256 current_cr_rev = current_cr_rev[0:7] |
| 254 new_cr_rev = new_cr_rev[0:7] | 257 new_cr_rev = new_cr_rev[0:7] |
| 255 rev_interval = '%s..%s' % (current_cr_rev, new_cr_rev) | 258 rev_interval = '%s..%s' % (current_cr_rev, new_cr_rev) |
| 256 git_number_interval = '%s:%s' % (current_commit_pos, new_commit_pos) | 259 git_number_interval = '%s:%s' % (current_commit_pos, new_commit_pos) |
| 257 | 260 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 UpdateDeps(deps_filename, current_cr_rev, new_cr_rev) | 446 UpdateDeps(deps_filename, current_cr_rev, new_cr_rev) |
| 444 _LocalCommit(commit_msg, opts.dry_run) | 447 _LocalCommit(commit_msg, opts.dry_run) |
| 445 _UploadCL(opts.dry_run, opts.rietveld_email) | 448 _UploadCL(opts.dry_run, opts.rietveld_email) |
| 446 _LaunchTrybots(opts.dry_run, opts.skip_try) | 449 _LaunchTrybots(opts.dry_run, opts.skip_try) |
| 447 _SendToCQ(opts.dry_run, opts.skip_cq) | 450 _SendToCQ(opts.dry_run, opts.skip_cq) |
| 448 return 0 | 451 return 0 |
| 449 | 452 |
| 450 | 453 |
| 451 if __name__ == '__main__': | 454 if __name__ == '__main__': |
| 452 sys.exit(main()) | 455 sys.exit(main()) |
| OLD | NEW |