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

Unified Diff: fetch.py

Issue 14093004: Ensure that we pick up 'git.bat' and 'svn.bat' on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: simplify even further Created 7 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fetch.py
diff --git a/fetch.py b/fetch.py
index 1e5d688f0b177f1d3dcf19c0ba8d4260472d84fa..68795587480cf508bf9c91f78a9058c2cd68d72d 100755
--- a/fetch.py
+++ b/fetch.py
@@ -24,6 +24,8 @@ import subprocess
import sys
import pipes
+from distutils import spawn
+
SCRIPT_PATH = os.path.dirname(os.path.abspath(__file__))
@@ -56,31 +58,41 @@ class Checkout(object):
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):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698