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

Side by Side Diff: gclient_scm.py

Issue 136863007: Gate tarball downloading based on SVN url (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: 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
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 exists = False 1173 exists = False
1174 else: 1174 else:
1175 msg = ('Can\'t update/checkout %s if an unversioned directory is ' 1175 msg = ('Can\'t update/checkout %s if an unversioned directory is '
1176 'present. Delete the directory and try again.') 1176 'present. Delete the directory and try again.')
1177 raise gclient_utils.Error(msg % self.checkout_path) 1177 raise gclient_utils.Error(msg % self.checkout_path)
1178 1178
1179 BASE_URLS = { 1179 BASE_URLS = {
1180 '/chrome/trunk/src': 'gs://chromium-svn-checkout/chrome/', 1180 '/chrome/trunk/src': 'gs://chromium-svn-checkout/chrome/',
1181 '/blink/trunk': 'gs://chromium-svn-checkout/blink/', 1181 '/blink/trunk': 'gs://chromium-svn-checkout/blink/',
1182 } 1182 }
1183 WHITELISTED_ROOTS = [
1184 'svn://svn.chromium.org',
1185 'svn://svn-mirror.golo.chromium.org',
1186 ]
1183 if not exists: 1187 if not exists:
1184 try: 1188 try:
1185 # Split out the revision number since it's not useful for us. 1189 # Split out the revision number since it's not useful for us.
1186 base_path = urlparse.urlparse(url).path.split('@')[0] 1190 base_path = urlparse.urlparse(url).path.split('@')[0]
1191 # Check to see if we're on a whitelisted root. We do this because
1192 # only some svn servers have matching UUIDs.
1193 local_parsed = urlparse.urlparse(url)
1194 local_root = '%s://%s' % (local_parsed.scheme, local_parsed.netloc)
1187 if ('CHROME_HEADLESS' in os.environ 1195 if ('CHROME_HEADLESS' in os.environ
1188 and sys.platform == 'linux2' # TODO(hinoka): Enable for win/mac. 1196 and sys.platform == 'linux2' # TODO(hinoka): Enable for win/mac.
1189 and base_path in BASE_URLS): 1197 and base_path in BASE_URLS
1198 and local_root in WHITELISTED_ROOTS):
1199
1190 # Use a tarball for initial sync if we are on a bot. 1200 # Use a tarball for initial sync if we are on a bot.
1191 # Get an unauthenticated gsutil instance. 1201 # Get an unauthenticated gsutil instance.
1192 gsutil = download_from_google_storage.Gsutil( 1202 gsutil = download_from_google_storage.Gsutil(
1193 GSUTIL_DEFAULT_PATH, boto_path=os.devnull) 1203 GSUTIL_DEFAULT_PATH, boto_path=os.devnull)
1194 1204
1195 gs_path = BASE_URLS[base_path] 1205 gs_path = BASE_URLS[base_path]
1196 _, out, _ = gsutil.check_call('ls', gs_path) 1206 _, out, _ = gsutil.check_call('ls', gs_path)
1197 # So that we can get the most recent revision. 1207 # So that we can get the most recent revision.
1198 sorted_items = sorted(out.splitlines()) 1208 sorted_items = sorted(out.splitlines())
1199 latest_checkout = sorted_items[-1] 1209 latest_checkout = sorted_items[-1]
(...skipping 17 matching lines...) Expand all
1217 1227
1218 print 'Deleting temp file' 1228 print 'Deleting temp file'
1219 gclient_utils.rmtree(tempdir) 1229 gclient_utils.rmtree(tempdir)
1220 1230
1221 # Rewrite the repository root to match. 1231 # Rewrite the repository root to match.
1222 tarball_url = scm.SVN.CaptureLocalInfo( 1232 tarball_url = scm.SVN.CaptureLocalInfo(
1223 ['.'], self.checkout_path)['Repository Root'] 1233 ['.'], self.checkout_path)['Repository Root']
1224 tarball_parsed = urlparse.urlparse(tarball_url) 1234 tarball_parsed = urlparse.urlparse(tarball_url)
1225 tarball_root = '%s://%s' % (tarball_parsed.scheme, 1235 tarball_root = '%s://%s' % (tarball_parsed.scheme,
1226 tarball_parsed.netloc) 1236 tarball_parsed.netloc)
1227 local_parsed = urlparse.urlparse(url)
1228 local_root = '%s://%s' % (local_parsed.scheme, local_parsed.netloc)
1229 1237
1230 if tarball_root != local_root: 1238 if tarball_root != local_root:
1231 print 'Switching repository root to %s' % local_root 1239 print 'Switching repository root to %s' % local_root
1232 self._Run(['switch', '--relocate', tarball_root, 1240 self._Run(['switch', '--relocate', tarball_root,
1233 local_root, self.checkout_path], 1241 local_root, self.checkout_path],
1234 options) 1242 options)
1235 except Exception as e: 1243 except Exception as e:
1236 print 'We tried to get a source tarball but failed.' 1244 print 'We tried to get a source tarball but failed.'
1237 print 'Resuming normal operations.' 1245 print 'Resuming normal operations.'
1238 print str(e) 1246 print str(e)
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 new_command.append('--force') 1526 new_command.append('--force')
1519 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1527 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1520 new_command.extend(('--accept', 'theirs-conflict')) 1528 new_command.extend(('--accept', 'theirs-conflict'))
1521 elif options.manually_grab_svn_rev: 1529 elif options.manually_grab_svn_rev:
1522 new_command.append('--force') 1530 new_command.append('--force')
1523 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1531 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1524 new_command.extend(('--accept', 'postpone')) 1532 new_command.extend(('--accept', 'postpone'))
1525 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1533 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1526 new_command.extend(('--accept', 'postpone')) 1534 new_command.extend(('--accept', 'postpone'))
1527 return new_command 1535 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