Chromium Code Reviews| Index: gclient_scm.py |
| =================================================================== |
| --- gclient_scm.py (revision 109214) |
| +++ gclient_scm.py (working copy) |
| @@ -476,6 +476,35 @@ |
| files = self._Capture(['diff', '--name-only', merge_base]).split() |
| file_list.extend([os.path.join(self.checkout_path, f) for f in files]) |
| + @staticmethod |
| + def GetUsableRev(cwd, url, 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=cwd) and |
| + rev.isdigit() and len(rev) < 7): |
| + local_head = scm.GIT.GetGitSvnHeadRev(cwd=cwd) |
| + 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=cwd) |
| + sha1 = scm.GIT.GetSha1ForSvnRev(cwd=cwd, rev=rev) |
| + else: |
| + sha1 = scm.GIT.IsValidRevision(cwd=cwd, url=url, rev=rev) |
| + if sha1: |
| + return sha1 |
| + else: |
| + help_url = ''.join(['http://code.google.com/p/chromium/wiki/UsingNewGit', |
|
M-A Ruel
2011/11/09 14:16:08
Replace lines 498-506 with:
if not sha1:
Dan Beam
2011/11/10 10:29:15
Done.
|
| + '#Initial_checkout']) |
| + raise gclient_utils.Error( |
| + 'Safesync URLs with a git checkout currently require a git-svn ' |
| + 'remote or a safesync_url that provides git sha1s. Please add a ' |
| + 'git-svn remote or change your safesync_url. %s' % help_url) |
| + |
| def FullUrlForRelativeUrl(self, url): |
| # Strip from last '/' |
| # Equivalent to unix basename |
| @@ -991,6 +1020,15 @@ |
| else: |
| self._RunAndGetFileList(command, options, file_list) |
| + @staticmethod |
| + def GetUsableRev(cwd, url, rev, options): |
| + """Finds a useful revision for this repository.""" |
|
M-A Ruel
2011/11/09 14:16:08
Verifies the validity of the revision for this rep
Dan Beam
2011/11/10 10:29:15
Done.
|
| + if scm.SVN.IsValidRevision(cwd=cwd, url=url, rev=rev): |
|
M-A Ruel
2011/11/09 14:16:08
I think you should do the url@revision formatting
Dan Beam
2011/11/09 19:21:59
I guess I could, but the git version doesn't use t
Dan Beam
2011/11/10 10:29:15
Done.
|
| + return rev |
| + raise gclient_utils.Error( |
| + 'The content of safesync_url doesn\'t look like a valid Subversion ' |
|
M-A Ruel
2011/11/09 14:16:08
Prepend '%s isn't a valid revision'
Dan Beam
2011/11/10 10:29:15
Done.
|
| + 'revision. Please check that your safesync_url is correct.') |
| + |
| def FullUrlForRelativeUrl(self, url): |
| # Find the forth '/' and strip from there. A bit hackish. |
| return '/'.join(self.url.split('/')[:4]) + url |