Add hierarchy information to flattened "visited DEPS" output.
This will make it easier to programmatically determine where a flattened
entry originated, which is needed for recursively branching and
unpinning DEPS files.
BUG=825063
R=dpranke@google.com
Change-Id: Id280c0b0a95b8664602e0ec4513722fe4d6d1ebf
Reviewed-on: https://chromium-review.googlesource.com/977326
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Michael Moss <mmoss@chromium.org>
diff --git a/gclient.py b/gclient.py
index c4bf011..d389622 100755
--- a/gclient.py
+++ b/gclient.py
@@ -1306,6 +1306,15 @@
i = i.parent
return out
+ def hierarchy_data(self):
+ """Returns a machine-readable hierarchical reference to a Dependency."""
+ d = self
+ out = []
+ while d and d.name:
+ out.insert(0, (d.name, d.url))
+ d = d.parent
+ return tuple(out)
+
def get_vars(self):
"""Returns a dictionary of effective variable values
(DEPS file contents with applied custom_vars overrides)."""
@@ -2181,7 +2190,7 @@
if not os.path.exists(deps_path):
return
assert dep.parsed_url
- self._deps_files.add((dep.parsed_url, deps_file))
+ self._deps_files.add((dep.parsed_url, deps_file, dep.hierarchy_data()))
for dep in self._deps.itervalues():
add_deps_file(dep)
for os_deps in self._deps_os.itervalues():
@@ -2200,7 +2209,7 @@
_HooksOsToLines(self._hooks_os) +
_VarsToLines(self._vars) +
['# %s, %s' % (url, deps_file)
- for url, deps_file in sorted(self._deps_files)] +
+ for url, deps_file, _ in sorted(self._deps_files)] +
['']) # Ensure newline at end of file.
def _add_dep(self, dep):
@@ -2338,7 +2347,7 @@
else:
print(flattener.deps_string)
- deps_files = [{'url': d[0], 'deps_file': d[1]}
+ deps_files = [{'url': d[0], 'deps_file': d[1], 'hierarchy': d[2]}
for d in sorted(flattener.deps_files)]
if options.output_deps_files:
with open(options.output_deps_files, 'w') as f: