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

Unified Diff: gclient.py

Issue 9560010: Rework gclient 'recurse' command to use a WorkQueue. (Closed) Base URL: http://src.chromium.org/svn/trunk/tools/depot_tools/
Patch Set: Created 8 years, 10 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 124337)
+++ gclient.py (working copy)
@@ -1121,6 +1121,32 @@
return client.RunOnDeps('cleanup', args)
+class Entry(gclient_utils.WorkItem):
M-A Ruel 2012/03/01 14:12:12 I'm a tad uncomfortable with this class. I'd rathe
+ """Object that represents a gclient entry."""
+
+ def __init__(self, name, scm, cwd, url):
+ gclient_utils.WorkItem.__init__(self, name)
+ self._scm = scm
+ self._cwd = cwd
+ self._url = url
+ self.requirements = {}
+
+ # Arguments number differs from overridden method
+ # pylint: disable=W0221
+ def run(self, revision_overrides, command, args, work_queue, options):
+ """Executes a command in a given module."""
+ assert command == 'exec'
+ # Pass in the SCM type as an env variable
+ env = os.environ.copy()
+ if self._scm:
+ env['GCLIENT_SCM'] = self._scm
+ if self._url:
+ env['GCLIENT_URL'] = self._url
+ if os.path.isdir(self._cwd):
+ subprocess2.call(args, cwd=self._cwd, env=env)
davidbarr 2012/03/01 05:33:15 Maybe this should be a wrapper method provided by
+ else:
+ print >> sys.stderr, 'Skipped missing %s' % self._cwd
+
davidbarr 2012/03/01 05:33:15 Whitespace nit.
@attr('usage', '[command] [args ...]')
def CMDrecurse(parser, args):
"""Operates on all the entries.
@@ -1131,7 +1157,6 @@
parser.disable_interspersed_args()
parser.add_option('-s', '--scm', action='append', default=[],
help='choose scm types to operate upon')
- parser.remove_option('--jobs')
options, args = parser.parse_args(args)
if not args:
print >> sys.stderr, 'Need to supply a command!'
@@ -1147,22 +1172,18 @@
for scm in options.scm:
scm_set.update(scm.split(','))
- # Pass in the SCM type as an env variable
- env = os.environ.copy()
-
+ pm = None
+ # Disable progress for non-tty stdout.
+ if (sys.stdout.isatty() and not options.verbose):
+ pm = Progress(' '.join(args), 1)
+ work_queue = gclient_utils.ExecutionQueue(options.jobs, pm)
for path, url in entries.iteritems():
scm = gclient_scm.GetScmName(url)
if scm_set and scm not in scm_set:
continue
cwd = os.path.normpath(os.path.join(root, path))
- if scm:
- env['GCLIENT_SCM'] = scm
- if url:
- env['GCLIENT_URL'] = url
- if os.path.isdir(cwd):
- subprocess2.call(args, cwd=cwd, env=env)
- else:
- print >> sys.stderr, 'Skipped missing %s' % cwd
+ work_queue.enqueue(Entry(path, scm, cwd, url))
+ work_queue.flush({}, 'exec', args, options=options)
return 0
@@ -1172,8 +1193,8 @@
Completely git-specific. Simply runs 'git fetch [args ...]' for each module.
"""
- (_, args) = parser.parse_args(args)
- args = ['-s', 'git', 'git', 'fetch'] + args
+ (options, args) = parser.parse_args(args)
+ args = ['-j%d' % options.jobs, '-s', 'git', 'git', 'fetch'] + args
davidbarr 2012/03/01 05:33:15 Is this necessary? Will the parser accumulate opti
return CMDrecurse(parser, args)
« 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