blob: 07b1c007bacc6cda35e5eb209e7b1e653f1e3a74 [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
commit-bot@chromium.org86876082014-03-14 15:50:39 +0000368 git_try = [
369 git, 'cl', 'try', '-m', 'tryserver.chromium', '--revision', svn_info]
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +0000370 git_try.extend([arg for bot in config.cl_bot_list for arg in ('-b', bot)])
371
372 branch_name = git_utils.git_branch_name(vsp.verbose)
373
374 if config.skip_cl_upload:
375 space = ' '
376 print 'You should call:'
377 print '%scd %s' % (space, os.getcwd())
378 misc_utils.print_subprocess_args(space, [git, 'checkout', branch_name])
379 misc_utils.print_subprocess_args(space, git_cl)
380 if config.cl_bot_list:
381 misc_utils.print_subprocess_args(space, git_try)
382 print
383 return ''
384 else:
385 vsp.check_call(git_cl)
386 issue = vsp.strip_output([git, 'cl', 'issue'])
387 if config.cl_bot_list:
388 vsp.check_call(git_try)
389 return issue
390
391
halcanary@google.com31fdb922014-01-06 19:50:22 +0000392def roll_deps(config, revision, git_hash):
393 """Upload changed DEPS and a whitespace change.
394
395 Given the correct git_hash, create two Reitveld issues.
396
397 Args:
398 config: (roll_deps.DepsRollConfig) object containing options.
399 revision: (int) Skia SVN revision.
400 git_hash: (string) Skia Git hash.
401
402 Returns:
403 a tuple containing textual description of the two issues.
404
405 Raises:
406 OSError: failed to execute git or git-cl.
407 subprocess.CalledProcessError: git returned unexpected status.
408 """
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000409
halcanary@google.com31fdb922014-01-06 19:50:22 +0000410 git = config.git
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +0000411 with misc_utils.ChangeDir(config.chromium_path, config.verbose):
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000412 config.vsp.check_call([git, 'fetch', '-q', 'origin'])
413
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +0000414 old_revision = misc_utils.ReSearch.search_within_output(
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000415 config.verbose, '"skia_revision": "(?P<return>[0-9]+)",', None,
416 [git, 'show', 'origin/master:DEPS'])
417 assert old_revision
418 if revision == int(old_revision):
419 print 'DEPS is up to date!'
commit-bot@chromium.org1b948192014-03-03 17:57:41 +0000420 return (None, None)
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000421
422 master_hash = config.vsp.strip_output(
halcanary@google.com31fdb922014-01-06 19:50:22 +0000423 [git, 'show-ref', 'origin/master', '--hash'])
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000424 master_revision = get_svn_revision(config, 'origin/master')
425
halcanary@google.com31fdb922014-01-06 19:50:22 +0000426 # master_hash[8] gives each whitespace CL a unique name.
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +0000427 if config.save_branches:
428 branch = 'control_%s' % master_hash[:8]
429 else:
430 branch = None
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000431 message = ('whitespace change %s\n\n'
432 'Chromium base revision: %d / %s\n\n'
433 'This CL was created by Skia\'s roll_deps.py script.\n'
434 ) % (master_hash[:8], master_revision, master_hash[:8])
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +0000435 with git_utils.ChangeGitBranch(branch, 'origin/master',
436 config.verbose):
437 branch = git_utils.git_branch_name(config.vsp.verbose)
halcanary@google.com31fdb922014-01-06 19:50:22 +0000438
halcanary@google.com31fdb922014-01-06 19:50:22 +0000439 with open('build/whitespace_file.txt', 'a') as output_stream:
440 output_stream.write('\nCONTROL\n')
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000441
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +0000442 whitespace_cl = git_cl_uploader(
443 config, message, ['build/whitespace_file.txt'])
444
445 control_url = misc_utils.ReSearch.search_within_string(
446 whitespace_cl, '(?P<return>https?://[^) ]+)', '?')
447 if config.save_branches:
448 whitespace_cl = '%s\n branch: %s' % (whitespace_cl, branch)
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000449
450 if config.save_branches:
451 branch = 'roll_%d_%s' % (revision, master_hash[:8])
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +0000452 else:
453 branch = None
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000454 message = (
455 'roll skia DEPS to %d\n\n'
456 'Chromium base revision: %d / %s\n'
457 'Old Skia revision: %s\n'
458 'New Skia revision: %d\n'
459 'Control CL: %s\n\n'
commit-bot@chromium.org06cd6c12014-01-27 22:42:51 +0000460 'This CL was created by Skia\'s roll_deps.py script.\n\n'
461 'Bypassing commit queue trybots:\n'
462 'NOTRY=true\n'
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000463 % (revision, master_revision, master_hash[:8],
464 old_revision, revision, control_url))
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +0000465 with git_utils.ChangeGitBranch(branch, 'origin/master',
466 config.verbose):
467 branch = git_utils.git_branch_name(config.vsp.verbose)
468
halcanary@google.com31fdb922014-01-06 19:50:22 +0000469 change_skia_deps(revision, git_hash, 'DEPS')
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +0000470 deps_cl = git_cl_uploader(config, message, ['DEPS'])
471 if config.save_branches:
472 deps_cl = '%s\n branch: %s' % (deps_cl, branch)
halcanary@google.com31fdb922014-01-06 19:50:22 +0000473
474 return deps_cl, whitespace_cl
halcanary@google.com31fdb922014-01-06 19:50:22 +0000475
476
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000477def find_hash_and_roll_deps(config, revision=None, partial_hash=None):
halcanary@google.com31fdb922014-01-06 19:50:22 +0000478 """Call find_hash_from_revision() and roll_deps().
479
480 The calls to git will be verbose on standard output. After a
481 successful upload of both issues, print links to the new
482 codereview issues.
483
484 Args:
485 config: (roll_deps.DepsRollConfig) object containing options.
486 revision: (int or None) the Skia SVN revision number or None
487 to use the tip of the tree.
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000488 partial_hash: (string or None) a partial pure-git Skia commit
489 hash. Don't pass both partial_hash and revision.
halcanary@google.com31fdb922014-01-06 19:50:22 +0000490
491 Raises:
492 roll_deps.DepsRollError: if the revision can't be found.
493 OSError: failed to execute git or git-cl.
494 subprocess.CalledProcessError: git returned unexpected status.
495 """
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000496
497 if revision and partial_hash:
498 raise DepsRollError('Pass revision or partial_hash, not both.')
499
500 if partial_hash:
501 revision, git_hash = revision_and_hash_from_partial(
502 config, partial_hash)
503 elif revision:
504 revision, git_hash = revision_and_hash_from_revision(config, revision)
505 else:
506 revision, git_hash = revision_and_hash(config)
halcanary@google.com31fdb922014-01-06 19:50:22 +0000507
508 print 'revision=%r\nhash=%r\n' % (revision, git_hash)
509
commit-bot@chromium.org1b948192014-03-03 17:57:41 +0000510 deps_issue, whitespace_issue = roll_deps(config, revision, git_hash)
halcanary@google.com31fdb922014-01-06 19:50:22 +0000511
commit-bot@chromium.org1b948192014-03-03 17:57:41 +0000512 if deps_issue and whitespace_issue:
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000513 print 'DEPS roll:\n %s\n' % deps_issue
514 print 'Whitespace change:\n %s\n' % whitespace_issue
commit-bot@chromium.org1b948192014-03-03 17:57:41 +0000515 else:
516 print >> sys.stderr, 'No issues created.'
halcanary@google.com31fdb922014-01-06 19:50:22 +0000517
518
519def main(args):
520 """main function; see module-level docstring and GetOptionParser help.
521
522 Args:
523 args: sys.argv[1:]-type argument list.
524 """
525 option_parser = DepsRollConfig.GetOptionParser()
526 options = option_parser.parse_args(args)[0]
527
528 if not options.chromium_path:
529 option_parser.error('Must specify chromium_path.')
530 if not os.path.isdir(options.chromium_path):
531 option_parser.error('chromium_path must be a directory.')
commit-bot@chromium.org0ed90022014-01-30 22:12:30 +0000532
533 if not git_utils.git_executable():
halcanary@google.com31fdb922014-01-06 19:50:22 +0000534 option_parser.error('Invalid git executable.')
535
536 config = DepsRollConfig(options)
halcanary@google.com8c5d2c12014-01-08 21:29:34 +0000537 find_hash_and_roll_deps(config, options.revision, options.git_hash)
halcanary@google.com31fdb922014-01-06 19:50:22 +0000538
539
540if __name__ == '__main__':
541 main(sys.argv[1:])
542