OLD | NEW |
---|---|
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 Loading... | |
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': { | |
1181 'gs_path': 'gs://chromium-svn-checkout/chrome/' | |
cmp
2014/01/07 02:10:14
indent mismatch (+2 on line 1180, +4 on line 1181)
hinoka
2014/01/07 02:17:10
Done.
| |
1182 }, | |
1183 '/blink/trunk' : { | |
cmp
2014/01/07 02:10:14
remove space before :
hinoka
2014/01/07 02:17:10
Done.
| |
1184 'gs_path': 'gs://chromium-svn-checkout/blink/' | |
1185 } | |
1186 } | |
1173 if not exists: | 1187 if not exists: |
1188 try: | |
1189 # Split out the revision number since it's not useful for us. | |
1190 base_path = urlparse.urlparse(url).path.split('@')[0] | |
1191 if ('CHROME_HEADLESS' in os.environ | |
1192 and sys.platform == 'linux2' # TODO(hinoka): Enable for win/mac. | |
1193 and base_path in BASE_URLS): | |
1194 # Use a tarball for initial sync if we are on a bot. | |
1195 # Get an unauthenticated gsutil instance. | |
1196 gsutil = download_from_google_storage.Gsutil( | |
1197 GSUTIL_DEFAULT_PATH, boto_path=os.devnull) | |
1198 | |
1199 entry = BASE_URLS[base_path] | |
1200 gs_path = entry['gs_path'] | |
1201 _, out, _ = gsutil.check_call('ls', gs_path) | |
1202 # So that we can get the most recent revision. | |
1203 sorted_items = sorted(out.splitlines()) | |
1204 latest_checkout = sorted_items[-1] | |
1205 | |
1206 tempdir = tempfile.mkdtemp() | |
1207 print 'Downloading %s...' % latest_checkout | |
1208 code, out, err = gsutil.check_call('cp', latest_checkout, tempdir) | |
1209 if code: | |
1210 print '%s\n%s' % (out, err) | |
1211 raise Exception() | |
1212 filename = latest_checkout.split('/')[-1] | |
1213 tarball = os.path.join(tempdir, filename) | |
1214 print 'Unpacking into %s...' % self.checkout_path | |
1215 if sys.platform == 'linux2': | |
cmp
2014/01/07 02:06:25
This code exists in a branch that already tested s
hinoka
2014/01/07 02:17:10
Done.
| |
1216 gclient_utils.safe_makedirs(self.checkout_path) | |
1217 cmd = ['tar', '--extract', '--ungzip', | |
1218 '--directory', self.checkout_path, | |
1219 '--file', tarball] | |
1220 gclient_utils.CheckCallAndFilter( | |
1221 cmd, stdout=sys.stdout, print_stdout=True) | |
1222 else: | |
1223 # TODO(hinoka): Implement for mac and windows. | |
1224 raise NotImplementedError | |
1225 print 'Deleting temp file' | |
1226 gclient_utils.rmtree(tempdir) | |
1227 | |
1228 # Rewrite the repository root to match. | |
1229 tarball_url = scm.SVN.CaptureLocalInfo( | |
1230 ['.'], self.checkout_path)['Repository Root'] | |
1231 tarball_parsed = urlparse.urlparse(tarball_url) | |
1232 tarball_root = '%s://%s' % (tarball_parsed.scheme, | |
1233 tarball_parsed.netloc) | |
1234 local_parsed = urlparse.urlparse(url) | |
1235 local_root = '%s://%s' % (local_parsed.scheme, local_parsed.netloc) | |
1236 | |
1237 if tarball_root != local_root: | |
1238 print 'Switching repository root to %s' % local_root | |
1239 self._Run(['switch', '--relocate', tarball_root, | |
1240 local_root, self.checkout_path], | |
1241 options) | |
1242 except Exception as e: | |
1243 print 'We tried to get a source tarball but failed.' | |
1244 print 'Resuming normal operations.' | |
1245 print str(e) | |
1246 | |
1174 gclient_utils.safe_makedirs(os.path.dirname(self.checkout_path)) | 1247 gclient_utils.safe_makedirs(os.path.dirname(self.checkout_path)) |
1175 # We need to checkout. | 1248 # We need to checkout. |
1176 command = ['checkout', url, self.checkout_path] | 1249 command = ['checkout', url, self.checkout_path] |
1177 command = self._AddAdditionalUpdateFlags(command, options, revision) | 1250 command = self._AddAdditionalUpdateFlags(command, options, revision) |
1178 self._RunAndGetFileList(command, options, file_list, self._root_dir) | 1251 self._RunAndGetFileList(command, options, file_list, self._root_dir) |
1179 return self.Svnversion() | 1252 return self.Svnversion() |
1180 | 1253 |
1181 if not managed: | 1254 if not managed: |
1182 print ('________ unmanaged solution; skipping %s' % self.relpath) | 1255 print ('________ unmanaged solution; skipping %s' % self.relpath) |
1183 return self.Svnversion() | 1256 return self.Svnversion() |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1452 new_command.append('--force') | 1525 new_command.append('--force') |
1453 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1526 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1454 new_command.extend(('--accept', 'theirs-conflict')) | 1527 new_command.extend(('--accept', 'theirs-conflict')) |
1455 elif options.manually_grab_svn_rev: | 1528 elif options.manually_grab_svn_rev: |
1456 new_command.append('--force') | 1529 new_command.append('--force') |
1457 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1530 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1458 new_command.extend(('--accept', 'postpone')) | 1531 new_command.extend(('--accept', 'postpone')) |
1459 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1532 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1460 new_command.extend(('--accept', 'postpone')) | 1533 new_command.extend(('--accept', 'postpone')) |
1461 return new_command | 1534 return new_command |
OLD | NEW |