Chromium Code Reviews| 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 logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import posixpath | 9 import posixpath |
| 10 import re | 10 import re |
| 11 import shlex | |
| 11 import sys | 12 import sys |
| 12 import tempfile | 13 import tempfile |
| 13 import traceback | 14 import traceback |
| 14 import urlparse | 15 import urlparse |
| 15 | 16 |
| 16 import download_from_google_storage | 17 import download_from_google_storage |
| 17 import gclient_utils | 18 import gclient_utils |
| 18 import scm | 19 import scm |
| 19 import subprocess2 | 20 import subprocess2 |
| 20 | 21 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 | 133 |
| 133 if not command in commands: | 134 if not command in commands: |
| 134 raise gclient_utils.Error('Unknown command %s' % command) | 135 raise gclient_utils.Error('Unknown command %s' % command) |
| 135 | 136 |
| 136 if not command in dir(self): | 137 if not command in dir(self): |
| 137 raise gclient_utils.Error('Command %s not implemented in %s wrapper' % ( | 138 raise gclient_utils.Error('Command %s not implemented in %s wrapper' % ( |
| 138 command, self.__class__.__name__)) | 139 command, self.__class__.__name__)) |
| 139 | 140 |
| 140 return getattr(self, command)(options, args, file_list) | 141 return getattr(self, command)(options, args, file_list) |
| 141 | 142 |
| 143 def GetActualRemoteURL(self): | |
| 144 """Attempt to determine the remote URL for this SCMWrapper.""" | |
| 145 try: | |
| 146 return shlex.split(scm.GIT.Capture( | |
|
ahe
2014/03/24 15:07:37
I have a layout where a Subversion directory is ne
| |
| 147 ['config', '--local', '--get-regexp', r'remote.*.url'], | |
| 148 self.checkout_path))[1] | |
| 149 except Exception: | |
| 150 pass | |
| 151 try: | |
| 152 return scm.SVN.CaptureLocalInfo([], self.checkout_path)['URL'] | |
| 153 except Exception: | |
| 154 pass | |
| 155 return None | |
| 156 | |
| 157 def DoesRemoteURLMatch(self): | |
| 158 """Determine whether the remote URL of this checkout is the expected URL.""" | |
| 159 if not os.path.exists(self.checkout_path): | |
| 160 # A checkout which doesn't exist can't be broken. | |
| 161 return True | |
| 162 | |
| 163 actual_remote_url = self.GetActualRemoteURL() | |
| 164 if actual_remote_url: | |
| 165 return actual_remote_url.rstrip('/') == self.url.rstrip('/') | |
| 166 else: | |
| 167 # This may occur if the self.checkout_path exists but does not contain a | |
| 168 # valid git or svn checkout. | |
| 169 return False | |
| 170 | |
| 142 | 171 |
| 143 class GitWrapper(SCMWrapper): | 172 class GitWrapper(SCMWrapper): |
| 144 """Wrapper for Git""" | 173 """Wrapper for Git""" |
| 145 name = 'git' | 174 name = 'git' |
| 146 remote = 'origin' | 175 remote = 'origin' |
| 147 | 176 |
| 148 cache_dir = None | 177 cache_dir = None |
| 149 | 178 |
| 150 def __init__(self, url=None, root_dir=None, relpath=None): | 179 def __init__(self, url=None, root_dir=None, relpath=None): |
| 151 """Removes 'git+' fake prefix from git URL.""" | 180 """Removes 'git+' fake prefix from git URL.""" |
| (...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1402 new_command.append('--force') | 1431 new_command.append('--force') |
| 1403 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1432 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1404 new_command.extend(('--accept', 'theirs-conflict')) | 1433 new_command.extend(('--accept', 'theirs-conflict')) |
| 1405 elif options.manually_grab_svn_rev: | 1434 elif options.manually_grab_svn_rev: |
| 1406 new_command.append('--force') | 1435 new_command.append('--force') |
| 1407 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1436 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1408 new_command.extend(('--accept', 'postpone')) | 1437 new_command.extend(('--accept', 'postpone')) |
| 1409 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1438 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1410 new_command.extend(('--accept', 'postpone')) | 1439 new_command.extend(('--accept', 'postpone')) |
| 1411 return new_command | 1440 return new_command |
| OLD | NEW |