Chromium Code Reviews| Index: gclient_scm.py |
| =================================================================== |
| --- gclient_scm.py (revision 108803) |
| +++ 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 FindSafesyncRev(cwd, rev, options): |
|
M-A Ruel
2011/11/08 14:29:20
Note that this function has nothing to do with 'sa
Dan Beam
2011/11/09 10:31:15
Done.
|
| + """Find a useful safesync revision for this repository. If SCM is git-svn |
|
M-A Ruel
2011/11/08 14:29:20
Finds
Dan Beam
2011/11/09 10:31:15
Done.
|
| + and the head revision is less than |rev|, git svn fetch will be |
|
M-A Ruel
2011/11/08 14:29:20
style nit: In general we strive for the docstring
Dan Beam
2011/11/09 10:31:15
Done.
|
| + called on the source.""" |
| + sha1 = None |
| + # As an optimization, only verify an SVN revision as [0-9]{1,6} for now so |
| + # we avoiding 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.VerifyRevisionFormat(cwd=cwd, rev=rev) |
| + if not sha1: |
| + # If we didn't find anything, show a warning. |
|
M-A Ruel
2011/11/08 14:29:20
Are you sure a warning is a good idea? It'll get l
Dan Beam
2011/11/09 10:31:15
Done.
|
| + help_url = ''.join(['http://code.google.com/p/chromium/wiki/UsingNewGit', |
| + '#Initial_checkout']) |
| + print('WARNING: Safesync URLs with a git checkout currently require a\n' |
| + ' git-svn remote or a safesync_url that provides git\n' |
| + ' sha1s. Please add a git-svn remote or change your\n' |
| + ' safesync_url.\n' |
| + ' %s\n' % help_url) |
| + return sha1 |
| + |
| def FullUrlForRelativeUrl(self, url): |
| # Strip from last '/' |
| # Equivalent to unix basename |
| @@ -991,6 +1020,17 @@ |
| else: |
| self._RunAndGetFileList(command, options, file_list) |
| + @staticmethod |
| + def FindSafesyncRev(cwd, rev, options): |
| + """Find a useful safesync revision for this repository.""" |
|
M-A Ruel
2011/11/08 14:29:20
Finds
Dan Beam
2011/11/09 10:31:15
Done.
|
| + if scm.SVN.VerifyRevisionFormat(cwd=cwd, rev=rev): |
| + return rev |
| + # Invalid revision format. |
| + print('WARNING: The content of safesync_url didn\'t look like a valid\n' |
|
M-A Ruel
2011/11/08 14:29:20
Same as line 498. Either always return rev silentl
Dan Beam
2011/11/09 10:31:15
Done.
|
| + ' Subversion revision. Please check your safesync_url is\n' |
| + ' correct. Ignoring for now.\n') |
| + return None |
| + |
| def FullUrlForRelativeUrl(self, url): |
| # Find the forth '/' and strip from there. A bit hackish. |
| return '/'.join(self.url.split('/')[:4]) + url |