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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient.py
diff --git a/gclient.py b/gclient.py
index a53626ba6d3384c729a08790645ee1c4acd13054..671250c7eae55dbf3e4db2537b79644b9ab29f99 100644
--- a/gclient.py
+++ b/gclient.py
@@ -275,15 +275,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
self._requirements.add(self.url.module_name)
if self.name and self.should_process:
- def yield_full_tree(root):
- """Depth-first recursion."""
- yield root
- for i in root.dependencies:
- for j in yield_full_tree(i):
- if j.should_process:
- yield j
-
- for obj in yield_full_tree(self.root):
+ for obj in self.root.depth_first_tree():
if obj is self or not obj.name:
continue
# Step 1: Find any requirements self may need.
@@ -610,15 +602,22 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
sys.exit(2)
def subtree(self, include_all):
- """Breadth first"""
- result = []
+ """Breadth first recursion excluding root node."""
dependencies = self.dependencies
for d in dependencies:
if d.should_process or include_all:
- result.append(d)
+ yield d
for d in dependencies:
- result.extend(d.subtree(include_all))
- return result
+ for i in d.subtree(include_all):
+ yield i
+
+ def depth_first_tree(self):
+ """Depth-first recursion including the root node."""
+ yield self
+ for i in self.dependencies:
+ for j in i.depth_first_tree():
+ if j.should_process:
+ yield j
def get_custom_deps(self, name, url):
"""Returns a custom deps if applicable."""
« 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