OLD | NEW |
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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 def spec_alias(self, name): | 127 def spec_alias(self, name): |
128 self._spec_alias = name | 128 self._spec_alias = name |
129 | 129 |
130 @spec_alias.deleter | 130 @spec_alias.deleter |
131 def spec_alias(self): | 131 def spec_alias(self): |
132 self._spec_alias = None | 132 self._spec_alias = None |
133 | 133 |
134 def get_config_defaults(self): | 134 def get_config_defaults(self): |
135 return { | 135 return { |
136 'USE_MIRROR': self.use_mirror, | 136 'USE_MIRROR': self.use_mirror, |
137 'CACHE_DIR': self.m.path['git_cache'], | 137 'CACHE_DIR': self.m.infra_paths['git_cache'], |
138 } | 138 } |
139 | 139 |
140 @staticmethod | 140 @staticmethod |
141 def config_to_pythonish(cfg): | 141 def config_to_pythonish(cfg): |
142 return jsonish_to_python(cfg.as_jsonish(), True) | 142 return jsonish_to_python(cfg.as_jsonish(), True) |
143 | 143 |
144 def resolve_revision(self, revision): | 144 def resolve_revision(self, revision): |
145 if hasattr(revision, 'resolve'): | 145 if hasattr(revision, 'resolve'): |
146 return revision.resolve(self.m.properties) | 146 return revision.resolve(self.m.properties) |
147 return revision | 147 return revision |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 | 269 |
270 cfg_cmds = [ | 270 cfg_cmds = [ |
271 ('user.name', 'local_bot'), | 271 ('user.name', 'local_bot'), |
272 ('user.email', 'local_bot@example.com'), | 272 ('user.email', 'local_bot@example.com'), |
273 ] | 273 ] |
274 for var, val in cfg_cmds: | 274 for var, val in cfg_cmds: |
275 name = 'recurse (git config %s)' % var | 275 name = 'recurse (git config %s)' % var |
276 self(name, ['recurse', 'git', 'config', var, val], **kwargs) | 276 self(name, ['recurse', 'git', 'config', var, val], **kwargs) |
277 | 277 |
278 finally: | 278 finally: |
279 cwd = kwargs.get('cwd', self.m.path['slave_build']) | 279 cwd = kwargs.get('cwd', self.m.infra_paths['slave_build']) |
280 if 'checkout' not in self.m.path: | 280 if 'checkout' not in self.m.path: |
281 self.m.path['checkout'] = cwd.join( | 281 self.m.path['checkout'] = cwd.join( |
282 *cfg.solutions[0].name.split(self.m.path.sep)) | 282 *cfg.solutions[0].name.split(self.m.path.sep)) |
283 | 283 |
284 return sync_step | 284 return sync_step |
285 | 285 |
286 def revert(self, **kwargs): | 286 def revert(self, **kwargs): |
287 """Return a gclient_safe_revert step.""" | 287 """Return a gclient_safe_revert step.""" |
288 # Not directly calling gclient, so don't use self(). | 288 # Not directly calling gclient, so don't use self(). |
289 alias = self.spec_alias | 289 alias = self.spec_alias |
290 prefix = '%sgclient ' % (('[spec: %s] ' % alias) if alias else '') | 290 prefix = '%sgclient ' % (('[spec: %s] ' % alias) if alias else '') |
291 | 291 |
292 return self.m.python(prefix + 'revert', | 292 return self.m.python(prefix + 'revert', |
293 self.m.path['build'].join('scripts', 'slave', 'gclient_safe_revert.py'), | 293 self.m.infra_paths['build'].join( |
294 ['.', self.m.path['depot_tools'].join('gclient', | 294 'scripts', 'slave', 'gclient_safe_revert.py'), |
295 platform_ext={'win': '.bat'})], | 295 [ |
| 296 '.', |
| 297 self.m.infra_paths['depot_tools'].join( |
| 298 'gclient', platform_ext={'win': '.bat'}) |
| 299 ], |
296 infra_step=True, | 300 infra_step=True, |
297 **kwargs | 301 **kwargs |
298 ) | 302 ) |
299 | 303 |
300 def runhooks(self, args=None, name='runhooks', **kwargs): | 304 def runhooks(self, args=None, name='runhooks', **kwargs): |
301 args = args or [] | 305 args = args or [] |
302 assert isinstance(args, (list, tuple)) | 306 assert isinstance(args, (list, tuple)) |
303 return self( | 307 return self( |
304 name, ['runhooks'] + list(args), infra_step=False, **kwargs) | 308 name, ['runhooks'] + list(args), infra_step=False, **kwargs) |
305 | 309 |
(...skipping 21 matching lines...) Expand all Loading... |
327 | 331 |
328 build_path = sys.argv[1] | 332 build_path = sys.argv[1] |
329 if os.path.exists(build_path): | 333 if os.path.exists(build_path): |
330 for (path, dir, files) in os.walk(build_path): | 334 for (path, dir, files) in os.walk(build_path): |
331 for cur_file in files: | 335 for cur_file in files: |
332 if cur_file.endswith('index.lock'): | 336 if cur_file.endswith('index.lock'): |
333 path_to_file = os.path.join(path, cur_file) | 337 path_to_file = os.path.join(path, cur_file) |
334 print 'deleting %s' % path_to_file | 338 print 'deleting %s' % path_to_file |
335 os.remove(path_to_file) | 339 os.remove(path_to_file) |
336 """, | 340 """, |
337 args=[self.m.path['slave_build']], | 341 args=[self.m.infra_paths['slave_build']], |
338 infra_step=True, | 342 infra_step=True, |
339 ) | 343 ) |
340 | 344 |
341 def calculate_patch_root(self, patch_project, gclient_config=None): | 345 def calculate_patch_root(self, patch_project, gclient_config=None): |
342 """Returns path where a patch should be applied to based patch_project. | 346 """Returns path where a patch should be applied to based patch_project. |
343 | 347 |
344 Maps "patch_project" to a path of directories relative to checkout's root, | 348 Maps "patch_project" to a path of directories relative to checkout's root, |
345 which describe where to place the patch. | 349 which describe where to place the patch. |
346 | 350 |
347 For now, considers only first solution (c.solutions[0]), but in theory can | 351 For now, considers only first solution (c.solutions[0]), but in theory can |
(...skipping 21 matching lines...) Expand all Loading... |
369 """Updates config revision corresponding to patch_project. | 373 """Updates config revision corresponding to patch_project. |
370 | 374 |
371 Useful for bot_update only, as this is the only consumer of gclient's config | 375 Useful for bot_update only, as this is the only consumer of gclient's config |
372 revision map. This doesn't overwrite the revision if it was already set. | 376 revision map. This doesn't overwrite the revision if it was already set. |
373 """ | 377 """ |
374 assert patch_project is None or isinstance(patch_project, basestring) | 378 assert patch_project is None or isinstance(patch_project, basestring) |
375 cfg = gclient_config or self.c | 379 cfg = gclient_config or self.c |
376 path, revision = cfg.patch_projects.get(patch_project, (None, None)) | 380 path, revision = cfg.patch_projects.get(patch_project, (None, None)) |
377 if path and revision and path not in cfg.revisions: | 381 if path and revision and path not in cfg.revisions: |
378 cfg.revisions[path] = revision | 382 cfg.revisions[path] = revision |
OLD | NEW |