blob: 6ee37c32b8d2c41ae1a304d277a0f1b75fd142e3 [file] [log] [blame]
halcanary@google.com31fdb922014-01-06 19:50:22 +00001#!/usr/bin/python2
2
3# Copyright 2014 Google Inc.
4#
5# Use of this source code is governed by a BSD-style license that can be
6# found in the LICENSE file.
7
8"""Skia's Chromium DEPS roll script.
9
10This script:
11- searches through the last N Skia git commits to find out the hash that is
12 associated with the SVN revision number.
13- creates a new branch in the Chromium tree, modifies the DEPS file to
14 point at the given Skia commit, commits, uploads to Rietveld, and
15 deletes the local copy of the branch.
16- creates a whitespace-only commit and uploads that to to Rietveld.
17- returns the Chromium tree to its previous state.
18
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +000019To specify the location of the git executable, set the GIT_EXECUTABLE
20environment variable.
21
halcanary@google.com31fdb922014-01-06 19:50:22 +000022Usage:
23 %prog -c CHROMIUM_PATH -r REVISION [OPTIONAL_OPTIONS]
24"""
25
26
27import optparse
28import os
29import re
30import shutil
31import subprocess
halcanary@google.com31fdb922014-01-06 19:50:22 +000032import sys
33import tempfile
34
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +000035import git_utils
36import misc_utils
37
halcanary@google.com31fdb922014-01-06 19:50:22 +000038
borenet@google.com17bb9512014-01-27 18:08:55 +000039DEFAULT_BOTS_LIST = [
40 'android_clang_dbg',
41 'android_dbg',
42 'android_rel',
43 'cros_daisy',
44 'linux',
45 'linux_asan',
46 'linux_chromeos',
47 'linux_chromeos_asan',
48 'linux_gpu',
49 'linux_layout',
50 'linux_layout_rel',
51 'mac',
52 'mac_asan',
53 'mac_gpu',
54 'mac_layout',
55 'mac_layout_rel',
56 'win',
57 'win_gpu',
58 'win_layout',
59 'win_layout_rel',
60]
61
62
halcanary@google.com31fdb922014-01-06 19:50:22 +000063class DepsRollConfig(object):
64 """Contains configuration options for this module.
65
66 Attributes:
67 git: (string) The git executable.
68 chromium_path: (string) path to a local chromium git repository.
69 save_branches: (boolean) iff false, delete temporary branches.
70 verbose: (boolean) iff false, suppress the output from git-cl.
71 search_depth: (int) how far back to look for the revision.
72 skia_url: (string) Skia's git repository.
73 self.skip_cl_upload: (boolean)
74 self.cl_bot_list: (list of strings)
75 """
76
77 # pylint: disable=I0011,R0903,R0902
78 def __init__(self, options=None):
79 self.skia_url = 'https://skia.googlesource.com/skia.git'
80 self.revision_format = (
81 'git-svn-id: http://skia.googlecode.com/svn/trunk@%d ')
82
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +000083 self.git = git_utils.git_executable()
84
halcanary@google.com31fdb922014-01-06 19:50:22 +000085 if not options:
86 options = DepsRollConfig.GetOptionParser()
87 # pylint: disable=I0011,E1103
88 self.verbose = options.verbose
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +000089 self.vsp = misc_utils.VerboseSubprocess(self.verbose)
halcanary@google.com8c5d2c12014-01-08 21:29:34 +000090 self.save_branches = not options.delete_branches
halcanary@google.com31fdb922014-01-06 19:50:22 +000091 self.search_depth = options.search_depth
92 self.chromium_path = options.chromium_path
halcanary@google.com31fdb922014-01-06 19:50:22 +000093 self.skip_cl_upload = options.skip_cl_upload
94 # Split and remove empty strigns from the bot list.
95 self.cl_bot_list = [bot for bot in options.bots.split(',') if bot]
96 self.skia_git_checkout_path = options.skia_git_path
97 self.default_branch_name = 'autogenerated_deps_roll_branch'
commit-bot@chromium.org34f47f92014-01-21 21:38:49 +000098 self.reviewers_list = ','.join([
99 # 'rmistry@google.com',
100 # 'reed@google.com',
101 # 'bsalomon@google.com',
102 # 'robertphillips@google.com',
103 ])
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +0000104 self.cc_list = ','.join([
commit-bot@chromium.org34f47f92014-01-21 21:38:49 +0000105 # 'skia-team@google.com',
106 ])
halcanary@google.com31fdb922014-01-06 19:50:22 +0000107
108 @staticmethod
109 def GetOptionParser():
110 # pylint: disable=I0011,C0103
111 """Returns an optparse.OptionParser object.
112
113 Returns:
114 An optparse.OptionParser object.
115
116 Called by the main() function.
117 """
halcanary@google.com31fdb922014-01-06 19:50:22 +0000118 option_parser = optparse.OptionParser(usage=__doc__)
119 # Anyone using this script on a regular basis should set the
120 # CHROMIUM_CHECKOUT_PATH environment variable.
121 option_parser.add_option(
122 '-c', '--chromium_path', help='Path to local Chromium Git'
123 ' repository checkout, defaults to CHROMIUM_CHECKOUT_PATH'
124 ' if that environment variable is set.',
125 default=os.environ.get('CHROMIUM_CHECKOUT_PATH'))
126 option_parser.add_option(
127 '-r', '--revision', type='int', default=None,
128 help='The Skia SVN revision number, defaults to top of tree.')
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000129 option_parser.add_option(
130 '-g', '--git_hash', default=None,
131 help='A partial Skia Git hash. Do not set this and revision.')
132
halcanary@google.com31fdb922014-01-06 19:50:22 +0000133 # Anyone using this script on a regular basis should set the
134 # SKIA_GIT_CHECKOUT_PATH environment variable.
135 option_parser.add_option(
136 '', '--skia_git_path',
137 help='Path of a pure-git Skia repository checkout. If empty,'
138 ' a temporary will be cloned. Defaults to SKIA_GIT_CHECKOUT'
139 '_PATH, if that environment variable is set.',
140 default=os.environ.get('SKIA_GIT_CHECKOUT_PATH'))
141 option_parser.add_option(
142 '', '--search_depth', type='int', default=100,
143 help='How far back to look for the revision.')
144 option_parser.add_option(
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000145 '', '--delete_branches', help='Delete the temporary branches',
146 action='store_true', dest='delete_branches', default=False)
halcanary@google.com31fdb922014-01-06 19:50:22 +0000147 option_parser.add_option(
148 '', '--verbose', help='Do not suppress the output from `git cl`.',
149 action='store_true', dest='verbose', default=False)
150 option_parser.add_option(
151 '', '--skip_cl_upload', help='Skip the cl upload step; useful'
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +0000152 ' for testing.',
halcanary@google.com31fdb922014-01-06 19:50:22 +0000153 action='store_true', default=False)
154
155 default_bots_help = (
156 'Comma-separated list of bots, defaults to a list of %d bots.'
157 ' To skip `git cl try`, set this to an empty string.'
borenet@google.com17bb9512014-01-27 18:08:55 +0000158 % len(DEFAULT_BOTS_LIST))
159 default_bots = ','.join(DEFAULT_BOTS_LIST)
halcanary@google.com31fdb922014-01-06 19:50:22 +0000160 option_parser.add_option(
161 '', '--bots', help=default_bots_help, default=default_bots)
162
163 return option_parser
164
165
halcanary@google.com31fdb922014-01-06 19:50:22 +0000166class DepsRollError(Exception):
167 """Exceptions specific to this module."""
168 pass
169
170
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000171def get_svn_revision(config, commit):
172 """Works in both git and git-svn. returns a string."""
173 svn_format = (
174 '(git-svn-id: [^@ ]+@|SVN changes up to revision |'
175 'LKGR w/ DEPS up to revision )(?P<return>[0-9]+)')
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +0000176 svn_revision = misc_utils.ReSearch.search_within_output(
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000177 config.verbose, svn_format, None,
178 [config.git, 'log', '-n', '1', '--format=format:%B', commit])
179 if not svn_revision:
180 raise DepsRollError(
181 'Revision number missing from Chromium origin/master.')
182 return int(svn_revision)
183
184
185class SkiaGitCheckout(object):
186 """Class to create a temporary skia git checkout, if necessary.
halcanary@google.com31fdb922014-01-06 19:50:22 +0000187 """
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000188 # pylint: disable=I0011,R0903
189
190 def __init__(self, config, depth):
191 self._config = config
192 self._depth = depth
193 self._use_temp = None
194 self._original_cwd = None
195
196 def __enter__(self):
197 config = self._config
198 git = config.git
199 skia_dir = None
200 self._original_cwd = os.getcwd()
201 if config.skia_git_checkout_path:
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +0000202 if config.skia_git_checkout_path != os.curdir:
203 skia_dir = config.skia_git_checkout_path
204 ## Update origin/master if needed.
205 if self._config.verbose:
206 print '~~$', 'cd', skia_dir
207 os.chdir(skia_dir)
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000208 config.vsp.check_call([git, 'fetch', '-q', 'origin'])
209 self._use_temp = None
210 else:
211 skia_dir = tempfile.mkdtemp(prefix='git_skia_tmp_')
212 self._use_temp = skia_dir
213 try:
214 os.chdir(skia_dir)
215 config.vsp.check_call(
216 [git, 'clone', '-q', '--depth=%d' % self._depth,
217 '--single-branch', config.skia_url, '.'])
218 except (OSError, subprocess.CalledProcessError) as error:
219 shutil.rmtree(skia_dir)
220 raise error
221
222 def __exit__(self, etype, value, traceback):
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +0000223 if self._config.skia_git_checkout_path != os.curdir:
224 if self._config.verbose:
225 print '~~$', 'cd', self._original_cwd
226 os.chdir(self._original_cwd)
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000227 if self._use_temp:
228 shutil.rmtree(self._use_temp)
halcanary@google.com31fdb922014-01-06 19:50:22 +0000229
230
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000231def revision_and_hash(config):
halcanary@google.com31fdb922014-01-06 19:50:22 +0000232 """Finds revision number and git hash of origin/master in the Skia tree.
233
234 Args:
235 config: (roll_deps.DepsRollConfig) object containing options.
halcanary@google.com31fdb922014-01-06 19:50:22 +0000236
237 Returns:
238 A tuple (revision, hash)
239 revision: (int) SVN revision number.
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000240 git_hash: (string) full Git commit hash.
halcanary@google.com31fdb922014-01-06 19:50:22 +0000241
242 Raises:
243 roll_deps.DepsRollError: if the revision can't be found.
244 OSError: failed to execute git or git-cl.
245 subprocess.CalledProcessError: git returned unexpected status.
246 """
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000247 with SkiaGitCheckout(config, 1):
248 revision = get_svn_revision(config, 'origin/master')
249 git_hash = config.vsp.strip_output(
250 [config.git, 'show-ref', 'origin/master', '--hash'])
251 if not git_hash:
halcanary@google.com31fdb922014-01-06 19:50:22 +0000252 raise DepsRollError('Git hash can not be found.')
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000253 return revision, git_hash
254
255
256def revision_and_hash_from_revision(config, revision):
257 """Finds revision number and git hash of a commit in the Skia tree.
258
259 Args:
260 config: (roll_deps.DepsRollConfig) object containing options.
261 revision: (int) SVN revision number.
262
263 Returns:
264 A tuple (revision, hash)
265 revision: (int) SVN revision number.
266 git_hash: (string) full Git commit hash.
267
268 Raises:
269 roll_deps.DepsRollError: if the revision can't be found.
270 OSError: failed to execute git or git-cl.
271 subprocess.CalledProcessError: git returned unexpected status.
272 """
273 with SkiaGitCheckout(config, config.search_depth):
274 revision_regex = config.revision_format % revision
275 git_hash = config.vsp.strip_output(
276 [config.git, 'log', '--grep', revision_regex,
277 '--format=format:%H', 'origin/master'])
278 if not git_hash:
279 raise DepsRollError('Git hash can not be found.')
280 return revision, git_hash
281
282
283def revision_and_hash_from_partial(config, partial_hash):
284 """Returns the SVN revision number and full git hash.
285
286 Args:
287 config: (roll_deps.DepsRollConfig) object containing options.
288 partial_hash: (string) Partial git commit hash.
289
290 Returns:
291 A tuple (revision, hash)
292 revision: (int) SVN revision number.
293 git_hash: (string) full Git commit hash.
294
295 Raises:
296 roll_deps.DepsRollError: if the revision can't be found.
297 OSError: failed to execute git or git-cl.
298 subprocess.CalledProcessError: git returned unexpected status.
299 """
300 with SkiaGitCheckout(config, config.search_depth):
301 git_hash = config.vsp.strip_output(
302 ['git', 'log', '-n', '1', '--format=format:%H', partial_hash])
303 if not git_hash:
304 raise DepsRollError('Partial Git hash can not be found.')
305 revision = get_svn_revision(config, git_hash)
306 return revision, git_hash
halcanary@google.com31fdb922014-01-06 19:50:22 +0000307
308
halcanary@google.com31fdb922014-01-06 19:50:22 +0000309def change_skia_deps(revision, git_hash, depspath):
310 """Update the DEPS file.
311
312 Modify the skia_revision and skia_hash entries in the given DEPS file.
313
314 Args:
315 revision: (int) Skia SVN revision.
316 git_hash: (string) Skia Git hash.
317 depspath: (string) path to DEPS file.
318 """
319 temp_file = tempfile.NamedTemporaryFile(delete=False,
320 prefix='skia_DEPS_ROLL_tmp_')
321 try:
322 deps_regex_rev = re.compile('"skia_revision": "[0-9]*",')
323 deps_regex_hash = re.compile('"skia_hash": "[0-9a-f]*",')
324
325 deps_regex_rev_repl = '"skia_revision": "%d",' % revision
326 deps_regex_hash_repl = '"skia_hash": "%s",' % git_hash
327
328 with open(depspath, 'r') as input_stream:
329 for line in input_stream:
330 line = deps_regex_rev.sub(deps_regex_rev_repl, line)
331 line = deps_regex_hash.sub(deps_regex_hash_repl, line)
332 temp_file.write(line)
333 finally:
334 temp_file.close()
335 shutil.move(temp_file.name, depspath)
336
337
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +0000338def git_cl_uploader(config, message, file_list):
339 """Create a commit in the current git branch; upload via git-cl.
340
341 Assumes that you are already on the branch you want to be on.
342
343 Args:
344 config: (roll_deps.DepsRollConfig) object containing options.
345 message: (string) the commit message, can be multiline.
346 file_list: (list of strings) list of filenames to pass to `git add`.
347
348 Returns:
349 The output of `git cl issue`, if not config.skip_cl_upload, else ''.
350 """
351
352 git, vsp = config.git, config.vsp
353 svn_info = str(get_svn_revision(config, 'HEAD'))
354
355 for filename in file_list:
356 assert os.path.exists(filename)
357 vsp.check_call([git, 'add', filename])
358
359 vsp.check_call([git, 'commit', '-q', '-m', message])
360
361 git_cl = [git, 'cl', 'upload', '-f',
362 '--bypass-hooks', '--bypass-watchlists']
363 if config.cc_list:
364 git_cl.append('--cc=%s' % config.cc_list)
365 if config.reviewers_list:
366 git_cl.append('--reviewers=%s' % config.reviewers_list)
367
368 git_try = [git, 'cl', 'try', '--revision', svn_info]
369 git_try.extend([arg for bot in config.cl_bot_list for arg in ('-b', bot)])
370
371 branch_name = git_utils.git_branch_name(vsp.verbose)
372
373 if config.skip_cl_upload:
374 space = ' '
375 print 'You should call:'
376 print '%scd %s' % (space, os.getcwd())
377 misc_utils.print_subprocess_args(space, [git, 'checkout', branch_name])
378 misc_utils.print_subprocess_args(space, git_cl)
379 if config.cl_bot_list:
380 misc_utils.print_subprocess_args(space, git_try)
381 print
382 return ''
383 else:
384 vsp.check_call(git_cl)
385 issue = vsp.strip_output([git, 'cl', 'issue'])
386 if config.cl_bot_list:
387 vsp.check_call(git_try)
388 return issue
389
390
halcanary@google.com31fdb922014-01-06 19:50:22 +0000391def roll_deps(config, revision, git_hash):
392 """Upload changed DEPS and a whitespace change.
393
394 Given the correct git_hash, create two Reitveld issues.
395
396 Args:
397 config: (roll_deps.DepsRollConfig) object containing options.
398 revision: (int) Skia SVN revision.
399 git_hash: (string) Skia Git hash.
400
401 Returns:
402 a tuple containing textual description of the two issues.
403
404 Raises:
405 OSError: failed to execute git or git-cl.
406 subprocess.CalledProcessError: git returned unexpected status.
407 """
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000408
halcanary@google.com31fdb922014-01-06 19:50:22 +0000409 git = config.git
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +0000410 with misc_utils.ChangeDir(config.chromium_path, config.verbose):
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000411 config.vsp.check_call([git, 'fetch', '-q', 'origin'])
412
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +0000413 old_revision = misc_utils.ReSearch.search_within_output(
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000414 config.verbose, '"skia_revision": "(?P<return>[0-9]+)",', None,
415 [git, 'show', 'origin/master:DEPS'])
416 assert old_revision
417 if revision == int(old_revision):
418 print 'DEPS is up to date!'
419 return None
420
421 master_hash = config.vsp.strip_output(
halcanary@google.com31fdb922014-01-06 19:50:22 +0000422 [git, 'show-ref', 'origin/master', '--hash'])
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000423 master_revision = get_svn_revision(config, 'origin/master')
424
halcanary@google.com31fdb922014-01-06 19:50:22 +0000425 # master_hash[8] gives each whitespace CL a unique name.
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +0000426 if config.save_branches:
427 branch = 'control_%s' % master_hash[:8]
428 else:
429 branch = None
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000430 message = ('whitespace change %s\n\n'
431 'Chromium base revision: %d / %s\n\n'
432 'This CL was created by Skia\'s roll_deps.py script.\n'
433 ) % (master_hash[:8], master_revision, master_hash[:8])
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +0000434 with git_utils.ChangeGitBranch(branch, 'origin/master',
435 config.verbose):
436 branch = git_utils.git_branch_name(config.vsp.verbose)
halcanary@google.com31fdb922014-01-06 19:50:22 +0000437
halcanary@google.com31fdb922014-01-06 19:50:22 +0000438 with open('build/whitespace_file.txt', 'a') as output_stream:
439 output_stream.write('\nCONTROL\n')
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000440
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +0000441 whitespace_cl = git_cl_uploader(
442 config, message, ['build/whitespace_file.txt'])
443
444 control_url = misc_utils.ReSearch.search_within_string(
445 whitespace_cl, '(?P<return>https?://[^) ]+)', '?')
446 if config.save_branches:
447 whitespace_cl = '%s\n branch: %s' % (whitespace_cl, branch)
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000448
449 if config.save_branches:
450 branch = 'roll_%d_%s' % (revision, master_hash[:8])
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +0000451 else:
452 branch = None
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000453 message = (
454 'roll skia DEPS to %d\n\n'
455 'Chromium base revision: %d / %s\n'
456 'Old Skia revision: %s\n'
457 'New Skia revision: %d\n'
458 'Control CL: %s\n\n'
commit-bot@chromium.org06cd6c12014-01-27 22:42:51 +0000459 'This CL was created by Skia\'s roll_deps.py script.\n\n'
460 'Bypassing commit queue trybots:\n'
461 'NOTRY=true\n'
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000462 % (revision, master_revision, master_hash[:8],
463 old_revision, revision, control_url))
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +0000464 with git_utils.ChangeGitBranch(branch, 'origin/master',
465 config.verbose):
466 branch = git_utils.git_branch_name(config.vsp.verbose)
467
halcanary@google.com31fdb922014-01-06 19:50:22 +0000468 change_skia_deps(revision, git_hash, 'DEPS')
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +0000469 deps_cl = git_cl_uploader(config, message, ['DEPS'])
470 if config.save_branches:
471 deps_cl = '%s\n branch: %s' % (deps_cl, branch)
halcanary@google.com31fdb922014-01-06 19:50:22 +0000472
473 return deps_cl, whitespace_cl
halcanary@google.com31fdb922014-01-06 19:50:22 +0000474
475
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000476def find_hash_and_roll_deps(config, revision=None, partial_hash=None):
halcanary@google.com31fdb922014-01-06 19:50:22 +0000477 """Call find_hash_from_revision() and roll_deps().
478
479 The calls to git will be verbose on standard output. After a
480 successful upload of both issues, print links to the new
481 codereview issues.
482
483 Args:
484 config: (roll_deps.DepsRollConfig) object containing options.
485 revision: (int or None) the Skia SVN revision number or None
486 to use the tip of the tree.
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000487 partial_hash: (string or None) a partial pure-git Skia commit
488 hash. Don't pass both partial_hash and revision.
halcanary@google.com31fdb922014-01-06 19:50:22 +0000489
490 Raises:
491 roll_deps.DepsRollError: if the revision can't be found.
492 OSError: failed to execute git or git-cl.
493 subprocess.CalledProcessError: git returned unexpected status.
494 """
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000495
496 if revision and partial_hash:
497 raise DepsRollError('Pass revision or partial_hash, not both.')
498
499 if partial_hash:
500 revision, git_hash = revision_and_hash_from_partial(
501 config, partial_hash)
502 elif revision:
503 revision, git_hash = revision_and_hash_from_revision(config, revision)
504 else:
505 revision, git_hash = revision_and_hash(config)
halcanary@google.com31fdb922014-01-06 19:50:22 +0000506
507 print 'revision=%r\nhash=%r\n' % (revision, git_hash)
508
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000509 roll = roll_deps(config, revision, git_hash)
halcanary@google.com31fdb922014-01-06 19:50:22 +0000510
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000511 if roll:
512 deps_issue, whitespace_issue = roll
513 print 'DEPS roll:\n %s\n' % deps_issue
514 print 'Whitespace change:\n %s\n' % whitespace_issue
halcanary@google.com31fdb922014-01-06 19:50:22 +0000515
516
517def main(args):
518 """main function; see module-level docstring and GetOptionParser help.
519
520 Args:
521 args: sys.argv[1:]-type argument list.
522 """
523 option_parser = DepsRollConfig.GetOptionParser()
524 options = option_parser.parse_args(args)[0]
525
526 if not options.chromium_path:
527 option_parser.error('Must specify chromium_path.')
528 if not os.path.isdir(options.chromium_path):
529 option_parser.error('chromium_path must be a directory.')
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +0000530
531 if not git_utils.git_executable():
halcanary@google.com31fdb922014-01-06 19:50:22 +0000532 option_parser.error('Invalid git executable.')
533
534 config = DepsRollConfig(options)
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000535 find_hash_and_roll_deps(config, options.revision, options.git_hash)
halcanary@google.com31fdb922014-01-06 19:50:22 +0000536
537
538if __name__ == '__main__':
539 main(sys.argv[1:])
540