Chromium Code Reviews| Index: gclient.py |
| diff --git a/gclient.py b/gclient.py |
| index c804186e858dc56b9d018008ceb742a5a93eb9c0..f2c2afaa33b08f701dbbcfcba7034394df640a7a 100644 |
| --- a/gclient.py |
| +++ b/gclient.py |
| @@ -923,15 +923,23 @@ solutions = [ |
| handle = urllib.urlopen(s.safesync_url) |
| rev = handle.read().strip() |
| handle.close() |
| - 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: |
| + if not len(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)) |
| + 'It appears your safesync_url (%s) is not working properly\n' |
| + '(as it returned an empty response). Check your config.' % |
| + s.safesync_url) |
| + # If the content of the safesync_url appears to be an SVN rev and the |
| + # URL of the source appears to be git, we can only attempt to find out |
| + # if a revision is useful after we've cloned the original URL. |
| + elif (rev.isdigit() and len(rev) < 7 and |
| + not os.path.isdir(os.path.join(s.root.root_dir, s.name)) and |
|
M-A Ruel
2011/12/21 18:31:02
I'd rather have GetUsableRev() handles that, it'd
Dan Beam
2011/12/21 20:20:11
Done.
|
| + gclient_scm.GetScmName(s.url) == 'git'): |
| + print('Checking out new git dependencies (%s) with an SVN\n' |
| + 'safesync_url (%s) isn\'t currently supported. Ignoring the\n' |
| + 'safesync_url during initial checkout.\n' % |
| + (s.url, s.safesync_url)) |
| + else: |
| + self._ApplySafeSyncRev(dependency=s, rev=rev) |
| if not self._options.revisions: |
| return revision_overrides |
| solutions_names = [s.name for s in self.dependencies] |
| @@ -950,6 +958,21 @@ solutions = [ |
| index += 1 |
| return revision_overrides |
| + def _ApplySafeSyncRev(self, dependency, rev): |
| + """Find a valid revision from the content of the safesync_url and apply it |
|
M-A Ruel
2011/12/21 18:31:02
Finds
Dan Beam
2011/12/21 20:20:11
Done.
|
| + by appending revisions to the revision list. Throws if revision appears to |
| + be invalid for the given |dependency|.""" |
| + scm = gclient_scm.CreateSCM(dependency.url, dependency.root.root_dir, |
| + dependency.name) |
| + safe_rev = scm.GetUsableRev(rev=rev, options=self._options) |
| + if not safe_rev: |
| + raise gclient_utils.Error( |
|
M-A Ruel
2011/12/21 18:31:02
You know that you are also raising inside GetUsabl
Dan Beam
2011/12/21 20:20:11
Done.
|
| + 'Despite our best attempts, we couldn\'t find a useful\n' |
| + 'safesync_url revision for you. Please check your config.') |
| + if self._options.verbose: |
| + print('Using safesync_url revision: %s.\n' % safe_rev) |
| + self._options.revisions.append('%s@%s' % (dependency.name, safe_rev)) |
| + |
| def RunOnDeps(self, command, args): |
| """Runs a command on each dependency in a client and its dependencies. |