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

Side by Side Diff: tools/auto_bisect/bisect_utils.py

Issue 640733004: Delete index.lock files before checking out master branch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 """Utility functions used by the bisect tool. 5 """Utility functions used by the bisect tool.
6 6
7 This includes functions related to checking out the depot and outputting 7 This includes functions related to checking out the depot and outputting
8 annotations for the Buildbot waterfall. 8 annotations for the Buildbot waterfall.
9 """ 9 """
10 10
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 path: The path name passed to func. 303 path: The path name passed to func.
304 _: Exception information from sys.exc_info(). Not used. 304 _: Exception information from sys.exc_info(). Not used.
305 """ 305 """
306 if not os.access(path, os.W_OK): 306 if not os.access(path, os.W_OK):
307 os.chmod(path, stat.S_IWUSR) 307 os.chmod(path, stat.S_IWUSR)
308 func(path) 308 func(path)
309 else: 309 else:
310 raise 310 raise
311 311
312 312
313 def _CleanupPreviousGitRuns(): 313 def _CleanupPreviousGitRuns(cwd=os.getcwd()):
314 """Cleans up any leftover index.lock files after running git.""" 314 """Cleans up any leftover index.lock files after running git."""
315 # If a previous run of git crashed, or bot was reset, etc., then we might 315 # If a previous run of git crashed, or bot was reset, etc., then we might
316 # end up with leftover index.lock files. 316 # end up with leftover index.lock files.
317 for path, _, files in os.walk(os.getcwd()): 317 for path, _, files in os.walk(cwd):
318 for cur_file in files: 318 for cur_file in files:
319 if cur_file.endswith('index.lock'): 319 if cur_file.endswith('index.lock'):
320 path_to_file = os.path.join(path, cur_file) 320 path_to_file = os.path.join(path, cur_file)
321 os.remove(path_to_file) 321 os.remove(path_to_file)
322 322
323 323
324 def RunGClientAndSync(cwd=None): 324 def RunGClientAndSync(cwd=None):
325 """Runs gclient and does a normal sync. 325 """Runs gclient and does a normal sync.
326 326
327 Args: 327 Args:
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 Args: 415 Args:
416 opts: The options parsed from the command line through parse_args(). 416 opts: The options parsed from the command line through parse_args().
417 custom_deps: A dictionary of additional dependencies to add to .gclient. 417 custom_deps: A dictionary of additional dependencies to add to .gclient.
418 """ 418 """
419 if CheckIfBisectDepotExists(opts): 419 if CheckIfBisectDepotExists(opts):
420 path_to_dir = os.path.join(os.path.abspath(opts.working_directory), 420 path_to_dir = os.path.join(os.path.abspath(opts.working_directory),
421 BISECT_DIR, 'src') 421 BISECT_DIR, 'src')
422 (output, _) = RunGit(['rev-parse', '--is-inside-work-tree'], 422 (output, _) = RunGit(['rev-parse', '--is-inside-work-tree'],
423 cwd=path_to_dir) 423 cwd=path_to_dir)
424 if output.strip() == 'true': 424 if output.strip() == 'true':
425 # Before checking out master, cleanup up any leftover index.lock files.
426 _CleanupPreviousGitRuns(path_to_dir)
425 # Checks out the master branch, throws an exception if git command fails. 427 # Checks out the master branch, throws an exception if git command fails.
426 CheckRunGit(['checkout', '-f', 'master'], cwd=path_to_dir) 428 CheckRunGit(['checkout', '-f', 'master'], cwd=path_to_dir)
427
428 if not _CreateAndChangeToSourceDirectory(opts.working_directory): 429 if not _CreateAndChangeToSourceDirectory(opts.working_directory):
429 raise RuntimeError('Could not create bisect directory.') 430 raise RuntimeError('Could not create bisect directory.')
430 431
431 if not SetupGitDepot(opts, custom_deps): 432 if not SetupGitDepot(opts, custom_deps):
432 raise RuntimeError('Failed to grab source.') 433 raise RuntimeError('Failed to grab source.')
433 434
434 435
435 def RunProcess(command): 436 def RunProcess(command):
436 """Runs an arbitrary command. 437 """Runs an arbitrary command.
437 438
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 platform = os.environ.get('PROCESSOR_ARCHITECTURE') 510 platform = os.environ.get('PROCESSOR_ARCHITECTURE')
510 return platform and platform in ['AMD64', 'I64'] 511 return platform and platform in ['AMD64', 'I64']
511 512
512 513
513 def IsLinuxHost(): 514 def IsLinuxHost():
514 return sys.platform.startswith('linux') 515 return sys.platform.startswith('linux')
515 516
516 517
517 def IsMacHost(): 518 def IsMacHost():
518 return sys.platform.startswith('darwin') 519 return sys.platform.startswith('darwin')
OLDNEW
« 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