Ensure that we pick up 'git.bat' and 'svn.bat' on Windows.
R=maruel@chromium.org
BUG=227526
Review URL: https://chromiumcodereview.appspot.com/14093004
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@193865 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/fetch.py b/fetch.py
index 1e5d688..6879558 100755
--- a/fetch.py
+++ b/fetch.py
@@ -24,6 +24,8 @@
import sys
import pipes
+from distutils import spawn
+
SCRIPT_PATH = os.path.dirname(os.path.abspath(__file__))
@@ -56,31 +58,41 @@
def sync(self):
pass
+ def run(self, cmd, **kwargs):
+ print 'Running: %s' % (' '.join(pipes.quote(x) for x in cmd))
+ if self.dryrun:
+ return 0
+ return subprocess.check_call(cmd, **kwargs)
+
class GclientCheckout(Checkout):
def run_gclient(self, *cmd, **kwargs):
- print 'Running: gclient %s' % ' '.join(pipes.quote(x) for x in cmd)
- if not self.dryrun:
- return subprocess.check_call(
- (sys.executable, os.path.join(SCRIPT_PATH, 'gclient.py')) + cmd,
- **kwargs)
+ if not spawn.find_executable('gclient'):
+ cmd_prefix = (sys.executable, os.path.join(SCRIPT_PATH, 'gclient.py'))
+ else:
+ cmd_prefix = ('gclient',)
+ return self.run(cmd_prefix + cmd, **kwargs)
class GitCheckout(Checkout):
def run_git(self, *cmd, **kwargs):
- print 'Running: git %s' % ' '.join(pipes.quote(x) for x in cmd)
- if not self.dryrun:
- return subprocess.check_call(('git',) + cmd, **kwargs)
+ if sys.platform == 'win32' and not spawn.find_executable('git'):
+ git_path = os.path.join(SCRIPT_PATH, 'git-1.8.0_bin', 'bin', 'git.exe')
+ else:
+ git_path = 'git'
+ return self.run((git_path,) + cmd, **kwargs)
class SvnCheckout(Checkout):
def run_svn(self, *cmd, **kwargs):
- print 'Running: svn %s' % ' '.join(pipes.quote(x) for x in cmd)
- if not self.dryrun:
- return subprocess.check_call(('svn',) + cmd, **kwargs)
+ if sys.platform == 'win32' and not spawn.find_executable('svn'):
+ svn_path = os.path.join(SCRIPT_PATH, 'svn_bin', 'svn.exe')
+ else:
+ svn_path = 'svn'
+ return self.run((svn_path,) + cmd, **kwargs)
class GclientGitCheckout(GclientCheckout, GitCheckout):