Chromium Code Reviews| Index: gclient_scm.py |
| diff --git a/gclient_scm.py b/gclient_scm.py |
| index 913d9a57e6746eba82bda263d430a11163696e08..f093108a3e0d0e50638ea88af8cff9a73659ddba 100644 |
| --- a/gclient_scm.py |
| +++ b/gclient_scm.py |
| @@ -140,23 +140,40 @@ class SCMWrapper(object): |
| return getattr(self, command)(options, args, file_list) |
| - def GetActualRemoteURL(self): |
| + def GetActualRemoteURL(self, options): |
| """Attempt to determine the remote URL for this SCMWrapper.""" |
| + # Git |
| if os.path.exists(os.path.join(self.checkout_path, '.git')): |
| - return shlex.split(scm.GIT.Capture( |
| + actual_remote_url = shlex.split(scm.GIT.Capture( |
| ['config', '--local', '--get-regexp', r'remote.*.url'], |
| self.checkout_path))[1] |
| + |
| + # If a cache_dir is used, obtain the actual remote URL from the cache. |
| + if hasattr(self, 'cache_dir') and self.cache_dir: |
|
iannucci
2014/04/08 17:29:36
if getattr(self, 'cache_dir', None):
borenet
2014/04/08 18:42:13
Done.
|
| + try: |
| + full_cache_dir = self._Run(['cache', 'exists', '--cache-dir', |
|
iannucci
2014/04/08 17:29:36
Note that there seems to be flakiness when invokin
|
| + self.cache_dir, self.url], |
| + options, cwd=self._root_dir).strip() |
| + except subprocess2.CalledProcessError: |
| + full_cache_dir = None |
| + if full_cache_dir == actual_remote_url: |
|
iannucci
2014/04/08 17:29:36
I'm not sure if this will work well on windows.
borenet
2014/04/08 19:23:42
Used .replace('\\', '/')
|
| + actual_remote_url = shlex.split(scm.GIT.Capture( |
| + ['config', '--local', '--get-regexp', r'remote.*.url'], |
| + os.path.join(self._root_dir, full_cache_dir)))[1] |
| + return actual_remote_url |
| + |
| + # Svn |
| if os.path.exists(os.path.join(self.checkout_path, '.svn')): |
| return scm.SVN.CaptureLocalInfo([], self.checkout_path)['URL'] |
| return None |
| - def DoesRemoteURLMatch(self): |
| + def DoesRemoteURLMatch(self, options): |
| """Determine whether the remote URL of this checkout is the expected URL.""" |
| if not os.path.exists(self.checkout_path): |
| # A checkout which doesn't exist can't be broken. |
| return True |
| - actual_remote_url = self.GetActualRemoteURL() |
| + actual_remote_url = self.GetActualRemoteURL(options) |
| if actual_remote_url: |
| return (gclient_utils.SplitUrlRevision(actual_remote_url)[0].rstrip('/') |
| == gclient_utils.SplitUrlRevision(self.url)[0].rstrip('/')) |