mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
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
This commit is contained in:
24
fetch.py
24
fetch.py
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user