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

Unified Diff: gclient_utils.py

Issue 11312116: Add gclient grep for git repos (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 8 years, 1 month 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 | « gclient.py ('k') | tests/gclient_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient_utils.py
diff --git a/gclient_utils.py b/gclient_utils.py
index 78fa7222adc4bae3d8c8696186ecc38352d5a8f8..0eeb185dc1481335ec9b4e5c885a585760d80485 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -192,29 +192,31 @@ def safe_makedirs(tree):
raise
-def CheckCallAndFilterAndHeader(args, always=False, **kwargs):
+def CheckCallAndFilterAndHeader(args, always=False, header=None, **kwargs):
"""Adds 'header' support to CheckCallAndFilter.
If |always| is True, a message indicating what is being done
is printed to stdout all the time even if not output is generated. Otherwise
the message header is printed only if the call generated any ouput.
"""
- stdout = kwargs.get('stdout', None) or sys.stdout
+ stdout = kwargs.setdefault('stdout', sys.stdout)
+ if header is None:
+ header = "\n________ running '%s' in '%s'\n" % (
+ ' '.join(args), kwargs.get('cwd', '.'))
+
if always:
- stdout.write('\n________ running \'%s\' in \'%s\'\n'
- % (' '.join(args), kwargs.get('cwd', '.')))
+ stdout.write(header)
else:
- filter_fn = kwargs.get('filter_fn', None)
+ filter_fn = kwargs.get('filter_fn')
def filter_msg(line):
if line is None:
- stdout.write('\n________ running \'%s\' in \'%s\'\n'
- % (' '.join(args), kwargs.get('cwd', '.')))
+ stdout.write(header)
elif filter_fn:
filter_fn(line)
kwargs['filter_fn'] = filter_msg
kwargs['call_filter_on_first_line'] = True
# Obviously.
- kwargs['print_stdout'] = True
+ kwargs.setdefault('print_stdout', True)
return CheckCallAndFilter(args, **kwargs)
@@ -450,7 +452,7 @@ def PathDifference(root, subpath):
def FindFileUpwards(filename, path=None):
"""Search upwards from the a directory (default: current) to find a file.
-
+
Returns nearest upper-level directory with the passed in file.
"""
if not path:
@@ -526,7 +528,7 @@ class ExecutionQueue(object):
Methods of this class are thread safe.
"""
- def __init__(self, jobs, progress):
+ def __init__(self, jobs, progress, ignore_requirements):
"""jobs specifies the number of concurrent tasks to allow. progress is a
Progress instance."""
# Set when a thread is done or a new item is enqueued.
@@ -546,6 +548,8 @@ class ExecutionQueue(object):
if self.progress:
self.progress.update(0)
+ self.ignore_requirements = ignore_requirements
+
def enqueue(self, d):
"""Enqueue one Dependency to be executed later once its requirements are
satisfied.
@@ -583,11 +587,8 @@ class ExecutionQueue(object):
# Check for new tasks to start.
for i in xrange(len(self.queued)):
# Verify its requirements.
- for r in self.queued[i].requirements:
- if not r in self.ran:
- # Requirement not met.
- break
- else:
+ if (self.ignore_requirements or
+ not (set(self.queued[i].requirements) - set(self.ran))):
# Start one work item: all its requirements are satisfied.
self._run_one_task(self.queued.pop(i), args, kwargs)
break
« no previous file with comments | « gclient.py ('k') | tests/gclient_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698