[depot_tools] Use git fetch to optimize the properly configured that use git-svn
in the way <http://code.google.com/p/chromium/wiki/UsingNewGit#Initial_checkout>
describes.
R=maruel@chromium.org
TEST=gclient sync with safesync_url is faster.
BUG=109184
Review URL: http://codereview.chromium.org/9379005
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@121988 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gclient_scm.py b/gclient_scm.py
index 2a97e89..9f74cc5 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -514,6 +514,14 @@
scm.GIT.IsGitSvn(cwd=self.checkout_path)):
local_head = scm.GIT.GetGitSvnHeadRev(cwd=self.checkout_path)
if not local_head or local_head < int(rev):
+ try:
+ logging.debug('Looking for git-svn configuration optimizations.')
+ if scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'],
+ cwd=self.checkout_path):
+ scm.GIT.Capture(['fetch'], cwd=self.checkout_path)
+ except subprocess2.CalledProcessError:
+ logging.debug('git config --get svn-remote.svn.fetch failed, '
+ 'ignoring possible optimization.')
if options.verbose:
print('Running git svn fetch. This might take a while.\n')
scm.GIT.Capture(['svn', 'fetch'], cwd=self.checkout_path)