Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Unified Diff: presubmit_support.py

Issue 8059009: Support for |change| argument to |GetPreferredTrySlaves()|, try 2. (Closed) Base URL: http://src.chromium.org/svn/trunk/tools/depot_tools/
Patch Set: '' Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « git_try.py ('k') | tests/presubmit_unittest.py » ('j') | trychange.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: presubmit_support.py
===================================================================
--- presubmit_support.py (revision 102922)
+++ presubmit_support.py (working copy)
@@ -16,6 +16,7 @@
import cStringIO # Exposed through the API.
import fnmatch
import glob
+import inspect
import logging
import marshal # Exposed through the API.
import optparse
@@ -875,7 +876,7 @@
class GetTrySlavesExecuter(object):
@staticmethod
- def ExecPresubmitScript(script_text, presubmit_path, project):
+ def ExecPresubmitScript(script_text, presubmit_path, project, change):
"""Executes GetPreferredTrySlaves() from a single presubmit script.
Args:
@@ -894,10 +895,14 @@
function_name = 'GetPreferredTrySlaves'
if function_name in context:
- try:
- result = eval(function_name + '(' + repr(project) + ')', context)
- except TypeError:
- result = eval(function_name + '()', context)
+ get_preferred_try_slaves = context[function_name]
+ function_info = inspect.getargspec(get_preferred_try_slaves)
+ if len(function_info[0]) == 1:
+ result = get_preferred_try_slaves(project)
+ elif len(function_info[0]) == 2:
+ result = get_preferred_try_slaves(project, change)
+ else:
+ result = get_preferred_try_slaves()
if not isinstance(result, types.ListType):
raise PresubmitFailure(
'Presubmit functions must return a list, got a %s instead: %s' %
@@ -913,7 +918,8 @@
return result
-def DoGetTrySlaves(changed_files,
+def DoGetTrySlaves(change,
+ changed_files,
repository_root,
default_presubmit,
project,
@@ -942,7 +948,7 @@
output_stream.write("Running default presubmit script.\n")
fake_path = os.path.join(repository_root, 'PRESUBMIT.py')
results += executer.ExecPresubmitScript(
- default_presubmit, fake_path, project)
+ default_presubmit, fake_path, project, change)
for filename in presubmit_files:
filename = os.path.abspath(filename)
if verbose:
@@ -950,7 +956,7 @@
# Accept CRLF presubmit script.
presubmit_script = gclient_utils.FileRead(filename, 'rU')
results += executer.ExecPresubmitScript(
- presubmit_script, filename, project)
+ presubmit_script, filename, project, change)
slaves = list(set(results))
if slaves and verbose:
« no previous file with comments | « git_try.py ('k') | tests/presubmit_unittest.py » ('j') | trychange.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698