Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Meta checkout manager supporting both Subversion and GIT. | 6 """Meta checkout manager supporting both Subversion and GIT. |
| 7 | 7 |
| 8 Files | 8 Files |
| 9 .gclient : Current client configuration, written by 'config' command. | 9 .gclient : Current client configuration, written by 'config' command. |
| 10 Format is a Python script defining 'solutions', a list whose | 10 Format is a Python script defining 'solutions', a list whose |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 558 for i in range(len(file_list)): | 558 for i in range(len(file_list)): |
| 559 # It depends on the command being executed (like runhooks vs sync). | 559 # It depends on the command being executed (like runhooks vs sync). |
| 560 if not os.path.isabs(file_list[i]): | 560 if not os.path.isabs(file_list[i]): |
| 561 continue | 561 continue |
| 562 prefix = os.path.commonprefix( | 562 prefix = os.path.commonprefix( |
| 563 [self.root.root_dir.lower(), file_list[i].lower()]) | 563 [self.root.root_dir.lower(), file_list[i].lower()]) |
| 564 file_list[i] = file_list[i][len(prefix):] | 564 file_list[i] = file_list[i][len(prefix):] |
| 565 # Strip any leading path separators. | 565 # Strip any leading path separators. |
| 566 while file_list[i].startswith(('\\', '/')): | 566 while file_list[i].startswith(('\\', '/')): |
| 567 file_list[i] = file_list[i][1:] | 567 file_list[i] = file_list[i][1:] |
| 568 elif command is None and args: | |
| 569 # Used by CMDrecurse to run an arbitrary command | |
| 570 if not isinstance(parsed_url, self.FileImpl): | |
| 571 # Skip file only checkout. | |
| 572 scm = gclient_scm.GetScmName(parsed_url) | |
| 573 if not options.scm or scm in options.scm: | |
| 574 cwd = os.path.normpath(os.path.join(self.root.root_dir, self.name)) | |
| 575 # Pass in the SCM type as an env variable | |
| 576 env = os.environ.copy() | |
| 577 if scm: | |
| 578 env['GCLIENT_SCM'] = scm | |
| 579 if parsed_url: | |
| 580 env['GCLIENT_URL'] = parsed_url | |
| 581 if os.path.isdir(cwd): | |
| 582 gclient_utils.CheckCallAndFilterAndHeader(args, cwd=cwd, env=env) | |
|
davidbarr
2012/03/02 01:23:05
Now the output is handled nicely.
| |
| 583 else: | |
| 584 print >> sys.stderr, 'Skipped missing %s' % cwd | |
| 568 | 585 |
| 569 # Always parse the DEPS file. | 586 # Always parse the DEPS file. |
| 570 self.ParseDepsFile() | 587 self.ParseDepsFile() |
| 571 | 588 |
| 572 self._run_is_done(file_list, parsed_url) | 589 self._run_is_done(file_list, parsed_url) |
| 573 | 590 |
| 574 if self.recursion_limit: | 591 if self.recursion_limit: |
| 575 # Parse the dependencies of this dependency. | 592 # Parse the dependencies of this dependency. |
| 576 for s in self.dependencies: | 593 for s in self.dependencies: |
| 577 work_queue.enqueue(s) | 594 work_queue.enqueue(s) |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1124 @attr('usage', '[command] [args ...]') | 1141 @attr('usage', '[command] [args ...]') |
| 1125 def CMDrecurse(parser, args): | 1142 def CMDrecurse(parser, args): |
| 1126 """Operates on all the entries. | 1143 """Operates on all the entries. |
| 1127 | 1144 |
| 1128 Runs a shell command on all entries. | 1145 Runs a shell command on all entries. |
| 1129 """ | 1146 """ |
| 1130 # Stop parsing at the first non-arg so that these go through to the command | 1147 # Stop parsing at the first non-arg so that these go through to the command |
| 1131 parser.disable_interspersed_args() | 1148 parser.disable_interspersed_args() |
| 1132 parser.add_option('-s', '--scm', action='append', default=[], | 1149 parser.add_option('-s', '--scm', action='append', default=[], |
| 1133 help='choose scm types to operate upon') | 1150 help='choose scm types to operate upon') |
| 1134 parser.remove_option('--jobs') | |
| 1135 options, args = parser.parse_args(args) | 1151 options, args = parser.parse_args(args) |
| 1136 if not args: | 1152 if not args: |
| 1137 print >> sys.stderr, 'Need to supply a command!' | 1153 print >> sys.stderr, 'Need to supply a command!' |
| 1138 return 1 | 1154 return 1 |
| 1139 root_and_entries = gclient_utils.GetGClientRootAndEntries() | 1155 root_and_entries = gclient_utils.GetGClientRootAndEntries() |
| 1140 if not root_and_entries: | 1156 if not root_and_entries: |
| 1141 print >> sys.stderr, ( | 1157 print >> sys.stderr, ( |
| 1142 'You need to run gclient sync at least once to use \'recurse\'.\n' | 1158 'You need to run gclient sync at least once to use \'recurse\'.\n' |
| 1143 'This is because .gclient_entries needs to exist and be up to date.') | 1159 'This is because .gclient_entries needs to exist and be up to date.') |
| 1144 return 1 | 1160 return 1 |
| 1145 root, entries = root_and_entries | 1161 |
| 1162 # Normalize options.scm to a set() | |
| 1146 scm_set = set() | 1163 scm_set = set() |
| 1147 for scm in options.scm: | 1164 for scm in options.scm: |
| 1148 scm_set.update(scm.split(',')) | 1165 scm_set.update(scm.split(',')) |
| 1166 options.scm = scm_set | |
| 1149 | 1167 |
| 1150 # Pass in the SCM type as an env variable | 1168 client = GClient.LoadCurrentConfig(options) |
| 1151 env = os.environ.copy() | 1169 pm = None |
|
M-A Ruel
2012/03/02 01:40:37
Replace lines 1168-1176 with:
options.nohooks = Tr
| |
| 1152 | 1170 # Disable progress for non-tty stdout. |
| 1153 for path, url in entries.iteritems(): | 1171 if (sys.stdout.isatty() and not options.verbose): |
| 1154 scm = gclient_scm.GetScmName(url) | 1172 pm = Progress(' '.join(args), 1) |
| 1155 if scm_set and scm not in scm_set: | 1173 work_queue = gclient_utils.ExecutionQueue(options.jobs, pm) |
| 1156 continue | 1174 for s in client.dependencies: |
| 1157 cwd = os.path.normpath(os.path.join(root, path)) | 1175 work_queue.enqueue(s) |
| 1158 if scm: | 1176 work_queue.flush({}, None, args, options=options) |
| 1159 env['GCLIENT_SCM'] = scm | |
| 1160 if url: | |
| 1161 env['GCLIENT_URL'] = url | |
| 1162 if os.path.isdir(cwd): | |
| 1163 subprocess2.call(args, cwd=cwd, env=env) | |
| 1164 else: | |
| 1165 print >> sys.stderr, 'Skipped missing %s' % cwd | |
| 1166 return 0 | 1177 return 0 |
| 1167 | 1178 |
| 1168 | 1179 |
| 1169 @attr('usage', '[args ...]') | 1180 @attr('usage', '[args ...]') |
| 1170 def CMDfetch(parser, args): | 1181 def CMDfetch(parser, args): |
| 1171 """Fetches upstream commits for all modules. | 1182 """Fetches upstream commits for all modules. |
| 1172 | 1183 |
| 1173 Completely git-specific. Simply runs 'git fetch [args ...]' for each module. | 1184 Completely git-specific. Simply runs 'git fetch [args ...]' for each module. |
| 1174 """ | 1185 """ |
| 1175 (_, args) = parser.parse_args(args) | 1186 (options, args) = parser.parse_args(args) |
| 1176 args = ['-s', 'git', 'git', 'fetch'] + args | 1187 args = ['-j%d' % options.jobs, '-s', 'git', 'git', 'fetch'] + args |
|
davidbarr
2012/03/02 01:23:05
This still makes me uncomfortable, but there isn't
| |
| 1177 return CMDrecurse(parser, args) | 1188 return CMDrecurse(parser, args) |
| 1178 | 1189 |
| 1179 | 1190 |
| 1180 @attr('usage', '[url] [safesync url]') | 1191 @attr('usage', '[url] [safesync url]') |
| 1181 def CMDconfig(parser, args): | 1192 def CMDconfig(parser, args): |
| 1182 """Create a .gclient file in the current directory. | 1193 """Create a .gclient file in the current directory. |
| 1183 | 1194 |
| 1184 This specifies the configuration for further commands. After update/sync, | 1195 This specifies the configuration for further commands. After update/sync, |
| 1185 top-level DEPS files in each module are read to determine dependent | 1196 top-level DEPS files in each module are read to determine dependent |
| 1186 modules to operate on as well. If optional [url] parameter is | 1197 modules to operate on as well. If optional [url] parameter is |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1549 except (gclient_utils.Error, subprocess2.CalledProcessError), e: | 1560 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
| 1550 print >> sys.stderr, 'Error: %s' % str(e) | 1561 print >> sys.stderr, 'Error: %s' % str(e) |
| 1551 return 1 | 1562 return 1 |
| 1552 | 1563 |
| 1553 | 1564 |
| 1554 if '__main__' == __name__: | 1565 if '__main__' == __name__: |
| 1555 fix_encoding.fix_encoding() | 1566 fix_encoding.fix_encoding() |
| 1556 sys.exit(Main(sys.argv[1:])) | 1567 sys.exit(Main(sys.argv[1:])) |
| 1557 | 1568 |
| 1558 # vim: ts=2:sw=2:tw=80:et: | 1569 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |