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

Unified Diff: gclient.py

Issue 9232068: Added `gclient hookinfo`. This will be used to convert hooks into (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: '' Created 8 years, 11 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 119695)
+++ gclient.py (working copy)
@@ -585,10 +585,12 @@
self._parsed_url = parsed_url
self._processed = True
- def RunHooksRecursively(self, options):
+ def RunHooksRecursively(self, options, action=None):
"""Evaluates all hooks, running actions as needed. run()
M-A Ruel 2012/01/30 19:23:07 ... running |action| for each hook. or something l
szager 2012/01/31 00:22:20 Done.
must have been called before to load the DEPS."""
assert self.hooks_ran == False
+ if not action:
M-A Ruel 2012/01/30 19:23:07 action = action or self._RunHookAction
szager 2012/01/31 00:22:20 Done.
+ action = self._RunHookAction
if not self.should_process or not self.recursion_limit:
# Don't run the hook when it is above recursion_limit.
return
@@ -603,7 +605,7 @@
gclient_scm.GetScmName(self.parsed_url) in ('git', None) or
os.path.isdir(os.path.join(self.root.root_dir, self.name, '.git'))):
for hook_dict in self.deps_hooks:
- self._RunHookAction(hook_dict, [])
+ action(hook_dict, [])
else:
# Run hooks on the basis of whether the files from the gclient operation
# match each hook's pattern.
@@ -613,9 +615,9 @@
f for f in self.file_list_and_children if pattern.search(f)
]
if matching_file_list:
- self._RunHookAction(hook_dict, matching_file_list)
+ action(hook_dict, matching_file_list)
for s in self.dependencies:
- s.RunHooksRecursively(options)
+ s.RunHooksRecursively(options, action=action)
M-A Ruel 2012/01/30 19:23:07 My idea was to still call _RunHookAtion but add an
szager 2012/01/31 00:22:20 OK. Patch is now much bigger...
def _RunHookAction(self, hook_dict, matching_file_list):
"""Runs the action from a single hook."""
@@ -1080,6 +1082,21 @@
print('%s: %s' % (x, entries[x]))
logging.info(str(self))
+ def HookInfo(self):
+ work_queue = gclient_utils.ExecutionQueue(self._options.jobs, None)
+ for s in self.dependencies:
+ work_queue.enqueue(s)
+ work_queue.flush({}, None, [], options=self._options)
+ hooks = []
+ def _process_hook(hook_dict, matching_file_list):
+ command = hook_dict['action'][:]
+ if '$matching_files' in command:
+ splice_index = command.index('$matching_files')
+ command[splice_index:splice_index + 1] = matching_file_list
+ hooks.append(command)
+ self.RunHooksRecursively(self._options, action=_process_hook)
+ return hooks
+
def ParseDepsFile(self):
"""No DEPS to parse for a .gclient file."""
raise gclient_utils.Error('Internal error')
@@ -1423,6 +1440,17 @@
return 0
+def CMDhookinfo(parser, args):
+ """Output the hooks that would be run by `gclient runhooks`"""
+
+ (options, args) = parser.parse_args(args)
+ client = GClient.LoadCurrentConfig(options)
+ if not client:
+ raise gclient_utils.Error('client not configured; see \'gclient config\'')
+ print client.HookInfo()
+ return 0
+
+
def Command(name):
return getattr(sys.modules[__name__], 'CMD' + name, None)
« 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