From 0b1c246cd7daf279c6d5aa539b494b6a817bb5fe Mon Sep 17 00:00:00 2001 From: "maruel@chromium.org" Date: Tue, 2 Mar 2010 00:48:14 +0000 Subject: [PATCH] Add automatic retry on "git remote update". It does remote connection and can get HTTP 502 when used over http. Review URL: http://codereview.chromium.org/661280 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@40330 0039d316-1c4b-4281-b951-d872f2087c98 --- gclient_scm.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/gclient_scm.py b/gclient_scm.py index 26d9a1588..36f043b3c 100644 --- a/gclient_scm.py +++ b/gclient_scm.py @@ -251,10 +251,23 @@ class GitWrapper(SCMWrapper, scm.GIT): else: raise gclient_utils.Error('Invalid Upstream') - # Update the remotes first so we have all the refs - remote_output, remote_err = self.Capture(['remote'] + verbose + ['update'], - self.checkout_path, - print_error=False) + # Update the remotes first so we have all the refs. + for i in range(3): + try: + remote_output, remote_err = self.Capture( + ['remote'] + verbose + ['update'], + self.checkout_path, + print_error=False) + break + except gclient_utils.CheckCallError, e: + # Hackish but at that point, git is known to work so just checking for + # 502 in stderr should be fine. + if '502' in e.stderr: + print str(e) + print "Retrying..." + continue + raise e + if verbose: print remote_output.strip() # git remote update prints to stderr when used with --verbose