Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(959)

Side by Side Diff: gclient_scm.py

Issue 103803006: Checkout tarball for chrome and blink for initial sync on a bot (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: nit comma Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Gclient-specific SCM-specific operations.""" 5 """Gclient-specific SCM-specific operations."""
6 6
7 import collections 7 import collections
8 import logging 8 import logging
9 import os 9 import os
10 import posixpath 10 import posixpath
11 import re 11 import re
12 import sys 12 import sys
13 import tempfile 13 import tempfile
14 import threading 14 import threading
15 import time 15 import time
16 import urlparse
16 17
18 import download_from_google_storage
17 import gclient_utils 19 import gclient_utils
18 import scm 20 import scm
19 import subprocess2 21 import subprocess2
20 22
21 23
22 THIS_FILE_PATH = os.path.abspath(__file__) 24 THIS_FILE_PATH = os.path.abspath(__file__)
23 25
26 GSUTIL_DEFAULT_PATH = os.path.join(
27 os.path.dirname(os.path.abspath(__file__)),
28 'third_party', 'gsutil', 'gsutil')
29
24 30
25 class DiffFiltererWrapper(object): 31 class DiffFiltererWrapper(object):
26 """Simple base class which tracks which file is being diffed and 32 """Simple base class which tracks which file is being diffed and
27 replaces instances of its file name in the original and 33 replaces instances of its file name in the original and
28 working copy lines of the svn/git diff output.""" 34 working copy lines of the svn/git diff output."""
29 index_string = None 35 index_string = None
30 original_prefix = "--- " 36 original_prefix = "--- "
31 working_prefix = "+++ " 37 working_prefix = "+++ "
32 38
33 def __init__(self, relpath): 39 def __init__(self, relpath):
(...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 except (gclient_utils.Error, subprocess2.CalledProcessError): 1169 except (gclient_utils.Error, subprocess2.CalledProcessError):
1164 if options.reset and options.delete_unversioned_trees: 1170 if options.reset and options.delete_unversioned_trees:
1165 print 'Removing troublesome path %s' % self.checkout_path 1171 print 'Removing troublesome path %s' % self.checkout_path
1166 gclient_utils.rmtree(self.checkout_path) 1172 gclient_utils.rmtree(self.checkout_path)
1167 exists = False 1173 exists = False
1168 else: 1174 else:
1169 msg = ('Can\'t update/checkout %s if an unversioned directory is ' 1175 msg = ('Can\'t update/checkout %s if an unversioned directory is '
1170 'present. Delete the directory and try again.') 1176 'present. Delete the directory and try again.')
1171 raise gclient_utils.Error(msg % self.checkout_path) 1177 raise gclient_utils.Error(msg % self.checkout_path)
1172 1178
1179 BASE_URLS = {
1180 '/chrome/trunk/src': 'gs://chromium-svn-checkout/chrome/',
1181 '/blink/trunk': 'gs://chromium-svn-checkout/blink/',
1182 }
1173 if not exists: 1183 if not exists:
1184 try:
1185 # Split out the revision number since it's not useful for us.
1186 base_path = urlparse.urlparse(url).path.split('@')[0]
1187 if ('CHROME_HEADLESS' in os.environ
1188 and sys.platform == 'linux2' # TODO(hinoka): Enable for win/mac.
1189 and base_path in BASE_URLS):
1190 # Use a tarball for initial sync if we are on a bot.
1191 # Get an unauthenticated gsutil instance.
1192 gsutil = download_from_google_storage.Gsutil(
1193 GSUTIL_DEFAULT_PATH, boto_path=os.devnull)
1194
1195 gs_path = BASE_URLS[base_path]
1196 _, out, _ = gsutil.check_call('ls', gs_path)
1197 # So that we can get the most recent revision.
1198 sorted_items = sorted(out.splitlines())
1199 latest_checkout = sorted_items[-1]
1200
1201 tempdir = tempfile.mkdtemp()
1202 print 'Downloading %s...' % latest_checkout
1203 code, out, err = gsutil.check_call('cp', latest_checkout, tempdir)
1204 if code:
1205 print '%s\n%s' % (out, err)
1206 raise Exception()
1207 filename = latest_checkout.split('/')[-1]
1208 tarball = os.path.join(tempdir, filename)
1209 print 'Unpacking into %s...' % self.checkout_path
1210 gclient_utils.safe_makedirs(self.checkout_path)
1211 # TODO(hinoka): Use 7z for windows.
1212 cmd = ['tar', '--extract', '--ungzip',
1213 '--directory', self.checkout_path,
1214 '--file', tarball]
1215 gclient_utils.CheckCallAndFilter(
1216 cmd, stdout=sys.stdout, print_stdout=True)
1217
1218 print 'Deleting temp file'
1219 gclient_utils.rmtree(tempdir)
1220
1221 # Rewrite the repository root to match.
1222 tarball_url = scm.SVN.CaptureLocalInfo(
1223 ['.'], self.checkout_path)['Repository Root']
1224 tarball_parsed = urlparse.urlparse(tarball_url)
1225 tarball_root = '%s://%s' % (tarball_parsed.scheme,
1226 tarball_parsed.netloc)
1227 local_parsed = urlparse.urlparse(url)
1228 local_root = '%s://%s' % (local_parsed.scheme, local_parsed.netloc)
1229
1230 if tarball_root != local_root:
1231 print 'Switching repository root to %s' % local_root
1232 self._Run(['switch', '--relocate', tarball_root,
1233 local_root, self.checkout_path],
1234 options)
1235 except Exception as e:
1236 print 'We tried to get a source tarball but failed.'
1237 print 'Resuming normal operations.'
1238 print str(e)
1239
1174 gclient_utils.safe_makedirs(os.path.dirname(self.checkout_path)) 1240 gclient_utils.safe_makedirs(os.path.dirname(self.checkout_path))
1175 # We need to checkout. 1241 # We need to checkout.
1176 command = ['checkout', url, self.checkout_path] 1242 command = ['checkout', url, self.checkout_path]
1177 command = self._AddAdditionalUpdateFlags(command, options, revision) 1243 command = self._AddAdditionalUpdateFlags(command, options, revision)
1178 self._RunAndGetFileList(command, options, file_list, self._root_dir) 1244 self._RunAndGetFileList(command, options, file_list, self._root_dir)
1179 return self.Svnversion() 1245 return self.Svnversion()
1180 1246
1181 if not managed: 1247 if not managed:
1182 print ('________ unmanaged solution; skipping %s' % self.relpath) 1248 print ('________ unmanaged solution; skipping %s' % self.relpath)
1183 return self.Svnversion() 1249 return self.Svnversion()
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 new_command.append('--force') 1518 new_command.append('--force')
1453 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1519 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1454 new_command.extend(('--accept', 'theirs-conflict')) 1520 new_command.extend(('--accept', 'theirs-conflict'))
1455 elif options.manually_grab_svn_rev: 1521 elif options.manually_grab_svn_rev:
1456 new_command.append('--force') 1522 new_command.append('--force')
1457 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1523 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1458 new_command.extend(('--accept', 'postpone')) 1524 new_command.extend(('--accept', 'postpone'))
1459 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1525 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1460 new_command.extend(('--accept', 'postpone')) 1526 new_command.extend(('--accept', 'postpone'))
1461 return new_command 1527 return new_command
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698