Index: tools/safely-roll-blink.py |
diff --git a/tools/safely-roll-blink.py b/tools/safely-roll-blink.py |
index 581aecd5c6bb1ddfd3c2514f7c8130d06d502412..af7c12df1e94e09e8ac0cf9838ce606537226947 100755 |
--- a/tools/safely-roll-blink.py |
+++ b/tools/safely-roll-blink.py |
@@ -30,8 +30,8 @@ def process_deps(path, new_rev, is_dry_run): |
A bit hacky, could it be made better? |
""" |
content = open(path).read() |
- old_line = r'(\s+)"webkit_revision": "(\d+)",' |
- new_line = r'\1"webkit_revision": "%d",' % new_rev |
+ old_line = r"(\s+)'webkit_revision': '([a-f0-9]{40})'," |
+ new_line = r"\1'webkit_revision': '%s'," % new_rev |
new_content = re.sub(old_line, new_line, content, 1) |
old_rev = re.search(old_line, content).group(2) |
if not old_rev or new_content == content: |
@@ -42,9 +42,19 @@ def process_deps(path, new_rev, is_dry_run): |
return old_rev |
+def get_svn_rev_from_git_rev(git_rev): |
+ """Return the svn revision associated with the Blink git revision.""" |
+ |
+ os.chdir("third_party/WebKit/") |
+ log = subprocess2.check_output(['git', 'log', git_rev, '-n', '1']) |
+ rev_line = r"\s+git-svn-id: svn://svn.chromium.org/blink/trunk@(\d+)" |
+ os.chdir("../..") |
+ |
+ return int(re.search(rev_line, log).group(1)) |
+ |
def main(): |
tool_dir = os.path.dirname(os.path.abspath(__file__)) |
- parser = optparse.OptionParser(usage='%prog [options] <new blink rev>') |
+ parser = optparse.OptionParser(usage='%prog [options] <new blink git rev>') |
parser.add_option('-v', '--verbose', action='count', default=0) |
parser.add_option('--dry-run', action='store_true') |
parser.add_option('--commit', action='store_true', default=True, |
@@ -72,7 +82,7 @@ def main(): |
root_dir = os.path.dirname(tool_dir) |
os.chdir(root_dir) |
- new_rev = int(args[0]) |
+ new_git_rev = args[0] |
# Silence the editor. |
os.environ['EDITOR'] = 'true' |
@@ -87,9 +97,13 @@ def main(): |
['git', 'checkout', '-b', 'blink_roll', options.upstream]) |
try: |
- old_rev = int(process_deps(os.path.join(root_dir, 'DEPS'), new_rev, |
- options.dry_run)) |
- print 'Blink roll %s:%s' % (old_rev, new_rev) |
+ old_git_rev = process_deps(os.path.join(root_dir, 'DEPS'), new_git_rev, |
+ options.dry_run) |
+ |
+ new_svn_rev = get_svn_rev_from_git_rev(new_git_rev) |
+ old_svn_rev = get_svn_rev_from_git_rev(old_git_rev) |
+ |
+ print 'Blink roll %s:%s' % (old_svn_rev, new_svn_rev) |
review_field = 'TBR' if options.commit else 'R' |
commit_msg = ('Blink roll %s:%s\n' |
@@ -97,8 +111,8 @@ def main(): |
'http://build.chromium.org/f/chromium/perf/dashboard/ui/' |
'changelog_blink.html?url=/trunk&range=%s:%s&mode=html' |
'\n' |
- '%s=%s\n' % (old_rev, new_rev, |
- old_rev+1, new_rev, |
+ '%s=%s\n' % (old_svn_rev, new_svn_rev, |
+ old_svn_rev+1, new_svn_rev, |
review_field, |
options.reviewers)) |