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

Side by Side Diff: fetch.py

Issue 440263002: Revert of Add --no-history option to fetch and gclient for shallow clones. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 6 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | gclient.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """ 6 """
7 Tool to perform checkouts in one easy command line! 7 Tool to perform checkouts in one easy command line!
8 8
9 Usage: 9 Usage:
10 fetch <recipe> [--property=value [--property2=value2 ...]] 10 fetch <recipe> [--property=value [--property2=value2 ...]]
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 107
108 def exists(self): 108 def exists(self):
109 return os.path.exists(os.path.join(os.getcwd(), self.root)) 109 return os.path.exists(os.path.join(os.getcwd(), self.root))
110 110
111 def init(self): 111 def init(self):
112 # Configure and do the gclient checkout. 112 # Configure and do the gclient checkout.
113 self.run_gclient('config', '--spec', self.spec['gclient_spec']) 113 self.run_gclient('config', '--spec', self.spec['gclient_spec'])
114 sync_cmd = ['sync'] 114 sync_cmd = ['sync']
115 if self.options.nohooks: 115 if self.options.nohooks:
116 sync_cmd.append('--nohooks') 116 sync_cmd.append('--nohooks')
117 if self.options.no_history:
118 sync_cmd.append('--no-history')
119 if self.spec.get('with_branch_heads', False): 117 if self.spec.get('with_branch_heads', False):
120 sync_cmd.append('--with_branch_heads') 118 sync_cmd.append('--with_branch_heads')
121 self.run_gclient(*sync_cmd) 119 self.run_gclient(*sync_cmd)
122 120
123 # Configure git. 121 # Configure git.
124 wd = os.path.join(self.base, self.root) 122 wd = os.path.join(self.base, self.root)
125 if self.options.dry_run: 123 if self.options.dry_run:
126 print 'cd %s' % wd 124 print 'cd %s' % wd
127 self.run_git( 125 self.run_git(
128 'submodule', 'foreach', 126 'submodule', 'foreach',
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 usage: %s [options] <recipe> [--property=value [--property2=value2 ...]] 200 usage: %s [options] <recipe> [--property=value [--property2=value2 ...]]
203 201
204 This script can be used to download the Chromium sources. See 202 This script can be used to download the Chromium sources. See
205 http://www.chromium.org/developers/how-tos/get-the-code 203 http://www.chromium.org/developers/how-tos/get-the-code
206 for full usage instructions. 204 for full usage instructions.
207 205
208 Valid options: 206 Valid options:
209 -h, --help, help Print this message. 207 -h, --help, help Print this message.
210 --nohooks Don't run hooks after checkout. 208 --nohooks Don't run hooks after checkout.
211 -n, --dry-run Don't run commands, only print them. 209 -n, --dry-run Don't run commands, only print them.
212 --no-history Perform shallow clones, don't fetch the full git history.
213 """ % os.path.basename(sys.argv[0])) 210 """ % os.path.basename(sys.argv[0]))
214 sys.exit(bool(msg)) 211 sys.exit(bool(msg))
215 212
216 213
217 def handle_args(argv): 214 def handle_args(argv):
218 """Gets the recipe name from the command line arguments.""" 215 """Gets the recipe name from the command line arguments."""
219 if len(argv) <= 1: 216 if len(argv) <= 1:
220 usage('Must specify a recipe.') 217 usage('Must specify a recipe.')
221 if argv[1] in ('-h', '--help', 'help'): 218 if argv[1] in ('-h', '--help', 'help'):
222 usage() 219 usage()
223 220
224 dry_run = False 221 dry_run = False
225 nohooks = False 222 nohooks = False
226 no_history = False
227 while len(argv) >= 2: 223 while len(argv) >= 2:
228 arg = argv[1] 224 arg = argv[1]
229 if not arg.startswith('-'): 225 if not arg.startswith('-'):
230 break 226 break
231 argv.pop(1) 227 argv.pop(1)
232 if arg in ('-n', '--dry-run'): 228 if arg in ('-n', '--dry-run'):
233 dry_run = True 229 dry_run = True
234 elif arg == '--nohooks': 230 elif arg == '--nohooks':
235 nohooks = True 231 nohooks = True
236 elif arg == '--no-history':
237 no_history = True
238 else: 232 else:
239 usage('Invalid option %s.' % arg) 233 usage('Invalid option %s.' % arg)
240 234
241 def looks_like_arg(arg): 235 def looks_like_arg(arg):
242 return arg.startswith('--') and arg.count('=') == 1 236 return arg.startswith('--') and arg.count('=') == 1
243 237
244 bad_parms = [x for x in argv[2:] if not looks_like_arg(x)] 238 bad_parms = [x for x in argv[2:] if not looks_like_arg(x)]
245 if bad_parms: 239 if bad_parms:
246 usage('Got bad arguments %s' % bad_parms) 240 usage('Got bad arguments %s' % bad_parms)
247 241
248 recipe = argv[1] 242 recipe = argv[1]
249 props = argv[2:] 243 props = argv[2:]
250 return ( 244 return optparse.Values({'dry_run':dry_run, 'nohooks':nohooks }), recipe, props
251 optparse.Values(
252 {'dry_run':dry_run, 'nohooks':nohooks, 'no_history': no_history }),
253 recipe,
254 props)
255 245
256 246
257 def run_recipe_fetch(recipe, props, aliased=False): 247 def run_recipe_fetch(recipe, props, aliased=False):
258 """Invoke a recipe's fetch method with the passed-through args 248 """Invoke a recipe's fetch method with the passed-through args
259 and return its json output as a python object.""" 249 and return its json output as a python object."""
260 recipe_path = os.path.abspath(os.path.join(SCRIPT_PATH, 'recipes', recipe)) 250 recipe_path = os.path.abspath(os.path.join(SCRIPT_PATH, 'recipes', recipe))
261 if not os.path.exists(recipe_path + '.py'): 251 if not os.path.exists(recipe_path + '.py'):
262 print "Could not find a recipe for %s" % recipe 252 print "Could not find a recipe for %s" % recipe
263 sys.exit(1) 253 sys.exit(1)
264 254
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 293
304 294
305 def main(): 295 def main():
306 options, recipe, props = handle_args(sys.argv) 296 options, recipe, props = handle_args(sys.argv)
307 spec, root = run_recipe_fetch(recipe, props) 297 spec, root = run_recipe_fetch(recipe, props)
308 return run(options, spec, root) 298 return run(options, spec, root)
309 299
310 300
311 if __name__ == '__main__': 301 if __name__ == '__main__':
312 sys.exit(main()) 302 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | gclient.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698