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

Unified Diff: gclient.py

Issue 160294: Pass matching file list to the hook in gclient. (Closed) Base URL: http://src.chromium.org/svn/trunk/tools/depot_tools/
Patch Set: '' Created 11 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient.py
===================================================================
--- gclient.py (revision 22062)
+++ gclient.py (working copy)
@@ -55,7 +55,9 @@
The action is executed in the same directory as the .gclient
file. If the first item in the list is the string "python",
the current Python interpreter (sys.executable) will be used
- to run the command.
+ to run the command. If the list contains string "$matching_files"
+ it will be removed from the list and the list will be extended
+ by the list of matching files.
Example:
hooks = [
@@ -859,8 +861,8 @@
command.extend(['--revision', str(revision)])
RunSVNAndGetFileList(command, self._root_dir, file_list)
return
-
+
# If the provided url has a revision number that matches the revision
# number of the existing directory, then we don't need to bother updating.
if not options.force and from_info['Revision'] == revision:
@@ -1220,7 +1222,7 @@
deps[d] = url
return deps
- def _RunHookAction(self, hook_dict):
+ def _RunHookAction(self, hook_dict, matching_file_list):
"""Runs the action from a single hook.
"""
command = hook_dict['action'][:]
@@ -1230,6 +1232,10 @@
# interpreter.
command[0] = sys.executable
+ if '$matching_files' in command:
+ command.remove('$matching_files')
Mark Mentovai 2009/07/31 19:12:42 Don't you want to splice matching_file_list into t
+ command.extend(matching_file_list)
+
# Use a discrete exit status code of 2 to indicate that a hook action
# failed. Users of this script may wish to treat hook action failures
# differently from VC failures.
@@ -1256,23 +1262,17 @@
# changed so we always run all hooks.
if self._options.force or is_using_git:
for hook_dict in hooks:
- self._RunHookAction(hook_dict)
+ self._RunHookAction(hook_dict, [])
return
# Run hooks on the basis of whether the files from the gclient operation
# match each hook's pattern.
for hook_dict in hooks:
pattern = re.compile(hook_dict['pattern'])
- for file in file_list:
- if not pattern.search(file):
- continue
+ matching_file_list = [file for file in file_list if pattern.search(file)]
+ if matching_file_list:
+ self._RunHookAction(hook_dict, matching_file_list)
- self._RunHookAction(hook_dict)
-
- # The hook's action only runs once. Don't bother looking for any
- # more matches.
- break
-
def RunOnDeps(self, command, args):
"""Runs a command on each dependency in a client and its dependencies.
@@ -1552,7 +1552,7 @@
def DoExport(options, args):
"""Handle the export subcommand.
-
+
Raises:
Error: on usage error
"""
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698