Chromium Code Reviews| Index: gclient_scm.py |
| diff --git a/gclient_scm.py b/gclient_scm.py |
| index 7dc0bd8018693859b15529b74ba0fb747973c5fe..7e639675248c0768f1c677a470e05322359bacde 100644 |
| --- a/gclient_scm.py |
| +++ b/gclient_scm.py |
| @@ -9,11 +9,15 @@ import logging |
| import os |
| import posixpath |
| import re |
| +import shutil |
| import sys |
| +import tarfile |
| import tempfile |
| import threading |
| import time |
| +import urlparse |
| +import download_from_google_storage |
| import gclient_utils |
| import scm |
| import subprocess2 |
| @@ -21,6 +25,10 @@ import subprocess2 |
| THIS_FILE_PATH = os.path.abspath(__file__) |
| +GSUTIL_DEFAULT_PATH = os.path.join( |
| + os.path.dirname(os.path.abspath(__file__)), |
| + 'third_party', 'gsutil', 'gsutil') |
| + |
| class DiffFiltererWrapper(object): |
| """Simple base class which tracks which file is being diffed and |
| @@ -1170,7 +1178,66 @@ class SVNWrapper(SCMWrapper): |
| 'present. Delete the directory and try again.') |
| raise gclient_utils.Error(msg % self.checkout_path) |
| + BASE_URLS = { |
| + '/chrome/trunk/src': { |
| + 'gs_path': '/chromium-svn-checkout/chrome/' |
|
cmp
2013/12/26 19:25:45
Prepend gs:/ to this and on line 1186.
hinoka
2014/01/07 00:57:25
Done.
|
| + }, |
| + '/blink/trunk' : { |
| + 'gs_path': '/chromium-svn-checkout/blink/' |
| + } |
| + } |
| if not exists: |
| + try: |
| + # Split out the revision number, its not useful for us. |
|
cmp
2013/12/26 19:25:45
number, its -> number since it's
hinoka
2014/01/07 00:57:25
Done.
|
| + base_path = urlparse.urlparse(url).path.split('@')[0] |
| + if ('CHROME_HEADLESS' in os.environ |
| + and sys.platform == 'linux2' # TODO(hinoka): Enable for win/mac. |
| + and base_path in BASE_URLS): |
| + # Use a tarball for initial sync if we are on a bot. |
| + # Get an unauthenticated gsutil instance. |
| + gsutil = download_from_google_storage.Gsutil(GSUTIL_DEFAULT_PATH, |
| + boto_path=os.devnull) |
|
cmp
2013/12/26 19:25:45
Indent needs to be fixed. It would be better as:
hinoka
2014/01/07 00:57:25
Done.
|
| + |
| + entry = BASE_URLS[base_path] |
| + gs_path = entry['gs_path'] |
| + _, out, _ = gsutil.check_call('ls', 'gs:/%s' % gs_path) |
|
cmp
2013/12/26 19:25:45
Just use gs_path here (no string shenanigans req'd
hinoka
2014/01/07 00:57:25
Done.
|
| + # So that we can get the most recent revision. |
| + sorted_items = sorted(out.splitlines()) |
| + latest_checkout = sorted_items[-1] |
| + |
| + tempdir = tempfile.mkdtemp() |
| + print 'Downloading %s...' % latest_checkout |
| + code, out, err = gsutil.check_call('cp', latest_checkout, tempdir) |
| + if code: |
| + print '%s\n%s' % (out, err) |
| + raise Exception() |
| + filename = latest_checkout.split('/')[-1] |
| + tarball = os.path.join(tempdir, filename) |
| + print 'Unpacking into %s...' % self.checkout_path |
| + with tarfile.open(tarball, 'r:gz') as f: |
| + f.extractall(self.checkout_path) |
|
cmp
2013/12/26 19:25:45
Use a local executable to unpack rather than Pytho
hinoka
2014/01/07 00:57:25
This would make gclient_scm pretty unportable :(
T
cmp
2014/01/07 01:09:52
You're assuming too much about how well an in-proc
hinoka
2014/01/07 02:03:32
How big of a tarball and what sort of problems are
|
| + print 'Deleting temp file' |
| + shutil.rmtree(tempdir) |
|
cmp
2014/01/07 01:09:52
We found rmtree() to cause problems on Windows. W
hinoka
2014/01/07 02:03:32
Just realized gclient_utils.rmtree does exactly wh
|
| + |
| + # Rewrite the repository root to match. |
| + tarball_url = scm.SVN.CaptureLocalInfo( |
| + ['.'], self.checkout_path)['Repository Root'] |
| + tarball_parsed = urlparse.urlparse(tarball_url) |
| + tarball_root = '%s://%s' % (tarball_parsed.scheme, |
| + tarball_parsed.netloc) |
| + local_parsed = urlparse.urlparse(url) |
| + local_root = '%s://%s' % (local_parsed.scheme, local_parsed.netloc) |
| + |
| + if tarball_root != local_root: |
| + print 'Switching repository root to %s' % local_root |
| + self._Run(['switch', '--relocate', tarball_root, |
| + local_root, self.checkout_path], |
|
cmp
2013/12/26 19:25:45
Indent needs to be less one character on line 1234
hinoka
2014/01/07 00:57:25
Done.
|
| + options) |
| + except Exception as e: |
| + print 'We tried to get a source tarball but failed.' |
| + print 'Resuming normal operations.' |
| + print str(e) |
| + |
| gclient_utils.safe_makedirs(os.path.dirname(self.checkout_path)) |
| # We need to checkout. |
| command = ['checkout', url, self.checkout_path] |