[PATCH 2 of 2 STABLE] subrepo: support Git being named "git.cmd" on Windows (issue3173)
Benjamin Pollack
benjamin at bitquabit.com
Tue Jun 12 09:25:45 CDT 2012
# HG changeset patch
# User Benjamin Pollack <benjamin at bitquabit.com>
# Date 1339507864 14400
# Branch stable
# Node ID acd1e2301b66c8401996ec514a2bd176fa4fa39a
# Parent 837053114bd0cac99add9128156d898f27d2e5b1
subrepo: support Git being named "git.cmd" on Windows (issue3173)
Popen does not consider "foo.cmd" equivalent to "foo" on Windows.
Unfortunately, the default MSYS Git installation installs only "git.cmd" into
the path by default. This patch probes for both possible names on Windows.
diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -850,7 +850,14 @@
self._ensuregit()
def _ensuregit(self):
- out = self._gitcommand(['--version'])
+ try:
+ self._gitexecutable = 'git'
+ out = self._gitcommand(['--version'])
+ except OSError, e:
+ if e.errno != 2 or os.name != 'nt':
+ raise
+ self._gitexecutable = 'git.cmd'
+ out = self._gitcommand(['--version'])
m = re.search(r'^git version (\d+)\.(\d+)\.(\d+)', out)
if not m:
self._ui.warn(_('cannot retrieve git version'))
@@ -878,8 +885,8 @@
errpipe = None
if self._ui.quiet:
errpipe = open(os.devnull, 'w')
- p = subprocess.Popen(['git'] + commands, bufsize=-1, cwd=cwd, env=env,
- close_fds=util.closefds,
+ p = subprocess.Popen([self._gitexecutable] + commands, bufsize=-1,
+ cwd=cwd, env=env, close_fds=util.closefds,
stdout=subprocess.PIPE, stderr=errpipe)
if stream:
return p.stdout, None
More information about the Mercurial-devel
mailing list