Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: gclient.py

Issue 363103002: Update recurselist to be a set, call it recursedeps now. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: update syntax Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tests/gclient_test.py » ('j') | tests/gclient_test.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 self._used_scm = None 304 self._used_scm = None
305 self._used_revision = None 305 self._used_revision = None
306 # 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
307 # unavailable 307 # unavailable
308 self._got_revision = None 308 self._got_revision = None
309 309
310 # This is a mutable value that overrides the normal recursion limit for this 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 311 # dependency. It is read from the actual DEPS file so cannot be set on
312 # class instantiation. 312 # class instantiation.
313 self.recursion_override = None 313 self.recursion_override = None
314 # recurselist is a mutable value that selectively overrides the default 314 # recursedeps is a mutable value that selectively overrides the default
315 # 'no recursion' setting on a dep-by-dep basis. It will replace 315 # 'no recursion' setting on a dep-by-dep basis. It will replace
316 # recursion_override. 316 # recursion_override.
317 self.recurselist = None 317 self.recursedeps = None
318 318
319 if not self.name and self.parent: 319 if not self.name and self.parent:
320 raise gclient_utils.Error('Dependency without name') 320 raise gclient_utils.Error('Dependency without name')
321 321
322 @property 322 @property
323 def requirements(self): 323 def requirements(self):
324 """Calculate the list of requirements.""" 324 """Calculate the list of requirements."""
325 requirements = set() 325 requirements = set()
326 # self.parent is implicitly a requirement. This will be recursive by 326 # self.parent is implicitly a requirement. This will be recursive by
327 # definition. 327 # definition.
(...skipping 21 matching lines...) Expand all
349 requirements |= set( 349 requirements |= set(
350 obj.name for obj in self.root.subtree(False) 350 obj.name for obj in self.root.subtree(False)
351 if (obj is not self 351 if (obj is not self
352 and obj.name and 352 and obj.name and
353 self.name.startswith(posixpath.join(obj.name, '')))) 353 self.name.startswith(posixpath.join(obj.name, ''))))
354 requirements = tuple(sorted(requirements)) 354 requirements = tuple(sorted(requirements))
355 logging.info('Dependency(%s).requirements = %s' % (self.name, requirements)) 355 logging.info('Dependency(%s).requirements = %s' % (self.name, requirements))
356 return requirements 356 return requirements
357 357
358 @property 358 @property
359 def try_recurselist(self): 359 def try_recursedeps(self):
360 """Returns False if recursion_override is ever specified.""" 360 """Returns False if recursion_override is ever specified."""
361 if self.recursion_override is not None: 361 if self.recursion_override is not None:
362 return False 362 return False
363 return self.parent.try_recurselist 363 return self.parent.try_recursedeps
364 364
365 @property 365 @property
366 def recursion_limit(self): 366 def recursion_limit(self):
367 """Returns > 0 if this dependency is not too recursed to be processed.""" 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 368 # We continue to support the absence of recursedeps until tools and DEPS
369 # using recursion_override are updated. 369 # using recursion_override are updated.
370 if self.try_recurselist and self.parent.recurselist != None: 370 if self.try_recursedeps and self.parent.recursedeps != None:
371 if self.name in self.parent.recurselist: 371 if self.name in self.parent.recursedeps:
372 return 1 372 return 1
373 373
374 if self.recursion_override is not None: 374 if self.recursion_override is not None:
375 return self.recursion_override 375 return self.recursion_override
376 return max(self.parent.recursion_limit - 1, 0) 376 return max(self.parent.recursion_limit - 1, 0)
377 377
378 def verify_validity(self): 378 def verify_validity(self):
379 """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.
380 380
381 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
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 if not isinstance(val, (dict, list, tuple, str)): 586 if not isinstance(val, (dict, list, tuple, str)):
587 raise gclient_utils.Error( 587 raise gclient_utils.Error(
588 'ParseDepsFile(%s): Strict mode disallows %r -> %r' % 588 'ParseDepsFile(%s): Strict mode disallows %r -> %r' %
589 (self.name, key, val)) 589 (self.name, key, val))
590 590
591 deps = local_scope.get('deps', {}) 591 deps = local_scope.get('deps', {})
592 if 'recursion' in local_scope: 592 if 'recursion' in local_scope:
593 self.recursion_override = local_scope.get('recursion') 593 self.recursion_override = local_scope.get('recursion')
594 logging.warning( 594 logging.warning(
595 'Setting %s recursion to %d.', self.name, self.recursion_limit) 595 'Setting %s recursion to %d.', self.name, self.recursion_limit)
596 self.recurselist = local_scope.get('recurselist', None) 596 self.recursedeps = local_scope.get('recursedeps', None)
iannucci 2014/07/03 18:55:59 could also cast to a set here. If it's already a s
597 if 'recurselist' in local_scope: 597 if 'recursedeps' in local_scope:
598 logging.warning('Found recurselist %r.', repr(self.recurselist)) 598 logging.warning('Found recursedeps %r.', repr(self.recursedeps))
599 # If present, save 'target_os' in the local_target_os property. 599 # If present, save 'target_os' in the local_target_os property.
600 if 'target_os' in local_scope: 600 if 'target_os' in local_scope:
601 self.local_target_os = local_scope['target_os'] 601 self.local_target_os = local_scope['target_os']
602 # load os specific dependencies if defined. these dependencies may 602 # load os specific dependencies if defined. these dependencies may
603 # override or extend the values defined by the 'deps' member. 603 # override or extend the values defined by the 'deps' member.
604 target_os_list = self.target_os 604 target_os_list = self.target_os
605 if 'deps_os' in local_scope and target_os_list: 605 if 'deps_os' in local_scope and target_os_list:
606 deps = self.MergeWithOsDeps(deps, local_scope['deps_os'], target_os_list) 606 deps = self.MergeWithOsDeps(deps, local_scope['deps_os'], target_os_list)
607 607
608 # If a line is in custom_deps, but not in the solution, we want to append 608 # 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
1483 def enforced_os(self): 1483 def enforced_os(self):
1484 """What deps_os entries that are to be parsed.""" 1484 """What deps_os entries that are to be parsed."""
1485 return self._enforced_os 1485 return self._enforced_os
1486 1486
1487 @property 1487 @property
1488 def recursion_limit(self): 1488 def recursion_limit(self):
1489 """How recursive can each dependencies in DEPS file can load DEPS file.""" 1489 """How recursive can each dependencies in DEPS file can load DEPS file."""
1490 return self._recursion_limit 1490 return self._recursion_limit
1491 1491
1492 @property 1492 @property
1493 def try_recurselist(self): 1493 def try_recursedeps(self):
1494 """Whether to attempt using recurselist-style recursion processing.""" 1494 """Whether to attempt using recursedeps-style recursion processing."""
1495 return True 1495 return True
1496 1496
1497 @property 1497 @property
1498 def target_os(self): 1498 def target_os(self):
1499 return self._enforced_os 1499 return self._enforced_os
1500 1500
1501 1501
1502 #### gclient commands. 1502 #### gclient commands.
1503 1503
1504 1504
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
2045 print >> sys.stderr, 'Error: %s' % str(e) 2045 print >> sys.stderr, 'Error: %s' % str(e)
2046 return 1 2046 return 1
2047 finally: 2047 finally:
2048 gclient_utils.PrintWarnings() 2048 gclient_utils.PrintWarnings()
2049 2049
2050 2050
2051 if '__main__' == __name__: 2051 if '__main__' == __name__:
2052 sys.exit(Main(sys.argv[1:])) 2052 sys.exit(Main(sys.argv[1:]))
2053 2053
2054 # vim: ts=2:sw=2:tw=80:et: 2054 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « no previous file | tests/gclient_test.py » ('j') | tests/gclient_test.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698