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

Side by Side Diff: tools/roll_skia_with_chrome_changes.py

Issue 249493003: Add roll_skia_with_chrome_changes script - DON'T COMMIT ME! (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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 | « no previous file | no next file » | 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 python
2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6
7 """Roll Skia one commit at a time, applying associated Chrome CLs as we go."""
8
9
10 import find_depot_tools
11 import apply_issue
12 import os
13 import re
14 import subprocess
15 import sys
16
17
18 PATH_TO_SKIA = os.path.join('third_party', 'skia')
19
20
21 def get_current_commit():
22 content = open('DEPS').read()
23 rev_line = r' "skia_revision": "(.+)",'
24 current_commit = re.search(rev_line, content).group(1)
25 return current_commit
26
27
28 def modify_skia_deps(commit):
29 content = open('DEPS').read()
30 old_line = r' "skia_revision": "(.+)",'
31 new_line = r' "skia_revision": "%s",' % commit
32 new_content = re.sub(old_line, new_line, content, 1)
33 old_rev = re.search(old_line, content).group(1)
34 print old_rev, commit
35 if not old_rev or new_content == content:
36 raise Exception('Failed to update the DEPS file')
37
38 open('DEPS', 'w').write(new_content)
39
40
41 def get_associated_chrome_issue(skia_commit):
42 # TODO(borenet): Parse the commit message for this:
43 #commit_msg = subprocess.check_output(['git', 'log', '--format=%B', '-n', '1',
44 # skia_commit])
45 #search_str = r'ASSOCIATED_CHROME_CHANGE=(\d+)'
46 #match = re.search(search_str, commit_msg)
47 #if match:
48 # return match.group(1)
49
50 return {
51 'e0d9ce890e67d02727ac2811bb456ddb64f827d4':
52 '248693002',
53 }.get(skia_commit)
54
55
56 def apply_associated_chrome_patch(skia_commit):
57 associated_issue = get_associated_chrome_issue(skia_commit)
58 if associated_issue:
59 sys.argv = ['apply_issue', '-i', associated_issue, '-b', 'HEAD~1']
60 apply_issue.main()
61
62
63 def make_commit(message, changed_files):
64 for changed_file in changed_files:
65 subprocess.check_call(['git', 'add', changed_file])
66 subprocess.check_call(['git', 'commit', '-m', message])
67
68
69 def increment_skia(commit):
70 apply_associated_chrome_patch(commit)
71 modify_skia_deps(commit)
72 make_commit('Roll Skia DEPS to %s' % commit, ['DEPS'])
73
74
75 def upload_cl():
76 print 'uploading CL'
77
78
79 def roll_skia():
80 current_commit = get_current_commit()
81
82 # Update the Skia checkout.
83 subprocess.check_call(['git', 'fetch'], cwd=PATH_TO_SKIA)
84 # Obtain the latest commit.
85 most_recent_commit = subprocess.check_output(['git', 'rev-parse',
86 'origin/master'],
87 cwd=PATH_TO_SKIA).rstrip()
88 # Find the list of commits between the current commit and the latest.
89 commit_list = subprocess.check_output(['git', 'rev-list',
90 '%s..%s' % (current_commit,
91 most_recent_commit)],
92 cwd=PATH_TO_SKIA).splitlines()
93 commit_list.reverse()
94
95 # For each commit between the current and the latest, roll Skia forward, apply
96 # any associated Chrome patch, and create a new commit.
97 for commit in commit_list:
98 increment_skia(commit)
99
100 # Upload the CL.
101 upload_cl()
102
103
104 if __name__ == '__main__':
105 roll_skia()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698