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.""" | |
|
borenet
2014/03/13 13:53:35
I just copied the new code here, because GitWrappe
iannucci
2014/03/13 18:27:27
yeah, that seems reasonable to me.
| |
| 145 try: | |
| 146 return shlex.split(scm.GIT.Capture( | |
| 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 return self.GetActualRemoteURL().rstrip('/') == self.url.rstrip('/') | |
| 160 | |
| 142 | 161 |
| 143 class GitWrapper(SCMWrapper): | 162 class GitWrapper(SCMWrapper): |
| 144 """Wrapper for Git""" | 163 """Wrapper for Git""" |
| 145 name = 'git' | 164 name = 'git' |
| 146 remote = 'origin' | 165 remote = 'origin' |
| 147 | 166 |
| 148 cache_dir = None | 167 cache_dir = None |
| 149 | 168 |
| 150 def __init__(self, url=None, root_dir=None, relpath=None): | 169 def __init__(self, url=None, root_dir=None, relpath=None): |
| 151 """Removes 'git+' fake prefix from git URL.""" | 170 """Removes 'git+' fake prefix from git URL.""" |
| (...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1401 new_command.append('--force') | 1420 new_command.append('--force') |
| 1402 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1421 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1403 new_command.extend(('--accept', 'theirs-conflict')) | 1422 new_command.extend(('--accept', 'theirs-conflict')) |
| 1404 elif options.manually_grab_svn_rev: | 1423 elif options.manually_grab_svn_rev: |
| 1405 new_command.append('--force') | 1424 new_command.append('--force') |
| 1406 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1425 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1407 new_command.extend(('--accept', 'postpone')) | 1426 new_command.extend(('--accept', 'postpone')) |
| 1408 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1427 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1409 new_command.extend(('--accept', 'postpone')) | 1428 new_command.extend(('--accept', 'postpone')) |
| 1410 return new_command | 1429 return new_command |
| OLD | NEW |