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

Unified Diff: gclient_scm.py

Issue 10103024: Check binary existence in gclient: 2nd try. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Created 8 years, 8 months 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 | « no previous file | tests/gclient_scm_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient_scm.py
===================================================================
--- gclient_scm.py (revision 132728)
+++ gclient_scm.py (working copy)
@@ -85,7 +85,10 @@
scm_name = GetScmName(url)
if not scm_name in SCM_MAP:
raise gclient_utils.Error('No SCM found for url %s' % url)
- return SCM_MAP[scm_name](url, root_dir, relpath)
+ scm_class = SCM_MAP[scm_name]
+ if not scm_class.BinaryExists():
+ raise gclient_utils.Error('%s command not found' % scm_name)
+ return scm_class(url, root_dir, relpath)
# SCMWrapper base class
@@ -133,6 +136,18 @@
url = url[4:]
SCMWrapper.__init__(self, url, root_dir, relpath)
+ @staticmethod
+ def BinaryExists():
+ """Returns true if the command exists."""
+ try:
+ # We assume git is newer than 1.7. See: crbug.com/114483
+ result, version = scm.GIT.AssertVersion('1.7')
+ if not result:
+ raise gclient_utils.Error('Git version is older than 1.7: %s' % version)
+ return result
+ except OSError:
+ return False
+
def GetRevisionDate(self, revision):
"""Returns the given revision's date in ISO-8601 format (which contains the
time zone)."""
@@ -775,6 +790,17 @@
class SVNWrapper(SCMWrapper):
""" Wrapper for SVN """
+ @staticmethod
+ def BinaryExists():
+ """Returns true if the command exists."""
+ try:
+ result, version = scm.SVN.AssertVersion('1.4')
+ if not result:
+ raise gclient_utils.Error('SVN version is older than 1.4: %s' % version)
+ return result
+ except OSError:
+ return False
+
def GetRevisionDate(self, revision):
"""Returns the given revision's date in ISO-8601 format (which contains the
time zone)."""
« no previous file with comments | « no previous file | tests/gclient_scm_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698