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 # Files | 7 # Files |
| 8 # .gclient : Current client configuration, written by 'config' command. | 8 # .gclient : Current client configuration, written by 'config' command. |
| 9 # Format is a Python script defining 'solutions', a list whose | 9 # Format is a Python script defining 'solutions', a list whose |
| 10 # entries each are maps binding the strings "name" and "url" | 10 # entries each are maps binding the strings "name" and "url" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 self._deps_file = deps_file | 171 self._deps_file = deps_file |
| 172 self._url = url | 172 self._url = url |
| 173 # 'managed' determines whether or not this dependency is synced/updated by | 173 # 'managed' determines whether or not this dependency is synced/updated by |
| 174 # gclient after gclient checks it out initially. The difference between | 174 # gclient after gclient checks it out initially. The difference between |
| 175 # 'managed' and 'should_process' is that the user specifies 'managed' via | 175 # 'managed' and 'should_process' is that the user specifies 'managed' via |
| 176 # the --unmanaged command-line flag or a .gclient config, where | 176 # the --unmanaged command-line flag or a .gclient config, where |
| 177 # 'should_process' is dynamically set by gclient if it goes over its | 177 # 'should_process' is dynamically set by gclient if it goes over its |
| 178 # recursion limit and controls gclient's behavior so it does not misbehave. | 178 # recursion limit and controls gclient's behavior so it does not misbehave. |
| 179 self._managed = managed | 179 self._managed = managed |
| 180 self._should_process = should_process | 180 self._should_process = should_process |
| 181 # This is a mutable value that overrides the normal recursion limit for this | |
| 182 # dependency. It is read from the actual DEPS file so cannot be set on | |
| 183 # class instantiation. | |
| 184 self.recursion_override = None | |
| 185 # This is a mutable value which has the list of 'target_os' OSes listed in | 181 # This is a mutable value which has the list of 'target_os' OSes listed in |
| 186 # the current deps file. | 182 # the current deps file. |
| 187 self.local_target_os = None | 183 self.local_target_os = None |
| 188 | 184 |
| 189 # These are only set in .gclient and not in DEPS files. | 185 # These are only set in .gclient and not in DEPS files. |
| 190 self._custom_vars = custom_vars or {} | 186 self._custom_vars = custom_vars or {} |
| 191 self._custom_deps = custom_deps or {} | 187 self._custom_deps = custom_deps or {} |
| 192 self._custom_hooks = custom_hooks or [] | 188 self._custom_hooks = custom_hooks or [] |
| 193 | 189 |
| 194 # TODO(iannucci): Remove this when all masters are correctly substituting | 190 # TODO(iannucci): Remove this when all masters are correctly substituting |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 | 248 |
| 253 @property | 249 @property |
| 254 def custom_hooks(self): | 250 def custom_hooks(self): |
| 255 return self._custom_hooks[:] | 251 return self._custom_hooks[:] |
| 256 | 252 |
| 257 @property | 253 @property |
| 258 def url(self): | 254 def url(self): |
| 259 return self._url | 255 return self._url |
| 260 | 256 |
| 261 @property | 257 @property |
| 262 def recursion_limit(self): | |
| 263 """Returns > 0 if this dependency is not too recursed to be processed.""" | |
| 264 if self.recursion_override is not None: | |
| 265 return self.recursion_override | |
| 266 return max(self.parent.recursion_limit - 1, 0) | |
| 267 | |
| 268 @property | |
| 269 def target_os(self): | 258 def target_os(self): |
| 270 if self.local_target_os is not None: | 259 if self.local_target_os is not None: |
| 271 return tuple(set(self.local_target_os).union(self.parent.target_os)) | 260 return tuple(set(self.local_target_os).union(self.parent.target_os)) |
| 272 else: | 261 else: |
| 273 return self.parent.target_os | 262 return self.parent.target_os |
| 274 | 263 |
| 275 def get_custom_deps(self, name, url): | 264 def get_custom_deps(self, name, url): |
| 276 """Returns a custom deps if applicable.""" | 265 """Returns a custom deps if applicable.""" |
| 277 if self.parent: | 266 if self.parent: |
| 278 url = self.parent.get_custom_deps(name, url) | 267 url = self.parent.get_custom_deps(name, url) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 # This dependency had its hook run | 300 # This dependency had its hook run |
| 312 self._hooks_ran = False | 301 self._hooks_ran = False |
| 313 # This is the scm used to checkout self.url. It may be used by dependencies | 302 # This is the scm used to checkout self.url. It may be used by dependencies |
| 314 # to get the datetime of the revision we checked out. | 303 # to get the datetime of the revision we checked out. |
| 315 self._used_scm = None | 304 self._used_scm = None |
| 316 self._used_revision = None | 305 self._used_revision = None |
| 317 # The actual revision we ended up getting, or None if that information is | 306 # The actual revision we ended up getting, or None if that information is |
| 318 # unavailable | 307 # unavailable |
| 319 self._got_revision = None | 308 self._got_revision = None |
| 320 | 309 |
| 310 # This is a mutable value that overrides the normal recursion limit for this | |
| 311 # dependency. It is read from the actual DEPS file so cannot be set on | |
| 312 # class instantiation. | |
| 313 self.recursion_override = None | |
| 314 # recurselist is a mutable value that selectively overrides the default | |
| 315 # 'no recursion' setting on a dep-by-dep basis. It will replace | |
| 316 # recursion_override. | |
| 317 self.recurselist = None | |
| 318 | |
| 321 if not self.name and self.parent: | 319 if not self.name and self.parent: |
| 322 raise gclient_utils.Error('Dependency without name') | 320 raise gclient_utils.Error('Dependency without name') |
| 323 | 321 |
| 324 @property | 322 @property |
| 325 def requirements(self): | 323 def requirements(self): |
| 326 """Calculate the list of requirements.""" | 324 """Calculate the list of requirements.""" |
| 327 requirements = set() | 325 requirements = set() |
| 328 # self.parent is implicitly a requirement. This will be recursive by | 326 # self.parent is implicitly a requirement. This will be recursive by |
| 329 # definition. | 327 # definition. |
| 330 if self.parent and self.parent.name: | 328 if self.parent and self.parent.name: |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 350 if self.name: | 348 if self.name: |
| 351 requirements |= set( | 349 requirements |= set( |
| 352 obj.name for obj in self.root.subtree(False) | 350 obj.name for obj in self.root.subtree(False) |
| 353 if (obj is not self | 351 if (obj is not self |
| 354 and obj.name and | 352 and obj.name and |
| 355 self.name.startswith(posixpath.join(obj.name, '')))) | 353 self.name.startswith(posixpath.join(obj.name, '')))) |
| 356 requirements = tuple(sorted(requirements)) | 354 requirements = tuple(sorted(requirements)) |
| 357 logging.info('Dependency(%s).requirements = %s' % (self.name, requirements)) | 355 logging.info('Dependency(%s).requirements = %s' % (self.name, requirements)) |
| 358 return requirements | 356 return requirements |
| 359 | 357 |
| 358 @property | |
| 359 def try_recurselist(self): | |
| 360 """Returns False if recursion_override is ever specified.""" | |
| 361 if self.recursion_override is not None: | |
| 362 return False | |
| 363 return self.parent.try_recurselist | |
| 364 | |
| 365 @property | |
| 366 def recursion_limit(self): | |
| 367 """Returns > 0 if this dependency is not too recursed to be processed.""" | |
| 368 # We continue to support the absence of recurselist until tools and DEPS | |
| 369 # using recursion_override are updated. | |
| 370 if self.try_recurselist and self.parent.recurselist != None: | |
| 371 if self.name in self.parent.recurselist: | |
| 372 return 1 | |
| 373 | |
| 374 if self.recursion_override is not None: | |
| 375 return self.recursion_override | |
| 376 return max(self.parent.recursion_limit - 1, 0) | |
| 377 | |
| 360 def verify_validity(self): | 378 def verify_validity(self): |
| 361 """Verifies that this Dependency is fine to add as a child of another one. | 379 """Verifies that this Dependency is fine to add as a child of another one. |
| 362 | 380 |
| 363 Returns True if this entry should be added, False if it is a duplicate of | 381 Returns True if this entry should be added, False if it is a duplicate of |
| 364 another entry. | 382 another entry. |
| 365 """ | 383 """ |
| 366 logging.info('Dependency(%s).verify_validity()' % self.name) | 384 logging.info('Dependency(%s).verify_validity()' % self.name) |
| 367 if self.name in [s.name for s in self.parent.dependencies]: | 385 if self.name in [s.name for s in self.parent.dependencies]: |
| 368 raise gclient_utils.Error( | 386 raise gclient_utils.Error( |
| 369 'The same name "%s" appears multiple times in the deps section' % | 387 'The same name "%s" appears multiple times in the deps section' % |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 556 if not isinstance(val, (dict, list, tuple, str)): | 574 if not isinstance(val, (dict, list, tuple, str)): |
| 557 raise gclient_utils.Error( | 575 raise gclient_utils.Error( |
| 558 'ParseDepsFile(%s): Strict mode disallows %r -> %r' % | 576 'ParseDepsFile(%s): Strict mode disallows %r -> %r' % |
| 559 (self.name, key, val)) | 577 (self.name, key, val)) |
| 560 | 578 |
| 561 deps = local_scope.get('deps', {}) | 579 deps = local_scope.get('deps', {}) |
| 562 if 'recursion' in local_scope: | 580 if 'recursion' in local_scope: |
| 563 self.recursion_override = local_scope.get('recursion') | 581 self.recursion_override = local_scope.get('recursion') |
| 564 logging.warning( | 582 logging.warning( |
| 565 'Setting %s recursion to %d.', self.name, self.recursion_limit) | 583 'Setting %s recursion to %d.', self.name, self.recursion_limit) |
| 584 self.recurselist = local_scope.get('recurselist', None) | |
|
iannucci
2014/06/30 23:37:04
nit: I would have preferred recurselist actually b
| |
| 585 if 'recurselist' in local_scope: | |
| 586 logging.warning('Found recurselist %r.', repr(self.recurselist)) | |
| 566 # If present, save 'target_os' in the local_target_os property. | 587 # If present, save 'target_os' in the local_target_os property. |
| 567 if 'target_os' in local_scope: | 588 if 'target_os' in local_scope: |
| 568 self.local_target_os = local_scope['target_os'] | 589 self.local_target_os = local_scope['target_os'] |
| 569 # load os specific dependencies if defined. these dependencies may | 590 # load os specific dependencies if defined. these dependencies may |
| 570 # override or extend the values defined by the 'deps' member. | 591 # override or extend the values defined by the 'deps' member. |
| 571 target_os_list = self.target_os | 592 target_os_list = self.target_os |
| 572 if 'deps_os' in local_scope and target_os_list: | 593 if 'deps_os' in local_scope and target_os_list: |
| 573 deps = self.MergeWithOsDeps(deps, local_scope['deps_os'], target_os_list) | 594 deps = self.MergeWithOsDeps(deps, local_scope['deps_os'], target_os_list) |
| 574 | 595 |
| 575 # If a line is in custom_deps, but not in the solution, we want to append | 596 # If a line is in custom_deps, but not in the solution, we want to append |
| (...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1450 def enforced_os(self): | 1471 def enforced_os(self): |
| 1451 """What deps_os entries that are to be parsed.""" | 1472 """What deps_os entries that are to be parsed.""" |
| 1452 return self._enforced_os | 1473 return self._enforced_os |
| 1453 | 1474 |
| 1454 @property | 1475 @property |
| 1455 def recursion_limit(self): | 1476 def recursion_limit(self): |
| 1456 """How recursive can each dependencies in DEPS file can load DEPS file.""" | 1477 """How recursive can each dependencies in DEPS file can load DEPS file.""" |
| 1457 return self._recursion_limit | 1478 return self._recursion_limit |
| 1458 | 1479 |
| 1459 @property | 1480 @property |
| 1481 def try_recurselist(self): | |
| 1482 """Whether to attempt using recurselist-style recursion processing.""" | |
| 1483 return True | |
| 1484 | |
| 1485 @property | |
| 1460 def target_os(self): | 1486 def target_os(self): |
| 1461 return self._enforced_os | 1487 return self._enforced_os |
| 1462 | 1488 |
| 1463 | 1489 |
| 1464 #### gclient commands. | 1490 #### gclient commands. |
| 1465 | 1491 |
| 1466 | 1492 |
| 1467 def CMDcleanup(parser, args): | 1493 def CMDcleanup(parser, args): |
| 1468 """Cleans up all working copies. | 1494 """Cleans up all working copies. |
| 1469 | 1495 |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2007 print >> sys.stderr, 'Error: %s' % str(e) | 2033 print >> sys.stderr, 'Error: %s' % str(e) |
| 2008 return 1 | 2034 return 1 |
| 2009 finally: | 2035 finally: |
| 2010 gclient_utils.PrintWarnings() | 2036 gclient_utils.PrintWarnings() |
| 2011 | 2037 |
| 2012 | 2038 |
| 2013 if '__main__' == __name__: | 2039 if '__main__' == __name__: |
| 2014 sys.exit(Main(sys.argv[1:])) | 2040 sys.exit(Main(sys.argv[1:])) |
| 2015 | 2041 |
| 2016 # vim: ts=2:sw=2:tw=80:et: | 2042 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |