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

Side by Side Diff: gclient.py

Issue 8114005: Move yield_full_tree() in its own member function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 2 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 | Annotate | Revision Log
« 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/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 for i in root_deps: 268 for i in root_deps:
269 if i is self.parent: 269 if i is self.parent:
270 break 270 break
271 if i.name: 271 if i.name:
272 self._requirements.add(i.name) 272 self._requirements.add(i.name)
273 273
274 if isinstance(self.url, self.FromImpl): 274 if isinstance(self.url, self.FromImpl):
275 self._requirements.add(self.url.module_name) 275 self._requirements.add(self.url.module_name)
276 276
277 if self.name and self.should_process: 277 if self.name and self.should_process:
278 def yield_full_tree(root): 278 for obj in self.root.depth_first_tree():
279 """Depth-first recursion."""
280 yield root
281 for i in root.dependencies:
282 for j in yield_full_tree(i):
283 if j.should_process:
284 yield j
285
286 for obj in yield_full_tree(self.root):
287 if obj is self or not obj.name: 279 if obj is self or not obj.name:
288 continue 280 continue
289 # Step 1: Find any requirements self may need. 281 # Step 1: Find any requirements self may need.
290 if self.name.startswith(posixpath.join(obj.name, '')): 282 if self.name.startswith(posixpath.join(obj.name, '')):
291 self._requirements.add(obj.name) 283 self._requirements.add(obj.name)
292 # Step 2: Find any requirements self may impose. 284 # Step 2: Find any requirements self may impose.
293 if obj.name.startswith(posixpath.join(self.name, '')): 285 if obj.name.startswith(posixpath.join(self.name, '')):
294 try: 286 try:
295 # Access to a protected member _requirements of a client class 287 # Access to a protected member _requirements of a client class
296 # pylint: disable=W0212 288 # pylint: disable=W0212
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 gclient_utils.CheckCallAndFilterAndHeader( 595 gclient_utils.CheckCallAndFilterAndHeader(
604 command, cwd=self.root.root_dir, always=True) 596 command, cwd=self.root.root_dir, always=True)
605 except (gclient_utils.Error, subprocess2.CalledProcessError), e: 597 except (gclient_utils.Error, subprocess2.CalledProcessError), e:
606 # Use a discrete exit status code of 2 to indicate that a hook action 598 # Use a discrete exit status code of 2 to indicate that a hook action
607 # failed. Users of this script may wish to treat hook action failures 599 # failed. Users of this script may wish to treat hook action failures
608 # differently from VC failures. 600 # differently from VC failures.
609 print >> sys.stderr, 'Error: %s' % str(e) 601 print >> sys.stderr, 'Error: %s' % str(e)
610 sys.exit(2) 602 sys.exit(2)
611 603
612 def subtree(self, include_all): 604 def subtree(self, include_all):
613 """Breadth first""" 605 """Breadth first recursion excluding root node."""
614 result = []
615 dependencies = self.dependencies 606 dependencies = self.dependencies
616 for d in dependencies: 607 for d in dependencies:
617 if d.should_process or include_all: 608 if d.should_process or include_all:
618 result.append(d) 609 yield d
619 for d in dependencies: 610 for d in dependencies:
620 result.extend(d.subtree(include_all)) 611 for i in d.subtree(include_all):
621 return result 612 yield i
613
614 def depth_first_tree(self):
615 """Depth-first recursion including the root node."""
616 yield self
617 for i in self.dependencies:
618 for j in i.depth_first_tree():
619 if j.should_process:
620 yield j
622 621
623 def get_custom_deps(self, name, url): 622 def get_custom_deps(self, name, url):
624 """Returns a custom deps if applicable.""" 623 """Returns a custom deps if applicable."""
625 if self.parent: 624 if self.parent:
626 url = self.parent.get_custom_deps(name, url) 625 url = self.parent.get_custom_deps(name, url)
627 # None is a valid return value to disable a dependency. 626 # None is a valid return value to disable a dependency.
628 return self.custom_deps.get(name, url) 627 return self.custom_deps.get(name, url)
629 628
630 @property 629 @property
631 def recursion_limit(self): 630 def recursion_limit(self):
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 except (gclient_utils.Error, subprocess2.CalledProcessError), e: 1460 except (gclient_utils.Error, subprocess2.CalledProcessError), e:
1462 print >> sys.stderr, 'Error: %s' % str(e) 1461 print >> sys.stderr, 'Error: %s' % str(e)
1463 return 1 1462 return 1
1464 1463
1465 1464
1466 if '__main__' == __name__: 1465 if '__main__' == __name__:
1467 fix_encoding.fix_encoding() 1466 fix_encoding.fix_encoding()
1468 sys.exit(Main(sys.argv[1:])) 1467 sys.exit(Main(sys.argv[1:]))
1469 1468
1470 # vim: ts=2:sw=2:tw=80:et: 1469 # 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