| 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 errno |
| 10 import logging | 10 import logging |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 return getattr(self, command)(options, args, file_list) | 166 return getattr(self, command)(options, args, file_list) |
| 167 | 167 |
| 168 @staticmethod | 168 @staticmethod |
| 169 def _get_first_remote_url(checkout_path): | 169 def _get_first_remote_url(checkout_path): |
| 170 log = scm.GIT.Capture( | 170 log = scm.GIT.Capture( |
| 171 ['config', '--local', '--get-regexp', r'remote.*.url'], | 171 ['config', '--local', '--get-regexp', r'remote.*.url'], |
| 172 cwd=checkout_path) | 172 cwd=checkout_path) |
| 173 # Get the second token of the first line of the log. | 173 # Get the second token of the first line of the log. |
| 174 return log.splitlines()[0].split(' ', 1)[1] | 174 return log.splitlines()[0].split(' ', 1)[1] |
| 175 | 175 |
| 176 def GetCacheMirror(self): |
| 177 if (getattr(self, 'cache_dir', None)): |
| 178 url, _ = gclient_utils.SplitUrlRevision(self.url) |
| 179 return git_cache.Mirror(url) |
| 180 return None |
| 181 |
| 176 def GetActualRemoteURL(self, options): | 182 def GetActualRemoteURL(self, options): |
| 177 """Attempt to determine the remote URL for this SCMWrapper.""" | 183 """Attempt to determine the remote URL for this SCMWrapper.""" |
| 178 # Git | 184 # Git |
| 179 if os.path.exists(os.path.join(self.checkout_path, '.git')): | 185 if os.path.exists(os.path.join(self.checkout_path, '.git')): |
| 180 actual_remote_url = self._get_first_remote_url(self.checkout_path) | 186 actual_remote_url = self._get_first_remote_url(self.checkout_path) |
| 181 | 187 |
| 182 # If a cache_dir is used, obtain the actual remote URL from the cache. | 188 mirror = self.GetCacheMirror() |
| 183 if getattr(self, 'cache_dir', None): | 189 # If the cache is used, obtain the actual remote URL from there. |
| 184 url, _ = gclient_utils.SplitUrlRevision(self.url) | 190 if (mirror and mirror.exists() and |
| 185 mirror = git_cache.Mirror(url) | 191 mirror.mirror_path.replace('\\', '/') == |
| 186 if (mirror.exists() and mirror.mirror_path.replace('\\', '/') == | 192 actual_remote_url.replace('\\', '/')): |
| 187 actual_remote_url.replace('\\', '/')): | 193 actual_remote_url = self._get_first_remote_url(mirror.mirror_path) |
| 188 actual_remote_url = self._get_first_remote_url(mirror.mirror_path) | |
| 189 return actual_remote_url | 194 return actual_remote_url |
| 190 | 195 |
| 191 # Svn | 196 # Svn |
| 192 if os.path.exists(os.path.join(self.checkout_path, '.svn')): | 197 if os.path.exists(os.path.join(self.checkout_path, '.svn')): |
| 193 return scm.SVN.CaptureLocalInfo([], self.checkout_path)['URL'] | 198 return scm.SVN.CaptureLocalInfo([], self.checkout_path)['URL'] |
| 194 return None | 199 return None |
| 195 | 200 |
| 196 def DoesRemoteURLMatch(self, options): | 201 def DoesRemoteURLMatch(self, options): |
| 197 """Determine whether the remote URL of this checkout is the expected URL.""" | 202 """Determine whether the remote URL of this checkout is the expected URL.""" |
| 198 if not os.path.exists(self.checkout_path): | 203 if not os.path.exists(self.checkout_path): |
| (...skipping 1514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1713 new_command.append('--force') | 1718 new_command.append('--force') |
| 1714 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1719 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1715 new_command.extend(('--accept', 'theirs-conflict')) | 1720 new_command.extend(('--accept', 'theirs-conflict')) |
| 1716 elif options.manually_grab_svn_rev: | 1721 elif options.manually_grab_svn_rev: |
| 1717 new_command.append('--force') | 1722 new_command.append('--force') |
| 1718 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1723 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1719 new_command.extend(('--accept', 'postpone')) | 1724 new_command.extend(('--accept', 'postpone')) |
| 1720 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1725 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
| 1721 new_command.extend(('--accept', 'postpone')) | 1726 new_command.extend(('--accept', 'postpone')) |
| 1722 return new_command | 1727 return new_command |
| OLD | NEW |