Commit f407f09f authored by bauerb@chromium.org's avatar bauerb@chromium.org

Skip updating remotes if we already have the upstream revision.

This should make a `gclient sync` faster, especially on Windows, where git hangs regularly.

BUG=none
TEST=gclient sync -v doesn't print "Fetching origin" all the time


Review URL: https://chromiumcodereview.appspot.com/10668020

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@143898 0039d316-1c4b-4281-b951-d872f2087c98
parent 78f5c164
...@@ -353,27 +353,28 @@ class GitWrapper(SCMWrapper): ...@@ -353,27 +353,28 @@ class GitWrapper(SCMWrapper):
else: else:
raise gclient_utils.Error('Invalid Upstream: %s' % upstream_branch) raise gclient_utils.Error('Invalid Upstream: %s' % upstream_branch)
# Update the remotes first so we have all the refs. if not scm.GIT.IsValidRevision(cwd=self.checkout_path, rev=revision):
backoff_time = 5 # Update the remotes first so we have all the refs.
for _ in range(10): backoff_time = 5
try: for _ in range(10):
remote_output = scm.GIT.Capture( try:
['remote'] + verbose + ['update'], remote_output = scm.GIT.Capture(
cwd=self.checkout_path) ['remote'] + verbose + ['update'],
break cwd=self.checkout_path)
except subprocess2.CalledProcessError, e: break
# Hackish but at that point, git is known to work so just checking for except subprocess2.CalledProcessError, e:
# 502 in stderr should be fine. # Hackish but at that point, git is known to work so just checking for
if '502' in e.stderr: # 502 in stderr should be fine.
print(str(e)) if '502' in e.stderr:
print('Sleeping %.1f seconds and retrying...' % backoff_time) print(str(e))
time.sleep(backoff_time) print('Sleeping %.1f seconds and retrying...' % backoff_time)
backoff_time *= 1.3 time.sleep(backoff_time)
continue backoff_time *= 1.3
raise continue
raise
if verbose: if verbose:
print(remote_output.strip()) print(remote_output.strip())
# This is a big hammer, debatable if it should even be here... # This is a big hammer, debatable if it should even be here...
if options.force or options.reset: if options.force or options.reset:
......
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