From cbd20a408f169b67225b6ea4147e49e92882d564 Mon Sep 17 00:00:00 2001 From: "bauerb@chromium.org" Date: Wed, 27 Jun 2012 13:49:27 +0000 Subject: [PATCH] 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 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=143898 Reverted: http://src.chromium.org/viewvc/chrome?view=rev&revision=143911 Review URL: https://chromiumcodereview.appspot.com/10668020 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@144451 0039d316-1c4b-4281-b951-d872f2087c98 --- gclient_scm.py | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/gclient_scm.py b/gclient_scm.py index 68f3be328..0f34d3860 100644 --- a/gclient_scm.py +++ b/gclient_scm.py @@ -353,27 +353,28 @@ class GitWrapper(SCMWrapper): else: raise gclient_utils.Error('Invalid Upstream: %s' % upstream_branch) - # Update the remotes first so we have all the refs. - backoff_time = 5 - for _ in range(10): - try: - remote_output = scm.GIT.Capture( - ['remote'] + verbose + ['update'], - cwd=self.checkout_path) - break - except subprocess2.CalledProcessError, 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('Sleeping %.1f seconds and retrying...' % backoff_time) - time.sleep(backoff_time) - backoff_time *= 1.3 - continue - raise + if not scm.GIT.IsValidRevision(cwd=self.checkout_path, rev=revision): + # Update the remotes first so we have all the refs. + backoff_time = 5 + for _ in range(10): + try: + remote_output = scm.GIT.Capture( + ['remote'] + verbose + ['update'], + cwd=self.checkout_path) + break + except subprocess2.CalledProcessError, 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('Sleeping %.1f seconds and retrying...' % backoff_time) + time.sleep(backoff_time) + backoff_time *= 1.3 + continue + raise - if verbose: - print(remote_output.strip()) + if verbose: + print(remote_output.strip()) # This is a big hammer, debatable if it should even be here... if options.force or options.reset: