| 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 from __future__ import print_function | 7 from __future__ import print_function |
| 8 | 8 |
| 9 import errno |
| 9 import logging | 10 import logging |
| 10 import os | 11 import os |
| 11 import posixpath | 12 import posixpath |
| 12 import re | 13 import re |
| 13 import shlex | 14 import shlex |
| 14 import sys | 15 import sys |
| 15 import tempfile | 16 import tempfile |
| 16 import traceback | 17 import traceback |
| 17 import urlparse | 18 import urlparse |
| 18 | 19 |
| 19 import download_from_google_storage | 20 import download_from_google_storage |
| 20 import gclient_utils | 21 import gclient_utils |
| 21 import git_cache | 22 import git_cache |
| 22 import scm | 23 import scm |
| 24 import shutil |
| 23 import subprocess2 | 25 import subprocess2 |
| 24 | 26 |
| 25 | 27 |
| 26 THIS_FILE_PATH = os.path.abspath(__file__) | 28 THIS_FILE_PATH = os.path.abspath(__file__) |
| 27 | 29 |
| 28 GSUTIL_DEFAULT_PATH = os.path.join( | 30 GSUTIL_DEFAULT_PATH = os.path.join( |
| 29 os.path.dirname(os.path.abspath(__file__)), | 31 os.path.dirname(os.path.abspath(__file__)), |
| 30 'third_party', 'gsutil', 'gsutil') | 32 'third_party', 'gsutil', 'gsutil') |
| 31 | 33 |
| 32 CHROMIUM_SRC_URL = 'https://chromium.googlesource.com/chromium/src.git' | 34 CHROMIUM_SRC_URL = 'https://chromium.googlesource.com/chromium/src.git' |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 191 |
| 190 actual_remote_url = self.GetActualRemoteURL(options) | 192 actual_remote_url = self.GetActualRemoteURL(options) |
| 191 if actual_remote_url: | 193 if actual_remote_url: |
| 192 return (gclient_utils.SplitUrlRevision(actual_remote_url)[0].rstrip('/') | 194 return (gclient_utils.SplitUrlRevision(actual_remote_url)[0].rstrip('/') |
| 193 == gclient_utils.SplitUrlRevision(self.url)[0].rstrip('/')) | 195 == gclient_utils.SplitUrlRevision(self.url)[0].rstrip('/')) |
| 194 else: | 196 else: |
| 195 # This may occur if the self.checkout_path exists but does not contain a | 197 # This may occur if the self.checkout_path exists but does not contain a |
| 196 # valid git or svn checkout. | 198 # valid git or svn checkout. |
| 197 return False | 199 return False |
| 198 | 200 |
| 199 # TODO(borenet): Remove this once SCMWrapper._DeleteOrMove is enabled. | |
| 200 # pylint: disable=R0201 | |
| 201 def _DeleteOrMove(self, force): | 201 def _DeleteOrMove(self, force): |
| 202 """Delete the checkout directory or move it out of the way. | 202 """Delete the checkout directory or move it out of the way. |
| 203 | 203 |
| 204 Args: | 204 Args: |
| 205 force: bool; if True, delete the directory. Otherwise, just move it. | 205 force: bool; if True, delete the directory. Otherwise, just move it. |
| 206 """ | 206 """ |
| 207 gclient_utils.AddWarning('WARNING: Upcoming change in ' | 207 if force and os.environ.get('CHROME_HEADLESS') == '1': |
| 208 'https://codereview.chromium.org/225403015 would ' | 208 self.Print('_____ Conflicting directory found in %s. Removing.' |
| 209 'cause %s to be deleted or moved to the side. ' | 209 % self.checkout_path) |
| 210 'This is intended to ease changes to DEPS in the ' | 210 gclient_utils.AddWarning('Conflicting directory %s deleted.' |
| 211 'future. If you are seeing this warning and ' | 211 % self.checkout_path) |
| 212 'haven\'t changed the DEPS file, please contact ' | 212 gclient_utils.rmtree(self.checkout_path) |
| 213 'borenet@ immediately.' % self.checkout_path) | 213 else: |
| 214 bad_scm_dir = os.path.join(self._root_dir, '_bad_scm', |
| 215 os.path.dirname(self.relpath)) |
| 216 |
| 217 try: |
| 218 os.makedirs(bad_scm_dir) |
| 219 except OSError as e: |
| 220 if e.errno != errno.EEXIST: |
| 221 raise |
| 222 |
| 223 dest_path = tempfile.mkdtemp( |
| 224 prefix=os.path.basename(self.relpath), |
| 225 dir=bad_scm_dir) |
| 226 self.Print('_____ Conflicting directory found in %s. Moving to %s.' |
| 227 % (self.checkout_path, dest_path)) |
| 228 gclient_utils.AddWarning('Conflicting directory %s moved to %s.' |
| 229 % (self.checkout_path, dest_path)) |
| 230 shutil.move(self.checkout_path, dest_path) |
| 214 | 231 |
| 215 | 232 |
| 216 class GitWrapper(SCMWrapper): | 233 class GitWrapper(SCMWrapper): |
| 217 """Wrapper for Git""" | 234 """Wrapper for Git""" |
| 218 name = 'git' | 235 name = 'git' |
| 219 remote = 'origin' | 236 remote = 'origin' |
| 220 | 237 |
| 221 cache_dir = None | 238 cache_dir = None |
| 222 | 239 |
| 223 def __init__(self, url=None, *args): | 240 def __init__(self, url=None, *args): |
| (...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1081 rev_str = '' | 1098 rev_str = '' |
| 1082 | 1099 |
| 1083 exists = os.path.exists(self.checkout_path) | 1100 exists = os.path.exists(self.checkout_path) |
| 1084 if exists and managed: | 1101 if exists and managed: |
| 1085 # Git is only okay if it's a git-svn checkout of the right repo. | 1102 # Git is only okay if it's a git-svn checkout of the right repo. |
| 1086 if scm.GIT.IsGitSvn(self.checkout_path): | 1103 if scm.GIT.IsGitSvn(self.checkout_path): |
| 1087 remote_url = scm.GIT.Capture(['config', '--local', '--get', | 1104 remote_url = scm.GIT.Capture(['config', '--local', '--get', |
| 1088 'svn-remote.svn.url'], | 1105 'svn-remote.svn.url'], |
| 1089 cwd=self.checkout_path).rstrip() | 1106 cwd=self.checkout_path).rstrip() |
| 1090 if remote_url.rstrip('/') == base_url.rstrip('/'): | 1107 if remote_url.rstrip('/') == base_url.rstrip('/'): |
| 1091 print('\n_____ %s looks like a git-svn checkout. Skipping.' | 1108 self.Print('\n_____ %s looks like a git-svn checkout. Skipping.' |
| 1092 % self.relpath) | 1109 % self.relpath) |
| 1093 return # TODO(borenet): Get the svn revision number? | 1110 return # TODO(borenet): Get the svn revision number? |
| 1094 | 1111 |
| 1095 # Get the existing scm url and the revision number of the current checkout. | 1112 # Get the existing scm url and the revision number of the current checkout. |
| 1096 if exists and managed: | 1113 if exists and managed: |
| 1097 try: | 1114 try: |
| 1098 from_info = scm.SVN.CaptureLocalInfo( | 1115 from_info = scm.SVN.CaptureLocalInfo( |
| 1099 [], os.path.join(self.checkout_path, '.')) | 1116 [], os.path.join(self.checkout_path, '.')) |
| 1100 except (gclient_utils.Error, subprocess2.CalledProcessError): | 1117 except (gclient_utils.Error, subprocess2.CalledProcessError): |
| 1101 self._DeleteOrMove(options.force) | 1118 self._DeleteOrMove(options.force) |
| 1102 exists = False | 1119 exists = False |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1454 new_command.append('--force') | 1471 new_command.append('--force') |
| 1455 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1472 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1456 new_command.extend(('--accept', 'theirs-conflict')) | 1473 new_command.extend(('--accept', 'theirs-conflict')) |
| 1457 elif options.manually_grab_svn_rev: | 1474 elif options.manually_grab_svn_rev: |
| 1458 new_command.append('--force') | 1475 new_command.append('--force') |
| 1459 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1476 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1460 new_command.extend(('--accept', 'postpone')) | 1477 new_command.extend(('--accept', 'postpone')) |
| 1461 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1478 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1462 new_command.extend(('--accept', 'postpone')) | 1479 new_command.extend(('--accept', 'postpone')) |
| 1463 return new_command | 1480 return new_command |
| OLD | NEW |