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 # This is currently only supported for top-level deps because gclient does | |
|
M-A Ruel
2012/10/17 11:08:25
Interesting note. I would have said it's just fine
Isaac (away)
2012/10/17 16:24:02
Here's an example of what I'm concerned about. Ma
M-A Ruel
2012/10/17 16:57:34
I'm pretty sure it's handled correctly. "deps3" is
| |
| 175 # not have logic for conflict handling where the same dep is specified | |
| 176 # twice, one in a non-overriden subtree and one in an overriden subtree. | |
| 177 # TODO(ilevy) Add recursion override support for non-top-level deps. | |
| 178 self.recursion_override = None | |
| 171 | 179 |
| 172 # These are only set in .gclient and not in DEPS files. | 180 # These are only set in .gclient and not in DEPS files. |
| 173 self._custom_vars = custom_vars or {} | 181 self._custom_vars = custom_vars or {} |
| 174 self._custom_deps = custom_deps or {} | 182 self._custom_deps = custom_deps or {} |
| 175 | 183 |
| 176 # Post process the url to remove trailing slashes. | 184 # Post process the url to remove trailing slashes. |
| 177 if isinstance(self._url, basestring): | 185 if isinstance(self._url, basestring): |
| 178 # urls are sometime incorrectly written as proto://host/path/@rev. Replace | 186 # urls are sometime incorrectly written as proto://host/path/@rev. Replace |
| 179 # it to proto://host/path@rev. | 187 # it to proto://host/path@rev. |
| 180 self._url = self._url.replace('/@', '@') | 188 self._url = self._url.replace('/@', '@') |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 def custom_deps(self): | 232 def custom_deps(self): |
| 225 return self._custom_deps.copy() | 233 return self._custom_deps.copy() |
| 226 | 234 |
| 227 @property | 235 @property |
| 228 def url(self): | 236 def url(self): |
| 229 return self._url | 237 return self._url |
| 230 | 238 |
| 231 @property | 239 @property |
| 232 def recursion_limit(self): | 240 def recursion_limit(self): |
| 233 """Returns > 0 if this dependency is not too recursed to be processed.""" | 241 """Returns > 0 if this dependency is not too recursed to be processed.""" |
| 242 if self.recursion_override is not None: | |
| 243 return self.recursion_override | |
| 234 return max(self.parent.recursion_limit - 1, 0) | 244 return max(self.parent.recursion_limit - 1, 0) |
| 235 | 245 |
| 236 def get_custom_deps(self, name, url): | 246 def get_custom_deps(self, name, url): |
| 237 """Returns a custom deps if applicable.""" | 247 """Returns a custom deps if applicable.""" |
| 238 if self.parent: | 248 if self.parent: |
| 239 url = self.parent.get_custom_deps(name, url) | 249 url = self.parent.get_custom_deps(name, url) |
| 240 # None is a valid return value to disable a dependency. | 250 # None is a valid return value to disable a dependency. |
| 241 return self.custom_deps.get(name, url) | 251 return self.custom_deps.get(name, url) |
| 242 | 252 |
| 243 | 253 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 438 self.name, self.deps_file, filepath)) | 448 self.name, self.deps_file, filepath)) |
| 439 else: | 449 else: |
| 440 deps_content = gclient_utils.FileRead(filepath) | 450 deps_content = gclient_utils.FileRead(filepath) |
| 441 logging.debug('ParseDepsFile(%s) read:\n%s' % (self.name, deps_content)) | 451 logging.debug('ParseDepsFile(%s) read:\n%s' % (self.name, deps_content)) |
| 442 # Eval the content. | 452 # Eval the content. |
| 443 try: | 453 try: |
| 444 exec(deps_content, global_scope, local_scope) | 454 exec(deps_content, global_scope, local_scope) |
| 445 except SyntaxError, e: | 455 except SyntaxError, e: |
| 446 gclient_utils.SyntaxErrorToError(filepath, e) | 456 gclient_utils.SyntaxErrorToError(filepath, e) |
| 447 deps = local_scope.get('deps', {}) | 457 deps = local_scope.get('deps', {}) |
| 458 if 'recursion' in local_scope: | |
|
M-A Ruel
2012/10/17 11:08:25
No need to "if" that. local_scope.get('recursion')
Isaac (away)
2012/10/17 16:24:02
I want the if for the logging line, though.
| |
| 459 self.recursion_override = local_scope.get('recursion') | |
| 460 logging.warning( | |
| 461 'Setting %s recursion to %d.', self.name, self.recursion_limit) | |
| 448 # load os specific dependencies if defined. these dependencies may | 462 # load os specific dependencies if defined. these dependencies may |
| 449 # override or extend the values defined by the 'deps' member. | 463 # override or extend the values defined by the 'deps' member. |
| 450 if 'deps_os' in local_scope: | 464 if 'deps_os' in local_scope: |
| 451 enforced_os = self.root.enforced_os | 465 enforced_os = self.root.enforced_os |
| 452 for deps_os_key in enforced_os: | 466 for deps_os_key in enforced_os: |
| 453 os_deps = local_scope['deps_os'].get(deps_os_key, {}) | 467 os_deps = local_scope['deps_os'].get(deps_os_key, {}) |
| 454 if len(enforced_os) > 1: | 468 if len(enforced_os) > 1: |
| 455 # Ignore any conflict when including deps for more than one | 469 # Ignore any conflict when including deps for more than one |
| 456 # platform, so we collect the broadest set of dependencies | 470 # platform, so we collect the broadest set of dependencies |
| 457 # available. We may end up with the wrong revision of something for | 471 # 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: | 1647 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
| 1634 print >> sys.stderr, 'Error: %s' % str(e) | 1648 print >> sys.stderr, 'Error: %s' % str(e) |
| 1635 return 1 | 1649 return 1 |
| 1636 | 1650 |
| 1637 | 1651 |
| 1638 if '__main__' == __name__: | 1652 if '__main__' == __name__: |
| 1639 fix_encoding.fix_encoding() | 1653 fix_encoding.fix_encoding() |
| 1640 sys.exit(Main(sys.argv[1:])) | 1654 sys.exit(Main(sys.argv[1:])) |
| 1641 | 1655 |
| 1642 # vim: ts=2:sw=2:tw=80:et: | 1656 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |