Commit 6133c5b6 authored by maruel@chromium.org's avatar maruel@chromium.org

Improve the retry algorithm to be much more liberal.

BUG=chromium-os:5305
TEST=gclient sync should be much more resistent

Review URL: http://codereview.chromium.org/3132021

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@56565 0039d316-1c4b-4281-b951-d872f2087c98
parent 945405e8
...@@ -446,43 +446,39 @@ class SVN(object): ...@@ -446,43 +446,39 @@ class SVN(object):
True, True,
CaptureMatchingLines) CaptureMatchingLines)
except gclient_utils.Error: except gclient_utils.Error:
def IsKnownFailure():
for x in failure:
if (x.startswith('svn: OPTIONS of') or
x.startswith('svn: PROPFIND of') or
x.startswith('svn: REPORT of') or
x.startswith('svn: Unknown hostname')):
return True
return False
# Subversion client is really misbehaving with Google Code. # Subversion client is really misbehaving with Google Code.
if args[0] == 'checkout': if args[0] == 'checkout':
# Ensure at least one file was checked out, otherwise *delete* the # Ensure at least one file was checked out, otherwise *delete* the
# directory. # directory.
if len(file_list) == previous_list_len: if len(file_list) == previous_list_len:
for x in failure: if not IsKnownFailure():
if ('502 Bad Gateway' in x or
'svn: REPORT of \'/svn/!svn/vcc/default\': 200 OK' in x):
# No file were checked out, so make sure the directory is
# deleted in case it's messed up and try again.
# Warning: It's bad, it assumes args[2] is the directory
# argument.
if os.path.isdir(args[2]):
gclient_utils.RemoveDirectory(args[2])
break
else:
# No known svn error was found, bail out. # No known svn error was found, bail out.
raise raise
# No file were checked out, so make sure the directory is
# deleted in case it's messed up and try again.
# Warning: It's bad, it assumes args[2] is the directory
# argument.
if os.path.isdir(args[2]):
gclient_utils.RemoveDirectory(args[2])
else: else:
# Progress was made, convert to update since an aborted checkout # Progress was made, convert to update since an aborted checkout
# is now an update. # is now an update.
args = ['update'] + args[1:] args = ['update'] + args[1:]
else: else:
# It was an update or export. # It was an update or export.
# We enforce that some progress has been made or HTTP 502. # We enforce that some progress has been made or a known failure.
if len(file_list) == previous_list_len: if len(file_list) == previous_list_len and not IsKnownFailure():
for x in failure: # No known svn error was found and no progress, bail out.
if ('502 Bad Gateway' in x or raise
'svn: REPORT of \'/svn/!svn/vcc/default\': 200 OK' in x):
# Ok, know failure code.
break
else:
# No known svn error was found, bail out.
raise
else:
# Progress was made, it's fine.
pass
print "Sleeping 15 seconds and retrying...." print "Sleeping 15 seconds and retrying...."
time.sleep(15) time.sleep(15)
continue continue
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment