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

Unified Diff: gclient_scm.py

Issue 574017: Add automatic retry on HTTP 502 for svn and connection drop for git. (Closed)
Patch Set: Created 10 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | scm.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient_scm.py
diff --git a/gclient_scm.py b/gclient_scm.py
index bacbb6557626f872eadf440f19f77af9116bf7a3..bdc9666576bf8a246cf4a70816f80a448699bf86 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -179,8 +179,25 @@ class GitWrapper(SCMWrapper, scm.GIT):
print("\n_____ %s%s" % (self.relpath, rev_str))
if not os.path.exists(self.checkout_path):
- self._Run(['clone', url, self.checkout_path],
- cwd=self._root_dir, redirect_stdout=False)
+ # Cloning
+ for i in range(3):
+ try:
+ self._Run(['clone', url, self.checkout_path],
+ cwd=self._root_dir, redirect_stdout=False)
+ break
+ except gclient_utils.Error, e:
+ # TODO(maruel): Hackish, should be fixed by moving _Run() to
+ # CheckCall().
+ # Too bad we don't have access to the actual output.
+ # We should check for "transfer closed with NNN bytes remaining to
+ # read". In the meantime, just make sure .git exists.
+ if (e.args[0] == 'git command clone returned 128' and
+ os.path.exists(os.path.join(self.checkout_path, '.git'))):
+ print str(e)
+ print "Retrying..."
+ continue
+ raise e
+
if revision:
self._Run(['reset', '--hard', revision], redirect_stdout=False)
files = self._Run(['ls-files']).split()
@@ -209,14 +226,18 @@ class GitWrapper(SCMWrapper, scm.GIT):
'\tSee man git-rebase for details.\n'
% (self.relpath, rev_str))
+ # TODO(maruel): Do we need to do an automatic retry here? Probably overkill
merge_base = self._Run(['merge-base', 'HEAD', new_base])
self._Run(['remote', 'update'], redirect_stdout=False)
files = self._Run(['diff', new_base, '--name-only']).split()
file_list.extend([os.path.join(self.checkout_path, f) for f in files])
if options.force:
self._Run(['reset', '--hard', merge_base], redirect_stdout=False)
- self._Run(['rebase', '-v', '--onto', new_base, merge_base, cur_branch],
- redirect_stdout=False, checkrc=False)
+ try:
+ self._Run(['rebase', '-v', '--onto', new_base, merge_base, cur_branch],
+ redirect_stdout=False)
+ except gclient_utils.Error:
+ pass
# If the rebase generated a conflict, abort and ask user to fix
if self._GetCurrentBranch() is None:
@@ -298,13 +319,13 @@ class GitWrapper(SCMWrapper, scm.GIT):
return None
return branch
- def _Run(self, args, cwd=None, checkrc=True, redirect_stdout=True):
- # TODO(maruel): Merge with Capture?
+ def _Run(self, args, cwd=None, redirect_stdout=True):
+ # TODO(maruel): Merge with Capture or better gclient_utils.CheckCall().
if cwd is None:
cwd = self.checkout_path
- stdout=None
+ stdout = None
if redirect_stdout:
- stdout=subprocess.PIPE
+ stdout = subprocess.PIPE
if cwd == None:
cwd = self.checkout_path
cmd = [self.COMMAND]
@@ -316,7 +337,7 @@ class GitWrapper(SCMWrapper, scm.GIT):
except OSError:
raise gclient_utils.Error("git command '%s' failed to run." %
' '.join(cmd) + "\nCheck that you have git installed.")
- if checkrc and sp.returncode:
+ if sp.returncode:
raise gclient_utils.Error('git command %s returned %d' %
(args[0], sp.returncode))
if output is not None:
« no previous file with comments | « no previous file | scm.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698