Index: gclient_scm.py |
diff --git a/gclient_scm.py b/gclient_scm.py |
index 55aa1cca190287dd679c8ff85200c0a80e28004e..0b21dce99a5717e3ebdd3ce2474a220a9215564f 100644 |
--- a/gclient_scm.py |
+++ b/gclient_scm.py |
@@ -483,6 +483,34 @@ class GitWrapper(SCMWrapper): |
files = self._Capture(['diff', '--name-only', merge_base]).split() |
file_list.extend([os.path.join(self.checkout_path, f) for f in files]) |
+ def GetUsableRev(self, rev, options): |
+ """Finds a useful revision for this repository. |
+ |
+ If SCM is git-svn and the head revision is less than |rev|, git svn fetch |
+ will be called on the source.""" |
+ sha1 = None |
+ # As an optimization, only verify an SVN revision as [0-9]{1,6} for now to |
+ # avoid making a network request. |
+ if (scm.GIT.IsGitSvn(cwd=self.checkout_path) and |
+ rev.isdigit() and len(rev) < 7): |
+ local_head = scm.GIT.GetGitSvnHeadRev(cwd=self.checkout_path) |
+ if not local_head or local_head < int(rev): |
+ if options.verbose: |
+ print('Running git svn fetch. This might take a while.\n') |
+ scm.GIT.Capture(['svn', 'fetch'], cwd=self.checkout_path) |
+ sha1 = scm.GIT.GetSha1ForSvnRev(cwd=self.checkout_path, rev=rev) |
+ elif scm.GIT.IsValidRevision(cwd=self.checkout_path, rev=rev): |
+ sha1 = rev |
+ if not sha1: |
+ raise gclient_utils.Error( |
+ ( '%s is not a value hash. Safesync URLs with a git checkout\n' |
+ 'currently require a git-svn remote or a safesync_url that\n' |
+ 'provides git sha1s. Please add a git-svn remote or change\n' |
+ 'your safesync_url. For more info, see:\n' |
+ 'http://code.google.com/p/chromium/wiki/UsingNewGit' |
+ '#Initial_checkout') % rev) |
+ return sha1 |
+ |
def FullUrlForRelativeUrl(self, url): |
# Strip from last '/' |
# Equivalent to unix basename |
@@ -1002,6 +1030,14 @@ class SVNWrapper(SCMWrapper): |
else: |
self._RunAndGetFileList(command, options, file_list) |
+ def GetUsableRev(self, rev, options): |
+ """Verifies the validity of the revision for this repository.""" |
+ if not scm.SVN.IsValidRevision(url='%s@%s' % (self.url, rev)): |
+ raise gclient_utils.Error( |
+ ( '%s isn\'t a valid revision. Please check that your safesync_url is\n' |
+ 'correct.') % rev) |
+ return rev |
+ |
def FullUrlForRelativeUrl(self, url): |
# Find the forth '/' and strip from there. A bit hackish. |
return '/'.join(self.url.split('/')[:4]) + url |