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

Unified Diff: gclient.py

Issue 2883035: Add Dependency.hierarchy() to better visualize the origin of a dependency. (Closed)
Patch Set: fix 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 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 9a722f7253e3cee2844d2574631ad60ec65f7720..d62e77ee58a3c8a49d528407e32377c0c5a5ba02 100644
--- a/gclient.py
+++ b/gclient.py
@@ -160,9 +160,11 @@ class Dependency(GClientKeywords):
# Sanity checks
if not self.name and self.parent:
raise gclient_utils.Error('Dependency without name')
- if self.name in [d.name for d in self.tree(False)]:
- raise gclient_utils.Error('Dependency %s specified more than once' %
- self.name)
+ tree = dict((d.name, d) for d in self.tree(False))
+ if self.name in tree:
+ raise gclient_utils.Error(
+ 'Dependency %s specified more than once:\n %s\nvs\n %s' %
+ (self.name, tree[self.name].hierarchy(), self.hierarchy()))
if not isinstance(self.url,
(basestring, self.FromImpl, self.FileImpl, None.__class__)):
raise gclient_utils.Error('dependency url must be either a string, None, '
@@ -436,6 +438,15 @@ class Dependency(GClientKeywords):
def __repr__(self):
return '%s: %s' % (self.name, self.url)
+ def hierarchy(self):
+ "Returns a human-readable hierarchical reference to a Dependency."
bradn 2010/07/22 21:22:25 Uh you'll want a """ here I believe.
+ out = '%s(%s)' % (self.name, self.url)
+ i = self.parent
+ while i and i.name:
+ out = '%s(%s) -> %s' % (i.name, i.url, out)
+ i = i.parent
+ return out
+
class GClient(Dependency):
"""Object that represent a gclient checkout. A tree of Dependency(), one per
« 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