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

Side by Side Diff: gclient_scm.py

Issue 661280: Add automatic retry on "git remote update". (Closed)
Patch Set: Created 10 years, 9 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
« no previous file with comments | « no previous file | 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) 2009 The Chromium Authors. All rights reserved. 1 # Copyright (c) 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 """Gclient-specific SCM-specific operations.""" 5 """Gclient-specific SCM-specific operations."""
6 6
7 import logging 7 import logging
8 import os 8 import os
9 import posixpath 9 import posixpath
10 import re 10 import re
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 upstream_branch = self.GetUpstream(self.checkout_path) 244 upstream_branch = self.GetUpstream(self.checkout_path)
245 if not upstream_branch or not upstream_branch.startswith('refs/remotes'): 245 if not upstream_branch or not upstream_branch.startswith('refs/remotes'):
246 current_type = "hash" 246 current_type = "hash"
247 logging.debug("Current branch is based off a specific rev and is not " 247 logging.debug("Current branch is based off a specific rev and is not "
248 "tracking an upstream.") 248 "tracking an upstream.")
249 elif upstream_branch.startswith('refs/remotes'): 249 elif upstream_branch.startswith('refs/remotes'):
250 current_type = "branch" 250 current_type = "branch"
251 else: 251 else:
252 raise gclient_utils.Error('Invalid Upstream') 252 raise gclient_utils.Error('Invalid Upstream')
253 253
254 # Update the remotes first so we have all the refs 254 # Update the remotes first so we have all the refs.
255 remote_output, remote_err = self.Capture(['remote'] + verbose + ['update'], 255 for i in range(3):
256 self.checkout_path, 256 try:
257 print_error=False) 257 remote_output, remote_err = self.Capture(
258 ['remote'] + verbose + ['update'],
259 self.checkout_path,
260 print_error=False)
261 break
262 except gclient_utils.CheckCallError, e:
263 # Hackish but at that point, git is known to work so just checking for
264 # 502 in stderr should be fine.
265 if '502' in e.stderr:
266 print str(e)
267 print "Retrying..."
268 continue
269 raise e
270
258 if verbose: 271 if verbose:
259 print remote_output.strip() 272 print remote_output.strip()
260 # git remote update prints to stderr when used with --verbose 273 # git remote update prints to stderr when used with --verbose
261 print remote_err.strip() 274 print remote_err.strip()
262 275
263 # This is a big hammer, debatable if it should even be here... 276 # This is a big hammer, debatable if it should even be here...
264 if options.force or options.reset: 277 if options.force or options.reset:
265 self._Run(['reset', '--hard', 'HEAD'], redirect_stdout=False) 278 self._Run(['reset', '--hard', 'HEAD'], redirect_stdout=False)
266 279
267 if current_type is 'hash': 280 if current_type is 'hash':
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 print("\n________ couldn't run \'%s\' in \'%s\':\nThe directory " 828 print("\n________ couldn't run \'%s\' in \'%s\':\nThe directory "
816 "does not exist." 829 "does not exist."
817 % (' '.join(command), path)) 830 % (' '.join(command), path))
818 # There's no file list to retrieve. 831 # There's no file list to retrieve.
819 else: 832 else:
820 self.RunAndGetFileList(options, command, path, file_list) 833 self.RunAndGetFileList(options, command, path, file_list)
821 834
822 def FullUrlForRelativeUrl(self, url): 835 def FullUrlForRelativeUrl(self, url):
823 # Find the forth '/' and strip from there. A bit hackish. 836 # Find the forth '/' and strip from there. A bit hackish.
824 return '/'.join(self.url.split('/')[:4]) + url 837 return '/'.join(self.url.split('/')[:4]) + url
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698