From b71b67e2aa6340c799bef03d772317b8f6de3b5f Mon Sep 17 00:00:00 2001 From: "maruel@chromium.org" Date: Tue, 24 Nov 2009 20:48:19 +0000 Subject: [PATCH] Add an automatic retry on some svn commands. Subversion's client just bails out too early too often. Review URL: http://codereview.chromium.org/437015 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@32967 0039d316-1c4b-4281-b951-d872f2087c98 --- scm.py | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/scm.py b/scm.py index 99dccf974..58f26c6a9 100644 --- a/scm.py +++ b/scm.py @@ -165,19 +165,34 @@ class SVN(object): 'status': status_pattern, 'update': update_pattern, }[args[0]] - compiled_pattern = re.compile(pattern) - - def CaptureMatchingLines(line): - match = compiled_pattern.search(line) - if match: - file_list.append(match.group(1)) - - SVN.RunAndFilterOutput(args, - in_directory, - options.verbose, - True, - CaptureMatchingLines) + # Place an upper limit. + for i in range(1, 10): + previous_list_len = len(file_list) + failure = [] + def CaptureMatchingLines(line): + match = compiled_pattern.search(line) + if match: + file_list.append(match.group(1)) + if line.startswith('svn: '): + # We can't raise an exception. We can't alias a variable. Use a cheap + # way. + failure.append(True) + try: + SVN.RunAndFilterOutput(args, + in_directory, + options.verbose, + True, + CaptureMatchingLines) + except gclient_utils.Error: + # We enforce that some progress has been made. + if len(failure) and len(file_list) > previous_list_len: + if args[0] == 'checkout': + args = args[:] + # An aborted checkout is now an update. + args[0] = 'update' + continue + break @staticmethod def RunAndFilterOutput(args,