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

Side by Side Diff: recipe_modules/gclient/api.py

Issue 2270083004: Default gclient's GIT_MODE to True (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: A slightly gentler hand with pragmas Created 4 years, 3 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 | recipe_modules/gclient/config.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 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from recipe_engine import recipe_api 5 from recipe_engine import recipe_api
6 6
7 7
8 class RevisionResolver(object): 8 class RevisionResolver(object):
9 """Resolves the revision based on build properties.""" 9 """Resolves the revision based on build properties."""
10 10
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 for name, revision in sorted(cfg.revisions.items()): 146 for name, revision in sorted(cfg.revisions.items()):
147 fixed_revision = self.resolve_revision(revision) 147 fixed_revision = self.resolve_revision(revision)
148 if fixed_revision: 148 if fixed_revision:
149 revisions.extend(['--revision', '%s@%s' % (name, fixed_revision)]) 149 revisions.extend(['--revision', '%s@%s' % (name, fixed_revision)])
150 150
151 test_data_paths = set(cfg.got_revision_mapping.keys() + 151 test_data_paths = set(cfg.got_revision_mapping.keys() +
152 [s.name for s in cfg.solutions]) 152 [s.name for s in cfg.solutions])
153 step_test_data = lambda: ( 153 step_test_data = lambda: (
154 self.test_api.output_json(test_data_paths, cfg.GIT_MODE)) 154 self.test_api.output_json(test_data_paths, cfg.GIT_MODE))
155 try: 155 try:
156 if not cfg.GIT_MODE: 156 if not cfg.GIT_MODE: # pragma: no cover
157 args = ['sync', '--nohooks', '--force', '--verbose'] 157 args = ['sync', '--nohooks', '--force', '--verbose']
158 if cfg.delete_unversioned_trees: 158 if cfg.delete_unversioned_trees:
159 args.append('--delete_unversioned_trees') 159 args.append('--delete_unversioned_trees')
160 if with_branch_heads: 160 if with_branch_heads:
161 args.append('--with_branch_heads') 161 args.append('--with_branch_heads')
162 self('sync', args + revisions + ['--output-json', self.m.json.output()], 162 self('sync', args + revisions + ['--output-json', self.m.json.output()],
163 step_test_data=step_test_data, 163 step_test_data=step_test_data,
164 **kwargs) 164 **kwargs)
165 else: 165 else:
166 # clean() isn't used because the gclient sync flags passed in checkout() 166 # clean() isn't used because the gclient sync flags passed in checkout()
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 if revert is self.RevertOnTryserver: 232 if revert is self.RevertOnTryserver:
233 revert = self.m.tryserver.is_tryserver 233 revert = self.m.tryserver.is_tryserver
234 234
235 if inject_parent_got_revision: 235 if inject_parent_got_revision:
236 self.inject_parent_got_revision(cfg, override=True) 236 self.inject_parent_got_revision(cfg, override=True)
237 237
238 self('setup', ['config', '--spec', self.config_to_pythonish(cfg)], **kwargs) 238 self('setup', ['config', '--spec', self.config_to_pythonish(cfg)], **kwargs)
239 239
240 sync_step = None 240 sync_step = None
241 try: 241 try:
242 if not cfg.GIT_MODE: 242 if not cfg.GIT_MODE: # pragma: no cover
243 try: 243 try:
244 if revert: 244 if revert:
245 self.revert(**kwargs) 245 self.revert(**kwargs)
246 finally: 246 finally:
247 sync_step = self.sync(cfg, with_branch_heads=with_branch_heads, 247 sync_step = self.sync(cfg, with_branch_heads=with_branch_heads,
248 **kwargs) 248 **kwargs)
249 else: 249 else:
250 sync_step = self.sync(cfg, with_branch_heads=with_branch_heads, 250 sync_step = self.sync(cfg, with_branch_heads=with_branch_heads,
251 **kwargs) 251 **kwargs)
252 252
253 cfg_cmds = [ 253 cfg_cmds = [
254 ('user.name', 'local_bot'), 254 ('user.name', 'local_bot'),
255 ('user.email', 'local_bot@example.com'), 255 ('user.email', 'local_bot@example.com'),
256 ] 256 ]
257 for var, val in cfg_cmds: 257 for var, val in cfg_cmds:
258 name = 'recurse (git config %s)' % var 258 name = 'recurse (git config %s)' % var
259 self(name, ['recurse', 'git', 'config', var, val], **kwargs) 259 self(name, ['recurse', 'git', 'config', var, val], **kwargs)
260 260
261 finally: 261 finally:
262 cwd = kwargs.get('cwd', self.m.path['slave_build']) 262 cwd = kwargs.get('cwd', self.m.path['slave_build'])
263 if 'checkout' not in self.m.path: 263 if 'checkout' not in self.m.path:
264 self.m.path['checkout'] = cwd.join( 264 self.m.path['checkout'] = cwd.join(
265 *cfg.solutions[0].name.split(self.m.path.sep)) 265 *cfg.solutions[0].name.split(self.m.path.sep))
266 266
267 return sync_step 267 return sync_step
268 268
269 def revert(self, **kwargs): 269 def revert(self, **kwargs): # pragma: no cover
270 """Return a gclient_safe_revert step.""" 270 """Return a gclient_safe_revert step."""
271 # Not directly calling gclient, so don't use self(). 271 # Not directly calling gclient, so don't use self().
272 alias = self.spec_alias 272 alias = self.spec_alias
273 prefix = '%sgclient ' % (('[spec: %s] ' % alias) if alias else '') 273 prefix = '%sgclient ' % (('[spec: %s] ' % alias) if alias else '')
274 274
275 return self.m.python(prefix + 'revert', 275 return self.m.python(prefix + 'revert',
276 self.m.path['build'].join('scripts', 'slave', 'gclient_safe_revert.py'), 276 self.m.path['build'].join('scripts', 'slave', 'gclient_safe_revert.py'),
277 ['.', self.m.path['depot_tools'].join('gclient', 277 ['.', self.m.path['depot_tools'].join('gclient',
278 platform_ext={'win': '.bat'})], 278 platform_ext={'win': '.bat'})],
279 infra_step=True, 279 infra_step=True,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 """Updates config revision corresponding to patch_project. 353 """Updates config revision corresponding to patch_project.
354 354
355 Useful for bot_update only, as this is the only consumer of gclient's config 355 Useful for bot_update only, as this is the only consumer of gclient's config
356 revision map. This doesn't overwrite the revision if it was already set. 356 revision map. This doesn't overwrite the revision if it was already set.
357 """ 357 """
358 assert patch_project is None or isinstance(patch_project, basestring) 358 assert patch_project is None or isinstance(patch_project, basestring)
359 cfg = gclient_config or self.c 359 cfg = gclient_config or self.c
360 path, revision = cfg.patch_projects.get(patch_project, (None, None)) 360 path, revision = cfg.patch_projects.get(patch_project, (None, None))
361 if path and revision and path not in cfg.revisions: 361 if path and revision and path not in cfg.revisions:
362 cfg.revisions[path] = revision 362 cfg.revisions[path] = revision
OLDNEW
« no previous file with comments | « no previous file | recipe_modules/gclient/config.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698