Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> | 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> |
| 7 | 7 |
| 8 """A git-command for integrating reviews on Rietveld.""" | 8 """A git-command for integrating reviews on Rietveld.""" |
| 9 | 9 |
| 10 from distutils.version import LooseVersion | 10 from distutils.version import LooseVersion |
| (...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1375 log_args = [args[0][:-1]] | 1375 log_args = [args[0][:-1]] |
| 1376 elif len(args) == 2: | 1376 elif len(args) == 2: |
| 1377 log_args = [args[0] + '..' + args[1]] | 1377 log_args = [args[0] + '..' + args[1]] |
| 1378 else: | 1378 else: |
| 1379 log_args = args[:] # Hope for the best! | 1379 log_args = args[:] # Hope for the best! |
| 1380 return RunGit(['log', '--pretty=format:%s\n\n%b'] + log_args) | 1380 return RunGit(['log', '--pretty=format:%s\n\n%b'] + log_args) |
| 1381 | 1381 |
| 1382 | 1382 |
| 1383 def CMDlint(parser, args): | 1383 def CMDlint(parser, args): |
| 1384 """Runs cpplint on the current changelist.""" | 1384 """Runs cpplint on the current changelist.""" |
| 1385 _, args = parser.parse_args(args) | 1385 parser.add_option('--filter', action='append', default=[], metavar='-x,+y', |
| 1386 help='Comma-separated list of cpplint\'s category-filters') | |
| 1387 (options, args) = parser.parse_args(args) | |
| 1386 | 1388 |
| 1387 # Access to a protected member _XX of a client class | 1389 # Access to a protected member _XX of a client class |
| 1388 # pylint: disable=W0212 | 1390 # pylint: disable=W0212 |
| 1389 try: | 1391 try: |
| 1390 import cpplint | 1392 import cpplint |
| 1391 import cpplint_chromium | 1393 import cpplint_chromium |
| 1392 except ImportError: | 1394 except ImportError: |
| 1393 print "Your depot_tools is missing cpplint.py and/or cpplint_chromium.py." | 1395 print "Your depot_tools is missing cpplint.py and/or cpplint_chromium.py." |
| 1394 return 1 | 1396 return 1 |
| 1395 | 1397 |
| 1396 # Change the current working directory before calling lint so that it | 1398 # Change the current working directory before calling lint so that it |
| 1397 # shows the correct base. | 1399 # shows the correct base. |
| 1398 previous_cwd = os.getcwd() | 1400 previous_cwd = os.getcwd() |
| 1399 os.chdir(settings.GetRoot()) | 1401 os.chdir(settings.GetRoot()) |
| 1400 try: | 1402 try: |
| 1401 cl = Changelist() | 1403 cl = Changelist() |
| 1402 change = cl.GetChange(cl.GetCommonAncestorWithUpstream(), None) | 1404 change = cl.GetChange(cl.GetCommonAncestorWithUpstream(), None) |
| 1403 files = [f.LocalPath() for f in change.AffectedFiles()] | 1405 files = [f.LocalPath() for f in change.AffectedFiles()] |
| 1404 | 1406 |
| 1405 # Process cpplints arguments if any. | 1407 # Process cpplints arguments if any. |
| 1406 filenames = cpplint.ParseArguments(args + files) | 1408 filenames = cpplint.ParseArguments( |
| 1409 ['--filter=' + ','.join(options.filter)] + args + files) | |
|
Nico
2014/03/13 04:21:18
if options.filter has its default value of [], thi
tzik
2014/03/13 04:35:58
Ah, right. Absence of "--filter" means different t
| |
| 1407 | 1410 |
| 1408 white_regex = re.compile(settings.GetLintRegex()) | 1411 white_regex = re.compile(settings.GetLintRegex()) |
| 1409 black_regex = re.compile(settings.GetLintIgnoreRegex()) | 1412 black_regex = re.compile(settings.GetLintIgnoreRegex()) |
| 1410 extra_check_functions = [cpplint_chromium.CheckPointerDeclarationWhitespace] | 1413 extra_check_functions = [cpplint_chromium.CheckPointerDeclarationWhitespace] |
| 1411 for filename in filenames: | 1414 for filename in filenames: |
| 1412 if white_regex.match(filename): | 1415 if white_regex.match(filename): |
| 1413 if black_regex.match(filename): | 1416 if black_regex.match(filename): |
| 1414 print "Ignoring file %s" % filename | 1417 print "Ignoring file %s" % filename |
| 1415 else: | 1418 else: |
| 1416 cpplint.ProcessFile(filename, cpplint._cpplint_state.verbose_level, | 1419 cpplint.ProcessFile(filename, cpplint._cpplint_state.verbose_level, |
| (...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2526 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 2529 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
| 2527 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2530 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 2528 | 2531 |
| 2529 | 2532 |
| 2530 if __name__ == '__main__': | 2533 if __name__ == '__main__': |
| 2531 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2534 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 2532 # unit testing. | 2535 # unit testing. |
| 2533 fix_encoding.fix_encoding() | 2536 fix_encoding.fix_encoding() |
| 2534 colorama.init() | 2537 colorama.init() |
| 2535 sys.exit(main(sys.argv[1:])) | 2538 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |