Chromium Code Reviews| 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 |
| """ |