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 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 | |
|
M-A Ruel
2012/10/16 14:15:00
Make it protected.
Isaac (away)
2012/10/17 08:19:05
I set this in a different class.
| |
| 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.""" |
| 234 return max(self.parent.recursion_limit - 1, 0) | 238 return self.recursion_override or max(self.parent.recursion_limit - 1, 0) |
|
M-A Ruel
2012/10/16 14:15:00
It could be 0, which would be valid, so check if t
Isaac (away)
2012/10/17 08:19:05
Done.
| |
| 235 | 239 |
| 236 def get_custom_deps(self, name, url): | 240 def get_custom_deps(self, name, url): |
| 237 """Returns a custom deps if applicable.""" | 241 """Returns a custom deps if applicable.""" |
| 238 if self.parent: | 242 if self.parent: |
| 239 url = self.parent.get_custom_deps(name, url) | 243 url = self.parent.get_custom_deps(name, url) |
| 240 # None is a valid return value to disable a dependency. | 244 # None is a valid return value to disable a dependency. |
| 241 return self.custom_deps.get(name, url) | 245 return self.custom_deps.get(name, url) |
| 242 | 246 |
| 243 | 247 |
| 244 class Dependency(gclient_utils.WorkItem, DependencySettings): | 248 class Dependency(gclient_utils.WorkItem, DependencySettings): |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 438 self.name, self.deps_file, filepath)) | 442 self.name, self.deps_file, filepath)) |
| 439 else: | 443 else: |
| 440 deps_content = gclient_utils.FileRead(filepath) | 444 deps_content = gclient_utils.FileRead(filepath) |
| 441 logging.debug('ParseDepsFile(%s) read:\n%s' % (self.name, deps_content)) | 445 logging.debug('ParseDepsFile(%s) read:\n%s' % (self.name, deps_content)) |
| 442 # Eval the content. | 446 # Eval the content. |
| 443 try: | 447 try: |
| 444 exec(deps_content, global_scope, local_scope) | 448 exec(deps_content, global_scope, local_scope) |
| 445 except SyntaxError, e: | 449 except SyntaxError, e: |
| 446 gclient_utils.SyntaxErrorToError(filepath, e) | 450 gclient_utils.SyntaxErrorToError(filepath, e) |
| 447 deps = local_scope.get('deps', {}) | 451 deps = local_scope.get('deps', {}) |
| 452 if 'recursion' in local_scope: | |
| 453 self.recursion_override = local_scope['recursion'] | |
|
M-A Ruel
2012/10/16 14:15:00
local_scope.get('recursion')
Isaac (away)
2012/10/17 08:19:05
Done.
| |
| 454 logging.warning( | |
| 455 'Setting %s recursion to %d.', self.name, self.recursion_limit) | |
| 448 # load os specific dependencies if defined. these dependencies may | 456 # load os specific dependencies if defined. these dependencies may |
| 449 # override or extend the values defined by the 'deps' member. | 457 # override or extend the values defined by the 'deps' member. |
| 450 if 'deps_os' in local_scope: | 458 if 'deps_os' in local_scope: |
| 451 enforced_os = self.root.enforced_os | 459 enforced_os = self.root.enforced_os |
| 452 for deps_os_key in enforced_os: | 460 for deps_os_key in enforced_os: |
| 453 os_deps = local_scope['deps_os'].get(deps_os_key, {}) | 461 os_deps = local_scope['deps_os'].get(deps_os_key, {}) |
| 454 if len(enforced_os) > 1: | 462 if len(enforced_os) > 1: |
| 455 # Ignore any conflict when including deps for more than one | 463 # Ignore any conflict when including deps for more than one |
| 456 # platform, so we collect the broadest set of dependencies | 464 # platform, so we collect the broadest set of dependencies |
| 457 # available. We may end up with the wrong revision of something for | 465 # 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: | 1641 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
| 1634 print >> sys.stderr, 'Error: %s' % str(e) | 1642 print >> sys.stderr, 'Error: %s' % str(e) |
| 1635 return 1 | 1643 return 1 |
| 1636 | 1644 |
| 1637 | 1645 |
| 1638 if '__main__' == __name__: | 1646 if '__main__' == __name__: |
| 1639 fix_encoding.fix_encoding() | 1647 fix_encoding.fix_encoding() |
| 1640 sys.exit(Main(sys.argv[1:])) | 1648 sys.exit(Main(sys.argv[1:])) |
| 1641 | 1649 |
| 1642 # vim: ts=2:sw=2:tw=80:et: | 1650 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |