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

Side by Side Diff: gclient.py

Issue 3005026: Make Dependency.subtree() a standalone function for later use. (Closed)
Patch Set: Created 10 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2010 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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 415
416 def enforced_os(self): 416 def enforced_os(self):
417 return self.parent.enforced_os() 417 return self.parent.enforced_os()
418 418
419 def recursion_limit(self): 419 def recursion_limit(self):
420 return self.parent.recursion_limit() - 1 420 return self.parent.recursion_limit() - 1
421 421
422 def tree(self, force_all): 422 def tree(self, force_all):
423 return self.parent.tree(force_all) 423 return self.parent.tree(force_all)
424 424
425 def subtree(self, force_all):
426 result = []
427 # Add breadth-first.
428 if self.direct_reference or force_all:
429 for d in self.dependencies:
430 result.append(d)
bradn 2010/07/22 21:51:49 extra indent here.
431 for d in self.dependencies:
432 result.extend(d.subtree(force_all))
433 return result
434
425 def get_custom_deps(self, name, url): 435 def get_custom_deps(self, name, url):
426 """Returns a custom deps if applicable.""" 436 """Returns a custom deps if applicable."""
427 if self.parent: 437 if self.parent:
428 url = self.parent.get_custom_deps(name, url) 438 url = self.parent.get_custom_deps(name, url)
429 # None is a valid return value to disable a dependency. 439 # None is a valid return value to disable a dependency.
430 return self.custom_deps.get(name, url) 440 return self.custom_deps.get(name, url)
431 441
432 def __str__(self): 442 def __str__(self):
433 out = [] 443 out = []
434 for i in ('name', 'url', 'safesync_url', 'custom_deps', 'custom_vars', 444 for i in ('name', 'url', 'safesync_url', 'custom_deps', 'custom_vars',
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 def enforced_os(self): 762 def enforced_os(self):
753 """What deps_os entries that are to be parsed.""" 763 """What deps_os entries that are to be parsed."""
754 return self._enforced_os 764 return self._enforced_os
755 765
756 def recursion_limit(self): 766 def recursion_limit(self):
757 """How recursive can each dependencies in DEPS file can load DEPS file.""" 767 """How recursive can each dependencies in DEPS file can load DEPS file."""
758 return self._recursion_limit 768 return self._recursion_limit
759 769
760 def tree(self, force_all): 770 def tree(self, force_all):
761 """Returns a flat list of all the dependencies.""" 771 """Returns a flat list of all the dependencies."""
762 def subtree(dep): 772 return self.subtree(force_all)
763 if not force_all and not dep.direct_reference:
764 # Was loaded from a From() keyword in a DEPS file, don't load all its
765 # dependencies.
766 return []
767 result = dep.dependencies[:]
768 for d in dep.dependencies:
769 result.extend(subtree(d))
770 return result
771 return subtree(self)
772 773
773 774
774 #### gclient commands. 775 #### gclient commands.
775 776
776 777
777 def CMDcleanup(parser, args): 778 def CMDcleanup(parser, args):
778 """Cleans up all working copies. 779 """Cleans up all working copies.
779 780
780 Mostly svn-specific. Simply runs 'svn cleanup' for each module. 781 Mostly svn-specific. Simply runs 'svn cleanup' for each module.
781 """ 782 """
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 return CMDhelp(parser, argv) 1151 return CMDhelp(parser, argv)
1151 except gclient_utils.Error, e: 1152 except gclient_utils.Error, e:
1152 print >> sys.stderr, 'Error: %s' % str(e) 1153 print >> sys.stderr, 'Error: %s' % str(e)
1153 return 1 1154 return 1
1154 1155
1155 1156
1156 if '__main__' == __name__: 1157 if '__main__' == __name__:
1157 sys.exit(Main(sys.argv[1:])) 1158 sys.exit(Main(sys.argv[1:]))
1158 1159
1159 # vim: ts=2:sw=2:tw=80:et: 1160 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698