Chromium Code Reviews| Index: scm.py |
| =================================================================== |
| --- scm.py (revision 109214) |
| +++ scm.py (working copy) |
| @@ -379,6 +379,41 @@ |
| root = GIT.Capture(['rev-parse', '--show-cdup'], cwd=cwd).strip() |
| return os.path.abspath(os.path.join(cwd, root)) |
| + @staticmethod |
| + def GetGitSvnHeadRev(cwd): |
| + """Gets the most recently pulled git-svn revision.""" |
| + try: |
| + output = GIT.Capture(['svn', 'info'], cwd=cwd) |
| + match = re.search(r'^Revision: ([0-9]+)$', output, re.MULTILINE) |
| + if match: |
| + print('Match found! ' + match.group(1)) |
|
M-A Ruel
2011/11/09 14:16:08
That was for debugging?
Dan Beam
2011/11/09 19:21:59
Ah, yeah, sorry. Will remove.
Dan Beam
2011/11/10 10:29:15
Done.
|
| + else: |
| + print('Match not found, :(') |
| + return int(match.group(1)) if match else None |
| + except (subprocess2.CalledProcessError, ValueError): |
| + return None |
| + |
| + @staticmethod |
| + def GetSha1ForSvnRev(cwd, rev): |
| + """Returns a corresponding git sha1 for a SVN revision.""" |
| + if not GIT.IsGitSvn(cwd=cwd): |
| + return None |
| + try: |
| + lines = GIT.Capture( |
| + ['svn', 'find-rev', 'r' + str(rev)], cwd=cwd).splitlines() |
| + return lines[-1].strip() if len(lines) else None |
|
M-A Ruel
2011/11/09 14:16:08
if lines
len() is unnecessary here.
Dan Beam
2011/11/10 10:29:15
Done.
|
| + except subprocess2.CalledProcessError: |
| + return None |
| + |
| + @staticmethod |
| + def IsValidRevision(cwd, url, rev): |
|
M-A Ruel
2011/11/09 14:16:08
Why url here?
Dan Beam
2011/11/09 19:21:59
To let scm.{GIT,SVN}.IsValidRevision() take the sa
M-A Ruel
2011/11/09 19:25:51
I prefer not. It's fine to have different interfac
Dan Beam
2011/11/09 19:37:22
OK, great, will change!
Dan Beam
2011/11/10 10:29:15
Done.
|
| + """Verifies the revision is a proper git revision.""" |
| + try: |
| + GIT.Capture(['rev-parse', rev], cwd=cwd) |
| + return True |
| + except subprocess2.CalledProcessError: |
| + return False |
| + |
| @classmethod |
| def AssertVersion(cls, min_version): |
| """Asserts git's version is at least min_version.""" |
| @@ -929,6 +964,15 @@ |
| directory = parent |
| return GetCasedPath(directory) |
| + @staticmethod |
| + def IsValidRevision(cwd, url, rev): |
|
M-A Ruel
2011/11/09 14:16:08
Remove url from here, have the caller reformat wha
Dan Beam
2011/11/09 19:21:59
Same reason as above, make both methods take same
Dan Beam
2011/11/10 10:29:15
Done.
|
| + """Verifies the revision looks like an SVN revision.""" |
| + try: |
| + SVN.Capture(['info', '%s@%s' % (url, rev)]) |
| + return True |
| + except subprocess2.CalledProcessError: |
| + return False |
| + |
| @classmethod |
| def AssertVersion(cls, min_version): |
| """Asserts svn's version is at least min_version.""" |