Index: tools/roll_skia_with_chrome_changes.py |
diff --git a/tools/roll_skia_with_chrome_changes.py b/tools/roll_skia_with_chrome_changes.py |
new file mode 100755 |
index 0000000000000000000000000000000000000000..8867058aa980313497b6f7accb418dba8331dae4 |
--- /dev/null |
+++ b/tools/roll_skia_with_chrome_changes.py |
@@ -0,0 +1,105 @@ |
+#!/usr/bin/env python |
+# Copyright 2014 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+ |
+"""Roll Skia one commit at a time, applying associated Chrome CLs as we go.""" |
+ |
+ |
+import find_depot_tools |
+import apply_issue |
+import os |
+import re |
+import subprocess |
+import sys |
+ |
+ |
+PATH_TO_SKIA = os.path.join('third_party', 'skia') |
+ |
+ |
+def get_current_commit(): |
+ content = open('DEPS').read() |
+ rev_line = r' "skia_revision": "(.+)",' |
+ current_commit = re.search(rev_line, content).group(1) |
+ return current_commit |
+ |
+ |
+def modify_skia_deps(commit): |
+ content = open('DEPS').read() |
+ old_line = r' "skia_revision": "(.+)",' |
+ new_line = r' "skia_revision": "%s",' % commit |
+ new_content = re.sub(old_line, new_line, content, 1) |
+ old_rev = re.search(old_line, content).group(1) |
+ print old_rev, commit |
+ if not old_rev or new_content == content: |
+ raise Exception('Failed to update the DEPS file') |
+ |
+ open('DEPS', 'w').write(new_content) |
+ |
+ |
+def get_associated_chrome_issue(skia_commit): |
+ # TODO(borenet): Parse the commit message for this: |
+ #commit_msg = subprocess.check_output(['git', 'log', '--format=%B', '-n', '1', |
+ # skia_commit]) |
+ #search_str = r'ASSOCIATED_CHROME_CHANGE=(\d+)' |
+ #match = re.search(search_str, commit_msg) |
+ #if match: |
+ # return match.group(1) |
+ |
+ return { |
+ 'e0d9ce890e67d02727ac2811bb456ddb64f827d4': |
+ '248693002', |
+ }.get(skia_commit) |
+ |
+ |
+def apply_associated_chrome_patch(skia_commit): |
+ associated_issue = get_associated_chrome_issue(skia_commit) |
+ if associated_issue: |
+ sys.argv = ['apply_issue', '-i', associated_issue, '-b', 'HEAD~1'] |
+ apply_issue.main() |
+ |
+ |
+def make_commit(message, changed_files): |
+ for changed_file in changed_files: |
+ subprocess.check_call(['git', 'add', changed_file]) |
+ subprocess.check_call(['git', 'commit', '-m', message]) |
+ |
+ |
+def increment_skia(commit): |
+ apply_associated_chrome_patch(commit) |
+ modify_skia_deps(commit) |
+ make_commit('Roll Skia DEPS to %s' % commit, ['DEPS']) |
+ |
+ |
+def upload_cl(): |
+ print 'uploading CL' |
+ |
+ |
+def roll_skia(): |
+ current_commit = get_current_commit() |
+ |
+ # Update the Skia checkout. |
+ subprocess.check_call(['git', 'fetch'], cwd=PATH_TO_SKIA) |
+ # Obtain the latest commit. |
+ most_recent_commit = subprocess.check_output(['git', 'rev-parse', |
+ 'origin/master'], |
+ cwd=PATH_TO_SKIA).rstrip() |
+ # Find the list of commits between the current commit and the latest. |
+ commit_list = subprocess.check_output(['git', 'rev-list', |
+ '%s..%s' % (current_commit, |
+ most_recent_commit)], |
+ cwd=PATH_TO_SKIA).splitlines() |
+ commit_list.reverse() |
+ |
+ # For each commit between the current and the latest, roll Skia forward, apply |
+ # any associated Chrome patch, and create a new commit. |
+ for commit in commit_list: |
+ increment_skia(commit) |
+ |
+ # Upload the CL. |
+ upload_cl() |
+ |
+ |
+if __name__ == '__main__': |
+ roll_skia() |