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

Side by Side Diff: scm.py

Issue 3326004: gclient: exponential backoff of SCM commands on known failure types.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: '' Created 10 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 | Annotate | Revision Log
« no previous file with comments | « gclient_scm.py ('k') | 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 (c) 2006-2009 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2006-2009 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 """SCM-specific utility classes.""" 5 """SCM-specific utility classes."""
6 6
7 import cStringIO 7 import cStringIO
8 import glob 8 import glob
9 import os 9 import os
10 import re 10 import re
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 # else, which is good. Note that the patterns are only effective when 357 # else, which is good. Note that the patterns are only effective when
358 # these commands are used in their ordinary forms, the patterns are invalid 358 # these commands are used in their ordinary forms, the patterns are invalid
359 # for "svn status --show-updates", for example. 359 # for "svn status --show-updates", for example.
360 pattern = { 360 pattern = {
361 'checkout': update_pattern, 361 'checkout': update_pattern,
362 'status': status_pattern, 362 'status': status_pattern,
363 'update': update_pattern, 363 'update': update_pattern,
364 }[args[0]] 364 }[args[0]]
365 compiled_pattern = re.compile(pattern) 365 compiled_pattern = re.compile(pattern)
366 # Place an upper limit. 366 # Place an upper limit.
367 backoff_time = 5
367 for _ in range(10): 368 for _ in range(10):
368 previous_list_len = len(file_list) 369 previous_list_len = len(file_list)
369 failure = [] 370 failure = []
370 371
371 def CaptureMatchingLines(line): 372 def CaptureMatchingLines(line):
372 match = compiled_pattern.search(line) 373 match = compiled_pattern.search(line)
373 if match: 374 if match:
374 file_list.append(match.group(1)) 375 file_list.append(match.group(1))
375 if line.startswith('svn: '): 376 if line.startswith('svn: '):
376 failure.append(line) 377 failure.append(line)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 else: 411 else:
411 # Progress was made, convert to update since an aborted checkout 412 # Progress was made, convert to update since an aborted checkout
412 # is now an update. 413 # is now an update.
413 args = ['update'] + args[1:] 414 args = ['update'] + args[1:]
414 else: 415 else:
415 # It was an update or export. 416 # It was an update or export.
416 # We enforce that some progress has been made or a known failure. 417 # We enforce that some progress has been made or a known failure.
417 if len(file_list) == previous_list_len and not IsKnownFailure(): 418 if len(file_list) == previous_list_len and not IsKnownFailure():
418 # No known svn error was found and no progress, bail out. 419 # No known svn error was found and no progress, bail out.
419 raise 420 raise
420 print "Sleeping 15 seconds and retrying...." 421 print "Sleeping %.1f seconds and retrying...." % backoff_time
421 time.sleep(15) 422 time.sleep(backoff_time)
423 backoff_time *= 1.3
422 continue 424 continue
423 break 425 break
424 426
425 @staticmethod 427 @staticmethod
426 def CaptureInfo(relpath, in_directory=None, print_error=True): 428 def CaptureInfo(relpath, in_directory=None, print_error=True):
427 """Returns a dictionary from the svn info output for the given file. 429 """Returns a dictionary from the svn info output for the given file.
428 430
429 Args: 431 Args:
430 relpath: The directory where the working copy resides relative to 432 relpath: The directory where the working copy resides relative to
431 the directory given by in_directory. 433 the directory given by in_directory.
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 if not SVN.current_version: 844 if not SVN.current_version:
843 SVN.current_version = SVN.Capture(['--version']).split()[2] 845 SVN.current_version = SVN.Capture(['--version']).split()[2]
844 current_version_list = map(only_int, SVN.current_version.split('.')) 846 current_version_list = map(only_int, SVN.current_version.split('.'))
845 for min_ver in map(int, min_version.split('.')): 847 for min_ver in map(int, min_version.split('.')):
846 ver = current_version_list.pop(0) 848 ver = current_version_list.pop(0)
847 if ver < min_ver: 849 if ver < min_ver:
848 return (False, SVN.current_version) 850 return (False, SVN.current_version)
849 elif ver > min_ver: 851 elif ver > min_ver:
850 return (True, SVN.current_version) 852 return (True, SVN.current_version)
851 return (True, SVN.current_version) 853 return (True, SVN.current_version)
OLDNEW
« no previous file with comments | « gclient_scm.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698