Index: gclient.py |
=================================================================== |
--- gclient.py (revision 124577) |
+++ gclient.py (working copy) |
@@ -525,7 +525,7 @@ |
# When running runhooks, there's no need to consult the SCM. |
# All known hooks are expected to run unconditionally regardless of working |
# copy state, so skip the SCM status check. |
- run_scm = command not in ('runhooks', None) |
+ run_scm = command not in ('runhooks', 'recurse', None) |
davidbarr
2012/03/02 03:21:55
It felt a bit too tricky to implicitly rely on thi
|
parsed_url = self.LateOverride(self.url) |
file_list = [] |
if run_scm and parsed_url: |
@@ -565,6 +565,22 @@ |
# Strip any leading path separators. |
while file_list[i].startswith(('\\', '/')): |
file_list[i] = file_list[i][1:] |
+ elif command is 'recurse': |
+ if not isinstance(parsed_url, self.FileImpl): |
+ # Skip file only checkout. |
+ scm = gclient_scm.GetScmName(parsed_url) |
+ if not options.scm or scm in options.scm: |
+ cwd = os.path.normpath(os.path.join(self.root.root_dir, self.name)) |
+ # Pass in the SCM type as an env variable |
+ env = os.environ.copy() |
+ if scm: |
+ env['GCLIENT_SCM'] = scm |
+ if parsed_url: |
+ env['GCLIENT_URL'] = parsed_url |
+ if os.path.isdir(cwd): |
+ gclient_utils.CheckCallAndFilterAndHeader(args, cwd=cwd, env=env) |
+ else: |
+ print >> sys.stderr, 'Skipped missing %s' % cwd |
# Always parse the DEPS file. |
self.ParseDepsFile() |
@@ -965,12 +981,16 @@ |
""" |
if not self.dependencies: |
raise gclient_utils.Error('No solution specified') |
- revision_overrides = self._EnforceRevisions() |
+ revision_overrides = {} |
+ if command is not 'recurse': |
+ revision_overrides = self._EnforceRevisions() |
davidbarr
2012/03/02 03:21:55
Is _EnforceRevisions() necessary in the 'recurse'
M-A Ruel
2012/03/02 14:25:30
Just add a comment that it's not strictly necessar
|
pm = None |
# Disable progress for non-tty stdout. |
- if (command in ('update', 'revert') and sys.stdout.isatty() and not |
- self._options.verbose): |
- pm = Progress('Syncing projects', 1) |
+ if (sys.stdout.isatty() and not self._options.verbose): |
+ if command in ('update', 'revert'): |
+ pm = Progress('Syncing projects', 1) |
+ elif command is 'recurse': |
+ pm = Progress(' '.join(args), 1) |
work_queue = gclient_utils.ExecutionQueue(self._options.jobs, pm) |
for s in self.dependencies: |
work_queue.enqueue(s) |
@@ -1131,7 +1151,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!' |
@@ -1142,38 +1161,26 @@ |
'You need to run gclient sync at least once to use \'recurse\'.\n' |
'This is because .gclient_entries needs to exist and be up to date.') |
return 1 |
- root, entries = root_and_entries |
+ |
+ # Normalize options.scm to a set() |
scm_set = set() |
for scm in options.scm: |
scm_set.update(scm.split(',')) |
+ options.scm = scm_set |
- # Pass in the SCM type as an env variable |
- env = os.environ.copy() |
+ options.nohooks = True |
+ client = GClient.LoadCurrentConfig(options) |
+ return client.RunOnDeps('recurse', args) |
- 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 |
- return 0 |
- |
@attr('usage', '[args ...]') |
def CMDfetch(parser, args): |
"""Fetches upstream commits for all modules. |
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 |
return CMDrecurse(parser, args) |