Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(774)

Unified Diff: scm.py

Issue 8382030: depot_tools: Add git svn find-rev for safesync_url parsing (commonly LKGR link). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: changing more occurrences of SVN to Svn Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gclient_scm.py ('k') | tests/gclient_scm_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scm.py
diff --git a/scm.py b/scm.py
index 2b63901a964c30ed79842f96b284d326e66c35fe..da094fb596825f738e58a985f5c197e609151559 100644
--- a/scm.py
+++ b/scm.py
@@ -380,6 +380,37 @@ class GIT(object):
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)
+ 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 lines else None
+ except subprocess2.CalledProcessError:
+ return None
+
+ @staticmethod
+ def IsValidRevision(cwd, rev):
+ """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."""
@@ -946,6 +977,15 @@ class SVN(object):
cwd = parent
return GetCasedPath(cwd)
+ @staticmethod
+ def IsValidRevision(url):
+ """Verifies the revision looks like an SVN revision."""
+ try:
+ SVN.Capture(['info', url], cwd=None)
+ return True
+ except subprocess2.CalledProcessError:
+ return False
+
@classmethod
def AssertVersion(cls, min_version):
"""Asserts svn's version is at least min_version."""
« no previous file with comments | « gclient_scm.py ('k') | tests/gclient_scm_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698