Chromium Code Reviews| Index: scm.py |
| =================================================================== |
| --- scm.py (revision 107937) |
| +++ scm.py (working copy) |
| @@ -379,6 +379,27 @@ |
| root = GIT.Capture(['rev-parse', '--show-cdup'], cwd=cwd).strip() |
| return os.path.abspath(os.path.join(cwd, root)) |
| + @staticmethod |
| + def GetSha1ForSvnRev(cwd, rev): |
| + """Returns a git sha1 for a corresponding Subversion revision from a git-svn |
| + remote. If that Subversion revision isn't found, an empty string is |
| + returned.""" |
| + # This probably won't work if not git-svn. There's a warning in |
| + # gclient_scm.py that gives a user an error message and a URL to how to set |
| + # up a git-svn remote, so we'll probably never get here but it doesn't hurt. |
| + if not GIT.IsGitSvn(cwd=cwd): |
| + return '' |
|
M-A Ruel
2011/10/31 13:46:51
return None in case of failure.
Dan Beam
2011/11/06 07:34:08
Done.
|
| + try: |
| + GIT.Capture(['svn', 'rebase', '--local'], cwd=cwd) |
|
M-A Ruel
2011/10/31 13:46:51
rebase (!) You need to use svn fetch instead, then
Dan Beam
2011/10/31 18:32:28
Yeah, I guess this isn't a good idea, but it's the
M-A Ruel
2011/10/31 19:17:50
Ah I see. I just dislike that a function like that
Dan Beam
2011/11/06 07:34:08
Done.
|
| + # Currently works by just grabbing last line of output from git svn |
| + # find-rev after rebuilding the index. This seems to currently always be |
| + # what we want (either a sha1 or empty) even if there is error output. |
| + lines = GIT.Capture( |
| + ['svn', 'find-rev', 'r' + rev], cwd=cwd).splitlines(True) |
| + return lines[-1].strip() if len(lines) else '' |
| + except subprocess2.CalledProcessError: |
| + return '' |
| + |
| @classmethod |
| def AssertVersion(cls, min_version): |
| """Asserts git's version is at least min_version.""" |