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

Unified Diff: gclient.py

Issue 2857017: Add more glue code necessary for getting the DEPS dependencies as Dependency objects. (Closed)
Patch Set: . Created 10 years, 6 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 55305bd8c4b2493766dfa995b9ad735a50613da0..30d26ba7d04ea45d2570b78f9a2a77a00542f045 100644
--- a/gclient.py
+++ b/gclient.py
@@ -311,8 +311,7 @@ class Dependency(GClientKeywords):
return deps
def _RunHookAction(self, hook_dict, matching_file_list):
- """Runs the action from a single hook.
- """
+ """Runs the action from a single hook."""
logging.info(hook_dict)
logging.info(matching_file_list)
command = hook_dict['action'][:]
@@ -329,7 +328,7 @@ class Dependency(GClientKeywords):
# Use a discrete exit status code of 2 to indicate that a hook action
# failed. Users of this script may wish to treat hook action failures
# differently from VC failures.
- gclient_utils.SubprocessCall(command, self.root_dir(), fail_status=2)
+ return gclient_utils.SubprocessCall(command, self.root_dir(), fail_status=2)
def _RunHooks(self, command, file_list, is_using_git):
"""Evaluates all hooks, running actions as needed.
@@ -370,9 +369,39 @@ class Dependency(GClientKeywords):
def enforced_os(self):
return self.parent.enforced_os()
+ def recursion_limit(self):
+ return self.parent.recursion_limit() - 1
+
+ def tree(self, force_all):
+ return self.parent.tree(force_all)
+
+ def get_custom_deps(self, name, url):
+ """Returns a custom deps if applicable."""
+ if self.parent:
+ url = self.parent.get_custom_deps(name, url)
+ # None is a valid return value to disable a dependency.
+ return self.custom_deps.get(name, url)
+
+ def __str__(self):
+ out = []
+ for i in ('name', 'url', 'safesync_url', 'custom_deps', 'custom_vars',
+ 'deps_hooks'):
+ # 'deps_file'
+ if self.__dict__[i]:
+ out.append('%s: %s' % (i, self.__dict__[i]))
+
+ for d in self.dependencies:
+ out.extend([' ' + x for x in str(d).splitlines()])
+ out.append('')
+ return '\n'.join(out)
+
+ def __repr__(self):
+ return '%s: %s' % (self.name, self.url)
+
class GClient(Dependency):
- """Main gclient checkout root where .gclient resides."""
+ """Object that represent a gclient checkout. A tree of Dependency(), one per
+ solution or DEPS entry."""
SUPPORTED_COMMANDS = [
'cleanup', 'diff', 'export', 'pack', 'revert', 'status', 'update',
'runhooks'
@@ -429,6 +458,9 @@ solutions = [
self._enforced_os = list(set(enforced_os))
self._root_dir = root_dir
self.config_content = None
+ # Do not change previous behavior. Only solution level and immediate DEPS
+ # are processed.
+ self._recursion_limit = 2
def SetConfig(self, content):
assert self.dependencies == []
@@ -670,13 +702,13 @@ solutions = [
if not self._options.delete_unversioned_trees or modified_files:
# There are modified files in this entry. Keep warning until
# removed.
- print(("\nWARNING: \"%s\" is no longer part of this client. "
- "It is recommended that you manually remove it.\n") %
+ print(('\nWARNING: \'%s\' is no longer part of this client. '
+ 'It is recommended that you manually remove it.\n') %
entry_fixed)
else:
# Delete the entry
- print("\n________ deleting \'%s\' " +
- "in \'%s\'") % (entry_fixed, self.root_dir())
+ print('\n________ deleting \'%s\' ' +
+ 'in \'%s\'') % (entry_fixed, self.root_dir())
gclient_utils.RemoveDirectory(e_dir)
# record the current list of entries for next time
self._SaveEntries(entries)
@@ -766,12 +798,36 @@ solutions = [
snapclient.SetConfig(config)
print(snapclient.config_content)
+ def ParseDepsFile(self, direct_reference):
+ """No DEPS to parse for a .gclient file."""
+ self.direct_reference = direct_reference
+ self.deps_parsed = True
+
def root_dir(self):
+ """Root directory of gclient checkout."""
return self._root_dir
def enforced_os(self):
+ """What deps_os entries that are to be parsed."""
return self._enforced_os
+ def recursion_limit(self):
+ """How recursive can each dependencies in DEPS file can load DEPS file."""
+ return self._recursion_limit
+
+ def tree(self, force_all):
+ """Returns a flat list of all the dependencies."""
+ def subtree(dep):
+ if not force_all and not dep.direct_reference:
+ # Was loaded from a From() keyword in a DEPS file, don't load all its
+ # dependencies.
+ return []
+ result = dep.dependencies[:]
+ for d in dep.dependencies:
+ result.extend(subtree(d))
+ return result
+ return subtree(self)
+
#### gclient commands.
« 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