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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 self._deps_file = deps_file | 161 self._deps_file = deps_file |
162 self._url = url | 162 self._url = url |
163 # 'managed' determines whether or not this dependency is synced/updated by | 163 # 'managed' determines whether or not this dependency is synced/updated by |
164 # gclient after gclient checks it out initially. The difference between | 164 # gclient after gclient checks it out initially. The difference between |
165 # 'managed' and 'should_process' is that the user specifies 'managed' via | 165 # 'managed' and 'should_process' is that the user specifies 'managed' via |
166 # the --unmanaged command-line flag or a .gclient config, where | 166 # the --unmanaged command-line flag or a .gclient config, where |
167 # 'should_process' is dynamically set by gclient if it goes over its | 167 # 'should_process' is dynamically set by gclient if it goes over its |
168 # recursion limit and controls gclient's behavior so it does not misbehave. | 168 # recursion limit and controls gclient's behavior so it does not misbehave. |
169 self._managed = managed | 169 self._managed = managed |
170 self._should_process = should_process | 170 self._should_process = should_process |
| 171 # This is a mutable value that overrides the normal recursion limit for this |
| 172 # dependency. It is read from the actual DEPS file so cannot be set on |
| 173 # class instantiation. |
| 174 self.recursion_override = None |
171 | 175 |
172 # These are only set in .gclient and not in DEPS files. | 176 # These are only set in .gclient and not in DEPS files. |
173 self._custom_vars = custom_vars or {} | 177 self._custom_vars = custom_vars or {} |
174 self._custom_deps = custom_deps or {} | 178 self._custom_deps = custom_deps or {} |
175 | 179 |
176 # Post process the url to remove trailing slashes. | 180 # Post process the url to remove trailing slashes. |
177 if isinstance(self._url, basestring): | 181 if isinstance(self._url, basestring): |
178 # urls are sometime incorrectly written as proto://host/path/@rev. Replace | 182 # urls are sometime incorrectly written as proto://host/path/@rev. Replace |
179 # it to proto://host/path@rev. | 183 # it to proto://host/path@rev. |
180 self._url = self._url.replace('/@', '@') | 184 self._url = self._url.replace('/@', '@') |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 def custom_deps(self): | 228 def custom_deps(self): |
225 return self._custom_deps.copy() | 229 return self._custom_deps.copy() |
226 | 230 |
227 @property | 231 @property |
228 def url(self): | 232 def url(self): |
229 return self._url | 233 return self._url |
230 | 234 |
231 @property | 235 @property |
232 def recursion_limit(self): | 236 def recursion_limit(self): |
233 """Returns > 0 if this dependency is not too recursed to be processed.""" | 237 """Returns > 0 if this dependency is not too recursed to be processed.""" |
| 238 if self.recursion_override is not None: |
| 239 return self.recursion_override |
234 return max(self.parent.recursion_limit - 1, 0) | 240 return max(self.parent.recursion_limit - 1, 0) |
235 | 241 |
236 def get_custom_deps(self, name, url): | 242 def get_custom_deps(self, name, url): |
237 """Returns a custom deps if applicable.""" | 243 """Returns a custom deps if applicable.""" |
238 if self.parent: | 244 if self.parent: |
239 url = self.parent.get_custom_deps(name, url) | 245 url = self.parent.get_custom_deps(name, url) |
240 # None is a valid return value to disable a dependency. | 246 # None is a valid return value to disable a dependency. |
241 return self.custom_deps.get(name, url) | 247 return self.custom_deps.get(name, url) |
242 | 248 |
243 | 249 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 self.name, self.deps_file, filepath)) | 444 self.name, self.deps_file, filepath)) |
439 else: | 445 else: |
440 deps_content = gclient_utils.FileRead(filepath) | 446 deps_content = gclient_utils.FileRead(filepath) |
441 logging.debug('ParseDepsFile(%s) read:\n%s' % (self.name, deps_content)) | 447 logging.debug('ParseDepsFile(%s) read:\n%s' % (self.name, deps_content)) |
442 # Eval the content. | 448 # Eval the content. |
443 try: | 449 try: |
444 exec(deps_content, global_scope, local_scope) | 450 exec(deps_content, global_scope, local_scope) |
445 except SyntaxError, e: | 451 except SyntaxError, e: |
446 gclient_utils.SyntaxErrorToError(filepath, e) | 452 gclient_utils.SyntaxErrorToError(filepath, e) |
447 deps = local_scope.get('deps', {}) | 453 deps = local_scope.get('deps', {}) |
| 454 if 'recursion' in local_scope: |
| 455 self.recursion_override = local_scope.get('recursion') |
| 456 logging.warning( |
| 457 'Setting %s recursion to %d.', self.name, self.recursion_limit) |
448 # load os specific dependencies if defined. these dependencies may | 458 # load os specific dependencies if defined. these dependencies may |
449 # override or extend the values defined by the 'deps' member. | 459 # override or extend the values defined by the 'deps' member. |
450 if 'deps_os' in local_scope: | 460 if 'deps_os' in local_scope: |
451 enforced_os = self.root.enforced_os | 461 enforced_os = self.root.enforced_os |
452 for deps_os_key in enforced_os: | 462 for deps_os_key in enforced_os: |
453 os_deps = local_scope['deps_os'].get(deps_os_key, {}) | 463 os_deps = local_scope['deps_os'].get(deps_os_key, {}) |
454 if len(enforced_os) > 1: | 464 if len(enforced_os) > 1: |
455 # Ignore any conflict when including deps for more than one | 465 # Ignore any conflict when including deps for more than one |
456 # platform, so we collect the broadest set of dependencies | 466 # platform, so we collect the broadest set of dependencies |
457 # available. We may end up with the wrong revision of something for | 467 # available. We may end up with the wrong revision of something for |
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1633 except (gclient_utils.Error, subprocess2.CalledProcessError), e: | 1643 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
1634 print >> sys.stderr, 'Error: %s' % str(e) | 1644 print >> sys.stderr, 'Error: %s' % str(e) |
1635 return 1 | 1645 return 1 |
1636 | 1646 |
1637 | 1647 |
1638 if '__main__' == __name__: | 1648 if '__main__' == __name__: |
1639 fix_encoding.fix_encoding() | 1649 fix_encoding.fix_encoding() |
1640 sys.exit(Main(sys.argv[1:])) | 1650 sys.exit(Main(sys.argv[1:])) |
1641 | 1651 |
1642 # vim: ts=2:sw=2:tw=80:et: | 1652 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |