Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # Copyright (c) 2011 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 """Safely* rolls webkit. | |
| 7 | |
| 8 * As safely as currently possible. | |
| 9 """ | |
|
Dirk Pranke
2011/05/30 21:23:24
This comment isn't that helpful. I would replace i
M-A Ruel
2011/05/31 01:21:07
done
| |
| 10 | |
| 11 import logging | |
| 12 import optparse | |
| 13 import os | |
| 14 import re | |
| 15 import sys | |
| 16 | |
| 17 import find_depot_tools | |
| 18 import scm | |
| 19 import subprocess2 | |
| 20 | |
| 21 | |
| 22 def die_with_error(msg): | |
| 23 print >> sys.stderr, msg | |
| 24 sys.exit(1) | |
| 25 | |
| 26 | |
| 27 def process_deps(path, new_rev): | |
| 28 """Update webkit_revision to |new_issue|. | |
| 29 | |
| 30 A bit hacky, could it be made better? | |
| 31 """ | |
| 32 content = open(path).read() | |
| 33 old_line = r' "webkit_revision": "(\d+)",' | |
| 34 new_line = ' "webkit_revision": "%d",' % new_rev | |
|
Dirk Pranke
2011/05/30 21:23:24
Hm. I'd probably do this using readlines() for lin
M-A Ruel
2011/05/31 01:21:07
I prefer to keep the dumb logic here and change it
| |
| 35 new_content = re.sub(old_line, new_line, content) | |
| 36 if new_content == content: | |
| 37 die_with_error('Failed to update the DEPS file') | |
| 38 open(path, 'w').write(new_content) | |
| 39 | |
| 40 | |
| 41 def main(): | |
| 42 tool_dir = os.path.dirname(os.path.abspath(__file__)) | |
| 43 parser = optparse.OptionParser(usage='<new webkit rev>') | |
| 44 parser.add_option('-v', '--verbose', action='count', default=0) | |
| 45 options, args = parser.parse_args() | |
| 46 logging.basicConfig( | |
| 47 level= | |
| 48 [logging.WARNING, logging.INFO, logging.DEBUG][ | |
| 49 min(2, options.verbose)]) | |
| 50 if len(args) != 1: | |
| 51 parser.error('Need only one arg: new webkit revision to roll to.') | |
| 52 | |
| 53 root_dir = os.path.dirname(tool_dir) | |
| 54 os.chdir(root_dir) | |
| 55 | |
| 56 new_rev = int(args[0]) | |
| 57 msg = 'Roll webkit revision to %s' % new_rev | |
| 58 print msg | |
| 59 | |
| 60 # Silence the editor. | |
| 61 os.environ['EDITOR'] = '/bin/true' | |
| 62 | |
| 63 old_branch = scm.GIT.GetBranch(root_dir) | |
| 64 subprocess2.check_output( | |
| 65 ['git', 'checkout', '-b', 'webkit_roll', 'origin/trunk']) | |
| 66 try: | |
| 67 process_deps(os.path.join(root_dir, 'DEPS'), new_rev) | |
| 68 subprocess2.check_output(['git', 'commit', '-m', msg, 'DEPS']) | |
| 69 changed = subprocess2.check_output( | |
| 70 ['git', 'diff', 'origin/trunk', '--name-only']).splitlines() | |
| 71 if changed != ['DEPS']: | |
| 72 die_with_error('Make sure to be on a clean branch first') | |
| 73 subprocess2.check_call(['git', 'cl', 'upload', '--use-commit-queue']) | |
| 74 finally: | |
| 75 subprocess2.check_output(['git', 'checkout', old_branch]) | |
| 76 subprocess2.check_output(['git', 'branch', '-D', 'webkit_roll']) | |
|
Dirk Pranke
2011/05/30 21:23:24
I personally don't like to delete branches until a
M-A Ruel
2011/05/31 01:21:07
By using check_call(git checkout -b) before the tr
| |
| 77 return 0 | |
| 78 | |
| 79 | |
| 80 if __name__ == '__main__': | |
| 81 sys.exit(main()) | |
| OLD | NEW |