Mercurial > hg-stable
changeset 17025:8ad08dcab7d9 stable
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.
author | Benjamin Pollack <benjamin@bitquabit.com> |
---|---|
date | Tue, 12 Jun 2012 09:31:04 -0400 |
parents | 33b057778cd2 |
children | f8af57c00a29 |
files | mercurial/subrepo.py |
diffstat | 1 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/subrepo.py Tue Jun 12 09:28:55 2012 -0400 +++ b/mercurial/subrepo.py Tue Jun 12 09:31:04 2012 -0400 @@ -850,7 +850,14 @@ self._ensuregit() def _ensuregit(self): - out, err = self._gitnodir(['--version']) + try: + self._gitexecutable = 'git' + out, err = self._gitnodir(['--version']) + except OSError, e: + if e.errno != 2 or os.name != 'nt': + raise + self._gitexecutable = 'git.cmd' + out, err = self._gitnodir(['--version']) m = re.search(r'^git version (\d+)\.(\d+)\.(\d+)', out) if not m: self._ui.warn(_('cannot retrieve git version')) @@ -883,8 +890,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