| 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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 blink) | 314 blink) |
| 315 """ | 315 """ |
| 316 return ( | 316 return ( |
| 317 self.m.properties.get('top_of_tree_blink') or | 317 self.m.properties.get('top_of_tree_blink') or |
| 318 self.m.properties.get('patch_project') == 'blink') | 318 self.m.properties.get('patch_project') == 'blink') |
| 319 | 319 |
| 320 def break_locks(self): | 320 def break_locks(self): |
| 321 """Remove all index.lock files. If a previous run of git crashed, bot was | 321 """Remove all index.lock files. If a previous run of git crashed, bot was |
| 322 reset, etc... we might end up with leftover index.lock files. | 322 reset, etc... we might end up with leftover index.lock files. |
| 323 """ | 323 """ |
| 324 self.m.python.inline( | 324 if self.c and self.c.break_locks_flag: |
| 325 'cleanup index.lock', | 325 self.m.python.inline( |
| 326 """ | 326 'cleanup index.lock', |
| 327 import os, sys | 327 """ |
| 328 import os, sys |
| 328 | 329 |
| 329 build_path = sys.argv[1] | 330 build_path = sys.argv[1] |
| 330 if os.path.exists(build_path): | 331 if os.path.exists(build_path): |
| 331 for (path, dir, files) in os.walk(build_path): | 332 for (path, dir, files) in os.walk(build_path): |
| 332 for cur_file in files: | 333 for cur_file in files: |
| 333 if cur_file.endswith('index.lock'): | 334 if cur_file.endswith('index.lock'): |
| 334 path_to_file = os.path.join(path, cur_file) | 335 path_to_file = os.path.join(path, cur_file) |
| 335 print 'deleting %s' % path_to_file | 336 os.remove(path_to_file) |
| 336 os.remove(path_to_file) | 337 """, |
| 337 """, | 338 args=[self.m.path['slave_build']], |
| 338 args=[self.m.path['slave_build']], | 339 infra_step=True, |
| 339 infra_step=True, | 340 ) |
| 340 ) | 341 else: |
| 342 self.m.python.inline( |
| 343 'cleanup index.lock', |
| 344 """ |
| 345 import os, sys |
| 346 |
| 347 build_path = sys.argv[1] |
| 348 if os.path.exists(build_path): |
| 349 for (path, dir, files) in os.walk(build_path): |
| 350 for cur_file in files: |
| 351 if cur_file.endswith('index.lock'): |
| 352 path_to_file = os.path.join(path, cur_file) |
| 353 print 'deleting %s' % path_to_file |
| 354 os.remove(path_to_file) |
| 355 """, |
| 356 args=[self.m.path['slave_build']], |
| 357 infra_step=True, |
| 358 ) |
| 341 | 359 |
| 342 def calculate_patch_root(self, patch_project, gclient_config=None): | 360 def calculate_patch_root(self, patch_project, gclient_config=None): |
| 343 """Returns path where a patch should be applied to based patch_project. | 361 """Returns path where a patch should be applied to based patch_project. |
| 344 | 362 |
| 345 Maps "patch_project" to a path of directories relative to checkout's root, | 363 Maps "patch_project" to a path of directories relative to checkout's root, |
| 346 which describe where to place the patch. | 364 which describe where to place the patch. |
| 347 | 365 |
| 348 For now, considers only first solution (c.solutions[0]), but in theory can | 366 For now, considers only first solution (c.solutions[0]), but in theory can |
| 349 be extended to all of them. | 367 be extended to all of them. |
| 350 | 368 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 370 """Updates config revision corresponding to patch_project. | 388 """Updates config revision corresponding to patch_project. |
| 371 | 389 |
| 372 Useful for bot_update only, as this is the only consumer of gclient's config | 390 Useful for bot_update only, as this is the only consumer of gclient's config |
| 373 revision map. This doesn't overwrite the revision if it was already set. | 391 revision map. This doesn't overwrite the revision if it was already set. |
| 374 """ | 392 """ |
| 375 assert patch_project is None or isinstance(patch_project, basestring) | 393 assert patch_project is None or isinstance(patch_project, basestring) |
| 376 cfg = gclient_config or self.c | 394 cfg = gclient_config or self.c |
| 377 path, revision = cfg.patch_projects.get(patch_project, (None, None)) | 395 path, revision = cfg.patch_projects.get(patch_project, (None, None)) |
| 378 if path and revision and path not in cfg.revisions: | 396 if path and revision and path not in cfg.revisions: |
| 379 cfg.revisions[path] = revision | 397 cfg.revisions[path] = revision |
| OLD | NEW |