| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 """Enables directory-specific presubmit checks to run at upload and/or commit. | 6 """Enables directory-specific presubmit checks to run at upload and/or commit. |
| 7 """ | 7 """ |
| 8 | 8 |
| 9 __version__ = '1.5' | 9 __version__ = '1.5' |
| 10 | 10 |
| 11 # TODO(joi) Add caching where appropriate/needed. The API is designed to allow | 11 # TODO(joi) Add caching where appropriate/needed. The API is designed to allow |
| 12 # caching (between all different invocations of presubmit scripts for a given | 12 # caching (between all different invocations of presubmit scripts for a given |
| 13 # change). We should add it as our presubmit scripts start feeling slow. | 13 # change). We should add it as our presubmit scripts start feeling slow. |
| 14 | 14 |
| 15 import cPickle # Exposed through the API. | 15 import cPickle # Exposed through the API. |
| 16 import cStringIO # Exposed through the API. | 16 import cStringIO # Exposed through the API. |
| 17 import exceptions | 17 import exceptions |
| 18 import fnmatch | 18 import fnmatch |
| 19 import glob | 19 import glob |
| 20 import logging | 20 import logging |
| 21 import marshal # Exposed through the API. | 21 import marshal # Exposed through the API. |
| 22 import optparse | 22 import optparse |
| 23 import os # Somewhat exposed through the API. | 23 import os # Somewhat exposed through the API. |
| 24 import pickle # Exposed through the API. | 24 import pickle # Exposed through the API. |
| 25 import random | 25 import random |
| 26 import re # Exposed through the API. | 26 import re # Exposed through the API. |
| 27 import subprocess # Exposed through the API. | |
| 28 import sys # Parts exposed through API. | 27 import sys # Parts exposed through API. |
| 29 import tempfile # Exposed through the API. | 28 import tempfile # Exposed through the API. |
| 30 import time | 29 import time |
| 31 import traceback # Exposed through the API. | 30 import traceback # Exposed through the API. |
| 32 import types | 31 import types |
| 33 import unittest # Exposed through the API. | 32 import unittest # Exposed through the API. |
| 34 import urllib2 # Exposed through the API. | 33 import urllib2 # Exposed through the API. |
| 35 from warnings import warn | 34 from warnings import warn |
| 36 | 35 |
| 37 try: | 36 try: |
| 38 import simplejson as json # pylint: disable=F0401 | 37 import simplejson as json # pylint: disable=F0401 |
| 39 except ImportError: | 38 except ImportError: |
| 40 try: | 39 try: |
| 41 import json # pylint: disable=F0401 | 40 import json # pylint: disable=F0401 |
| 42 except ImportError: | 41 except ImportError: |
| 43 # Import the one included in depot_tools. | 42 # Import the one included in depot_tools. |
| 44 sys.path.append(os.path.join(os.path.dirname(__file__), 'third_party')) | 43 sys.path.append(os.path.join(os.path.dirname(__file__), 'third_party')) |
| 45 import simplejson as json # pylint: disable=F0401 | 44 import simplejson as json # pylint: disable=F0401 |
| 46 | 45 |
| 47 # Local imports. | 46 # Local imports. |
| 48 import fix_encoding | 47 import fix_encoding |
| 49 import gclient_utils | 48 import gclient_utils |
| 50 import owners | 49 import owners |
| 51 import presubmit_canned_checks | 50 import presubmit_canned_checks |
| 52 import scm | 51 import scm |
| 52 import subprocess2 as subprocess # Exposed through the API. |
| 53 | 53 |
| 54 | 54 |
| 55 # Ask for feedback only once in program lifetime. | 55 # Ask for feedback only once in program lifetime. |
| 56 _ASKED_FOR_FEEDBACK = False | 56 _ASKED_FOR_FEEDBACK = False |
| 57 | 57 |
| 58 | 58 |
| 59 class NotImplementedException(Exception): | 59 class NotImplementedException(Exception): |
| 60 """We're leaving placeholders in a bunch of places to remind us of the | 60 """We're leaving placeholders in a bunch of places to remind us of the |
| 61 design of the API, but we have not implemented all of it yet. Implement as | 61 design of the API, but we have not implemented all of it yet. Implement as |
| 62 the need arises. | 62 the need arises. |
| (...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 sys.stdout, | 1192 sys.stdout, |
| 1193 sys.stdin, | 1193 sys.stdin, |
| 1194 options.default_presubmit, | 1194 options.default_presubmit, |
| 1195 options.may_prompt) | 1195 options.may_prompt) |
| 1196 return not results.should_continue() | 1196 return not results.should_continue() |
| 1197 | 1197 |
| 1198 | 1198 |
| 1199 if __name__ == '__main__': | 1199 if __name__ == '__main__': |
| 1200 fix_encoding.fix_encoding() | 1200 fix_encoding.fix_encoding() |
| 1201 sys.exit(Main(None)) | 1201 sys.exit(Main(None)) |
| OLD | NEW |