Chromium Code Reviews| Index: gclient.py | 
| =================================================================== | 
| --- gclient.py (revision 98571) | 
| +++ gclient.py (working copy) | 
| @@ -139,7 +139,7 @@ | 
| class Dependency(GClientKeywords, gclient_utils.WorkItem): | 
| """Object that represents a dependency checkout.""" | 
| - def __init__(self, parent, name, url, safesync_url, custom_deps, | 
| + def __init__(self, parent, name, url, safesync_url, managed, custom_deps, | 
| custom_vars, deps_file, should_process): | 
| GClientKeywords.__init__(self) | 
| gclient_utils.WorkItem.__init__(self) | 
| @@ -149,6 +149,7 @@ | 
| self.parsed_url = None | 
| # These 2 are only set in .gclient and not in DEPS files. | 
| self.safesync_url = safesync_url | 
| + self.managed = managed | 
| self.custom_vars = custom_vars or {} | 
| self.custom_deps = custom_deps or {} | 
| self.deps_hooks = [] | 
| @@ -331,7 +332,7 @@ | 
| 'Dependency %s specified more than once:\n %s\nvs\n %s' % | 
| (name, tree[name].hierarchy(), self.hierarchy())) | 
| self.dependencies.append(Dependency(self, name, url, None, None, None, | 
| - self.deps_file, should_process)) | 
| + None, self.deps_file, should_process)) | 
| 
 
M-A Ruel
2011/08/28 13:03:31
So it's not inheritable?
 
nsylvain
2011/08/29 18:03:58
Right
 
 | 
| logging.debug('Loaded: %s' % str(self)) | 
| # Arguments number differs from overridden method | 
| @@ -587,6 +588,7 @@ | 
| { "name" : "%(solution_name)s", | 
| "url" : "%(solution_url)s", | 
| "deps_file" : "%(deps_file)s", | 
| + "managed" : %(managed)s, | 
| "custom_deps" : { | 
| }, | 
| "safesync_url": "%(safesync_url)s", | 
| @@ -598,6 +600,7 @@ | 
| { "name" : "%(solution_name)s", | 
| "url" : "%(solution_url)s", | 
| "deps_file" : "%(deps_file)s", | 
| + "managed" : %(managed)s, | 
| "custom_deps" : { | 
| %(solution_deps)s }, | 
| "safesync_url": "%(safesync_url)s", | 
| @@ -614,8 +617,8 @@ | 
| # Do not change previous behavior. Only solution level and immediate DEPS | 
| # are processed. | 
| self._recursion_limit = 2 | 
| - Dependency.__init__(self, None, None, None, None, None, None, 'unused', | 
| - True) | 
| + Dependency.__init__(self, None, None, None, None, None, None, None, | 
| + 'unused', True) | 
| self._options = options | 
| if options.deps_os: | 
| enforced_os = options.deps_os.split(',') | 
| @@ -644,6 +647,7 @@ | 
| self.dependencies.append(Dependency( | 
| self, s['name'], s['url'], | 
| s.get('safesync_url', None), | 
| + s.get('managed', True), | 
| s.get('custom_deps', {}), | 
| s.get('custom_vars', {}), | 
| s.get('deps_file', 'DEPS'), | 
| @@ -673,12 +677,13 @@ | 
| return client | 
| def SetDefaultConfig(self, solution_name, deps_file, solution_url, | 
| - safesync_url): | 
| + safesync_url, managed): | 
| self.SetConfig(self.DEFAULT_CLIENT_FILE_TEXT % { | 
| 'solution_name': solution_name, | 
| 'solution_url': solution_url, | 
| 'deps_file': deps_file, | 
| 'safesync_url' : safesync_url, | 
| + 'managed': managed, | 
| }) | 
| def _SaveEntries(self): | 
| @@ -724,13 +729,14 @@ | 
| # Do not check safesync_url if one or more --revision flag is specified. | 
| if not self._options.revisions: | 
| for s in self.dependencies: | 
| - if not s.safesync_url: | 
| - continue | 
| - handle = urllib.urlopen(s.safesync_url) | 
| - rev = handle.read().strip() | 
| - handle.close() | 
| - if len(rev): | 
| - self._options.revisions.append('%s@%s' % (s.name, rev)) | 
| + if not s.managed: | 
| + self._options.revisions.append('%s@unmanaged' % s.name) | 
| + elif s.safesync_url: | 
| + handle = urllib.urlopen(s.safesync_url) | 
| + rev = handle.read().strip() | 
| + handle.close() | 
| + if len(rev): | 
| + self._options.revisions.append('%s@%s' % (s.name, rev)) | 
| if not self._options.revisions: | 
| return revision_overrides | 
| solutions_names = [s.name for s in self.dependencies] | 
| @@ -854,6 +860,7 @@ | 
| 'solution_url': d.url, | 
| 'deps_file': d.deps_file, | 
| 'safesync_url' : d.safesync_url or '', | 
| + 'managed': d.managed, | 
| 'solution_deps': ''.join(custom_deps), | 
| } | 
| # Print the snapshot configuration file | 
| @@ -974,6 +981,9 @@ | 
| parser.add_option('--deps-file', default='DEPS', | 
| help='overrides the default name for the DEPS file for the' | 
| 'main solutions and all sub-dependencies') | 
| + parser.add_option('--unmanaged', action='store_true', | 
| 
 
M-A Ruel
2011/08/28 13:03:31
Why add the flag if it's accessible from .gclient?
 
nsylvain
2011/08/29 18:03:58
because it's user friendly? Same reason we have --
 
Dirk Pranke
2011/08/29 20:56:13
It's unclear to me if both of these options are ne
 
 | 
| + help='overrides the default behavior to make it possible to' | 
| + 'have the main solution untouched by gclient') | 
| parser.add_option('--git-deps', action='store_true', | 
| help='sets the deps file to ".DEPS.git" instead of "DEPS"') | 
| (options, args) = parser.parse_args(args) | 
| @@ -996,10 +1006,13 @@ | 
| deps_file = options.deps_file | 
| if options.git_deps: | 
| deps_file = '.DEPS.git' | 
| + managed = True | 
| + if options.unmanaged: | 
| + managed = False | 
| safesync_url = '' | 
| if len(args) > 1: | 
| safesync_url = args[1] | 
| - client.SetDefaultConfig(name, deps_file, base_url, safesync_url) | 
| + client.SetDefaultConfig(name, deps_file, base_url, safesync_url, managed) | 
| client.SaveConfig() | 
| return 0 |