[depot_tools] Adding safesync_url for git and git-svn checkouts.
R=maruel@chromium.org
TEST=Configure a checkout using the NewGitWorkflow with a safesync_url and everything works (though possibly with a really long git svn fetch time).
BUG=106015
Review URL: http://codereview.chromium.org/8382030
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@115011 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gclient.py b/gclient.py
index e29eaa8..c804186 100644
--- a/gclient.py
+++ b/gclient.py
@@ -923,8 +923,15 @@
handle = urllib.urlopen(s.safesync_url)
rev = handle.read().strip()
handle.close()
- if len(rev):
- self._options.revisions.append('%s@%s' % (s.name, rev))
+ scm = gclient_scm.CreateSCM(s.url, s.root.root_dir, s.name)
+ safe_rev = scm.GetUsableRev(rev=rev, options=self._options)
+ if not safe_rev:
+ raise gclient_utils.Error(
+ 'Despite our best attempts, we couldn\'t find a useful\n'
+ 'safesync_url revision for you.')
+ if self._options.verbose:
+ print('Using safesync_url revision: %s.\n' % safe_rev)
+ self._options.revisions.append('%s@%s' % (s.name, safe_rev))
if not self._options.revisions:
return revision_overrides
solutions_names = [s.name for s in self.dependencies]