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

Unified Diff: fetch.py

Issue 753383002: Have fetch pretty-print the .gclient solution. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 6 years, 1 month 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: fetch.py
diff --git a/fetch.py b/fetch.py
index e579f916ed4c32411bcc8eefd9e1d96aeaff3166..5335f75a4419e283f0179e356e427668be49b0c8 100755
--- a/fetch.py
+++ b/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')
« 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