Commit 5bde64ed authored by agable@chromium.org's avatar agable@chromium.org

Have fetch pretty-print the .gclient solution.

R=kjellander@chromium.org

Review URL: https://codereview.chromium.org/753383002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@293110 0039d316-1c4b-4281-b951-d872f2087c98
parent f1c53941
......@@ -101,17 +101,31 @@ class GclientGitCheckout(GclientCheckout, GitCheckout):
def __init__(self, options, spec, root):
super(GclientGitCheckout, self).__init__(options, spec, root)
assert 'solutions' in self.spec
keys = ['solutions', 'target_os', 'target_os_only']
gclient_spec = '\n'.join('%s = %s' % (key, self.spec[key])
for key in keys if key in self.spec)
self.spec['gclient_spec'] = gclient_spec
def _format_spec(self):
def _format_literal(lit):
if isinstance(lit, basestring):
return '"%s"' % lit
if isinstance(lit, list):
return '[%s]' % ', '.join(_format_literal(i) for i in lit)
return '%r' % lit
soln_strings = []
for soln in self.spec['solutions']:
soln_string= '\n'.join(' "%s": %s,' % (key, _format_literal(value))
for key, value in soln.iteritems())
soln_strings.append(' {\n%s\n },' % soln_string)
gclient_spec = 'solutions = [\n%s\n]\n' % '\n'.join(soln_strings)
extra_keys = ['target_os', 'target_os_only']
gclient_spec += ''.join('%s = %s\n' % (key, _format_literal(self.spec[key]))
for key in extra_keys if key in self.spec)
return gclient_spec
def exists(self):
return os.path.exists(os.path.join(os.getcwd(), self.root))
def init(self):
# Configure and do the gclient checkout.
self.run_gclient('config', '--spec', self.spec['gclient_spec'])
self.run_gclient('config', '--spec', self._format_spec())
sync_cmd = ['sync']
if self.options.nohooks:
sync_cmd.append('--nohooks')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment