Chromium Code Reviews| Index: gclient_scm.py |
| diff --git a/gclient_scm.py b/gclient_scm.py |
| index e8ab1409a9dcb23b1a160311b308fbfd0a3d974c..76b4d8dd22bd5c360b2a603a8f91a655ab296182 100644 |
| --- a/gclient_scm.py |
| +++ b/gclient_scm.py |
| @@ -8,6 +8,7 @@ import logging |
| import os |
| import posixpath |
| import re |
| +import shlex |
| import sys |
| import tempfile |
| import traceback |
| @@ -139,6 +140,34 @@ class SCMWrapper(object): |
| return getattr(self, command)(options, args, file_list) |
| + def GetActualRemoteURL(self): |
| + """Attempt to determine the remote URL for this SCMWrapper.""" |
| + try: |
| + return shlex.split(scm.GIT.Capture( |
|
ahe
2014/03/24 15:07:37
I have a layout where a Subversion directory is ne
|
| + ['config', '--local', '--get-regexp', r'remote.*.url'], |
| + self.checkout_path))[1] |
| + except Exception: |
| + pass |
| + try: |
| + return scm.SVN.CaptureLocalInfo([], self.checkout_path)['URL'] |
| + except Exception: |
| + pass |
| + return None |
| + |
| + def DoesRemoteURLMatch(self): |
| + """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() |
| + if actual_remote_url: |
| + return actual_remote_url.rstrip('/') == self.url.rstrip('/') |
| + else: |
| + # This may occur if the self.checkout_path exists but does not contain a |
| + # valid git or svn checkout. |
| + return False |
| + |
| class GitWrapper(SCMWrapper): |
| """Wrapper for Git""" |